Skip to content

Commit

Permalink
update proto to 0.12.0 (open-telemetry#2415)
Browse files Browse the repository at this point in the history
* update proto to 0.12.0

This PR updates the proto to the latest release.

* remove deprecated status codes, no longer supported

* update logs to log_records

* remove unused import

* update changelog
  • Loading branch information
Alex Boten authored Jan 28, 2022
1 parent d112814 commit 2f2d252
Show file tree
Hide file tree
Showing 14 changed files with 695 additions and 1,027 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased](https://github.com/open-telemetry/opentelemetry-python/compare/v1.9.0-0.28b0...HEAD)

- Update opentelemetry-proto to v0.12.0. Note that this update removes deprecated status codes.
([#2415](https://github.com/open-telemetry/opentelemetry-python/pull/2415))

## [1.9.0-0.28b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.9.0-0.28b0) - 2022-01-26


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def _translate_data(
"severity_number"
] = log_data.log_record.severity_number.value

instrumentation_library_logs.logs.append(
instrumentation_library_logs.log_records.append(
PB2LogRecord(**self._collector_kwargs)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
)
from opentelemetry.sdk.trace import ReadableSpan
from opentelemetry.sdk.trace.export import SpanExporter, SpanExportResult
from opentelemetry.trace import StatusCode

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -208,11 +207,7 @@ def _translate_links(self, sdk_span: ReadableSpan) -> None:
def _translate_status(self, sdk_span: ReadableSpan) -> None:
# pylint: disable=no-member
if sdk_span.status is not None:
deprecated_code = Status.DEPRECATED_STATUS_CODE_OK
if sdk_span.status.status_code == StatusCode.ERROR:
deprecated_code = Status.DEPRECATED_STATUS_CODE_UNKNOWN_ERROR
self._collector_kwargs["status"] = Status(
deprecated_code=deprecated_code,
code=sdk_span.status.status_code.value,
message=sdk_span.status.description,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def test_translate_log_data(self):
instrumentation_library=InstrumentationLibrary(
name="first_name", version="first_version"
),
logs=[
log_records=[
PB2LogRecord(
# pylint: disable=no-member
name="name",
Expand Down Expand Up @@ -372,7 +372,7 @@ def test_translate_multiple_logs(self):
instrumentation_library=InstrumentationLibrary(
name="first_name", version="first_version"
),
logs=[
log_records=[
PB2LogRecord(
# pylint: disable=no-member
name="name",
Expand Down Expand Up @@ -410,7 +410,7 @@ def test_translate_multiple_logs(self):
instrumentation_library=InstrumentationLibrary(
name="second_name", version="second_version"
),
logs=[
log_records=[
PB2LogRecord(
# pylint: disable=no-member
name="info name",
Expand Down Expand Up @@ -456,7 +456,7 @@ def test_translate_multiple_logs(self):
instrumentation_library=InstrumentationLibrary(
name="third_name", version="third_version"
),
logs=[
log_records=[
PB2LogRecord(
# pylint: disable=no-member
name="error name",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,6 @@ def _check_translated_status(
self,
translated: ExportTraceServiceRequest,
code_expected: Status,
deprecated_code_expected: Status,
):
status = (
translated.resource_spans[0]
Expand All @@ -775,10 +774,6 @@ def _check_translated_status(
status.code,
code_expected,
)
self.assertEqual(
status.deprecated_code,
deprecated_code_expected,
)

def test_span_status_translate(self):
# pylint: disable=protected-access,no-member
Expand All @@ -797,17 +792,14 @@ def test_span_status_translate(self):
self._check_translated_status(
unset_translated,
Status.STATUS_CODE_UNSET,
Status.DEPRECATED_STATUS_CODE_OK,
)
self._check_translated_status(
ok_translated,
Status.STATUS_CODE_OK,
Status.DEPRECATED_STATUS_CODE_OK,
)
self._check_translated_status(
error_translated,
Status.STATUS_CODE_ERROR,
Status.DEPRECATED_STATUS_CODE_UNKNOWN_ERROR,
)

# pylint:disable=no-member
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
from opentelemetry.trace import Link
from opentelemetry.trace import SpanKind
from opentelemetry.trace.span import SpanContext, TraceState, Status
from opentelemetry.trace.status import StatusCode
from opentelemetry.util.types import Attributes

# pylint: disable=E1101
Expand Down Expand Up @@ -196,11 +195,7 @@ def _encode_links(links: List[Link]) -> List[PB2SPan.Link]:
def _encode_status(status: Status) -> Optional[PB2Status]:
pb2_status = None
if status is not None:
deprecated_code = PB2Status.DEPRECATED_STATUS_CODE_OK
if status.status_code is StatusCode.ERROR:
deprecated_code = PB2Status.DEPRECATED_STATUS_CODE_UNKNOWN_ERROR
pb2_status = PB2Status(
deprecated_code=deprecated_code,
code=status.status_code.value,
message=status.description,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ def get_exhaustive_test_spans(
)
],
status=PB2Status(
deprecated_code=PB2Status.DEPRECATED_STATUS_CODE_UNKNOWN_ERROR, # pylint: disable=no-member
code=SDKStatusCode.ERROR.value,
message="Example description",
),
Expand Down Expand Up @@ -374,23 +373,20 @@ def test_encode_status_code_translations(self):
self.assertEqual(
_encode_status(SDKStatus(status_code=SDKStatusCode.UNSET)),
PB2Status(
deprecated_code=PB2Status.DEPRECATED_STATUS_CODE_OK, # pylint: disable=no-member
code=SDKStatusCode.UNSET.value,
),
)

self.assertEqual(
_encode_status(SDKStatus(status_code=SDKStatusCode.OK)),
PB2Status(
deprecated_code=PB2Status.DEPRECATED_STATUS_CODE_OK, # pylint: disable=no-member
code=SDKStatusCode.OK.value,
),
)

self.assertEqual(
_encode_status(SDKStatus(status_code=SDKStatusCode.ERROR)),
PB2Status(
deprecated_code=PB2Status.DEPRECATED_STATUS_CODE_UNKNOWN_ERROR, # pylint: disable=no-member
code=SDKStatusCode.ERROR.value,
),
)
67 changes: 54 additions & 13 deletions opentelemetry-proto/src/opentelemetry/proto/logs/v1/logs_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2f2d252

Please sign in to comment.