diff --git a/CHANGELOG.md b/CHANGELOG.md index a4b55712f3b..c65e1a73bc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,6 +57,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([#1533](https://github.com/open-telemetry/opentelemetry-python/pull/1533)) - `opentelemetry-sdk` The JaegerPropagator has been moved into its own package: `opentelemetry-propagator-jaeger` ([#1525](https://github.com/open-telemetry/opentelemetry-python/pull/1525)) +- `opentelemetry-exporter-jaeger`, `opentelemetry-exporter-zipkin` Update InstrumentationInfo tag keys for Jaeger and Zipkin exporters + ([#1535](https://github.com/open-telemetry/opentelemetry-python/pull/1535)) ### Removed - `opentelemetry-api` Remove ThreadLocalRuntimeContext since python3.4 is not supported. diff --git a/exporter/opentelemetry-exporter-jaeger/src/opentelemetry/exporter/jaeger/translate/__init__.py b/exporter/opentelemetry-exporter-jaeger/src/opentelemetry/exporter/jaeger/translate/__init__.py index b840687fbeb..853da9ac6df 100644 --- a/exporter/opentelemetry-exporter-jaeger/src/opentelemetry/exporter/jaeger/translate/__init__.py +++ b/exporter/opentelemetry-exporter-jaeger/src/opentelemetry/exporter/jaeger/translate/__init__.py @@ -24,8 +24,8 @@ SpanKind.INTERNAL: "internal", } -NAME_KEY = "otel.instrumentation_library.name" -VERSION_KEY = "otel.instrumentation_library.version" +NAME_KEY = "otel.library.name" +VERSION_KEY = "otel.library.version" def _nsec_to_usec_round(nsec: int) -> int: diff --git a/exporter/opentelemetry-exporter-jaeger/tests/test_jaeger_exporter_thrift.py b/exporter/opentelemetry-exporter-jaeger/tests/test_jaeger_exporter_thrift.py index 132d92b1e12..379dd9a1e7d 100644 --- a/exporter/opentelemetry-exporter-jaeger/tests/test_jaeger_exporter_thrift.py +++ b/exporter/opentelemetry-exporter-jaeger/tests/test_jaeger_exporter_thrift.py @@ -399,12 +399,12 @@ def test_translate_to_jaeger(self): vStr="internal", ), jaeger.Tag( - key="otel.instrumentation_library.name", + key=jaeger_exporter.translate.NAME_KEY, vType=jaeger.TagType.STRING, vStr="name", ), jaeger.Tag( - key="otel.instrumentation_library.version", + key=jaeger_exporter.translate.VERSION_KEY, vType=jaeger.TagType.STRING, vStr="version", ), diff --git a/exporter/opentelemetry-exporter-jaeger/tests/test_jarget_exporter_protobuf.py b/exporter/opentelemetry-exporter-jaeger/tests/test_jarget_exporter_protobuf.py index f6f7d99bb52..2af228a6b78 100644 --- a/exporter/opentelemetry-exporter-jaeger/tests/test_jarget_exporter_protobuf.py +++ b/exporter/opentelemetry-exporter-jaeger/tests/test_jarget_exporter_protobuf.py @@ -24,7 +24,11 @@ from opentelemetry import trace as trace_api from opentelemetry.configuration import Configuration from opentelemetry.exporter.jaeger import JaegerSpanExporter -from opentelemetry.exporter.jaeger.translate import Translate +from opentelemetry.exporter.jaeger.translate import ( + NAME_KEY, + VERSION_KEY, + Translate, +) from opentelemetry.sdk import trace from opentelemetry.sdk.trace import Resource from opentelemetry.sdk.util.instrumentation import InstrumentationInfo @@ -358,12 +362,12 @@ def test_translate_to_jaeger(self): v_str="internal", ), model_pb2.KeyValue( - key="otel.instrumentation_library.name", + key=NAME_KEY, v_type=model_pb2.ValueType.STRING, v_str="name", ), model_pb2.KeyValue( - key="otel.instrumentation_library.version", + key=VERSION_KEY, v_type=model_pb2.ValueType.STRING, v_str="version", ), diff --git a/exporter/opentelemetry-exporter-zipkin/src/opentelemetry/exporter/zipkin/__init__.py b/exporter/opentelemetry-exporter-zipkin/src/opentelemetry/exporter/zipkin/__init__.py index 1610e0a3f67..387e33d5944 100644 --- a/exporter/opentelemetry-exporter-zipkin/src/opentelemetry/exporter/zipkin/__init__.py +++ b/exporter/opentelemetry-exporter-zipkin/src/opentelemetry/exporter/zipkin/__init__.py @@ -107,6 +107,9 @@ SpanKind.CONSUMER: zipkin_pb2.Span.Kind.CONSUMER, } +NAME_KEY = "otel.library.name" +VERSION_KEY = "otel.library.version" + SUCCESS_STATUS_CODES = (200, 202) logger = logging.getLogger(__name__) @@ -231,11 +234,9 @@ def _translate_to_json(self, spans: Sequence[Span]): } if span.instrumentation_info is not None: + zipkin_span["tags"][NAME_KEY] = span.instrumentation_info.name zipkin_span["tags"][ - "otel.instrumentation_library.name" - ] = span.instrumentation_info.name - zipkin_span["tags"][ - "otel.instrumentation_library.version" + VERSION_KEY ] = span.instrumentation_info.version if span.status.status_code is not StatusCode.UNSET: @@ -313,8 +314,8 @@ def _translate_to_protobuf(self, spans: Sequence[Span]): if span.instrumentation_info is not None: pbuf_span.tags.update( { - "otel.instrumentation_library.name": span.instrumentation_info.name, - "otel.instrumentation_library.version": span.instrumentation_info.version, + NAME_KEY: span.instrumentation_info.name, + VERSION_KEY: span.instrumentation_info.version, } ) diff --git a/exporter/opentelemetry-exporter-zipkin/tests/test_zipkin_exporter.py b/exporter/opentelemetry-exporter-zipkin/tests/test_zipkin_exporter.py index ee6c9f2a09c..30837106c1a 100644 --- a/exporter/opentelemetry-exporter-zipkin/tests/test_zipkin_exporter.py +++ b/exporter/opentelemetry-exporter-zipkin/tests/test_zipkin_exporter.py @@ -20,10 +20,12 @@ from opentelemetry import trace as trace_api from opentelemetry.configuration import Configuration from opentelemetry.exporter.zipkin import ( + NAME_KEY, SPAN_KIND_MAP_JSON, SPAN_KIND_MAP_PROTOBUF, TRANSPORT_FORMAT_JSON, TRANSPORT_FORMAT_PROTOBUF, + VERSION_KEY, ZipkinSpanExporter, nsec_to_usec_round, ) @@ -297,10 +299,7 @@ def test_export_json(self): "duration": durations[3] // 10 ** 3, "localEndpoint": local_endpoint, "kind": span_kind, - "tags": { - "otel.instrumentation_library.name": "name", - "otel.instrumentation_library.version": "version", - }, + "tags": {NAME_KEY: "name", VERSION_KEY: "version"}, "annotations": None, }, ] @@ -833,10 +832,7 @@ def test_export_protobuf(self): duration=nsec_to_usec_round(durations[3]), local_endpoint=local_endpoint, kind=span_kind, - tags={ - "otel.instrumentation_library.name": "name", - "otel.instrumentation_library.version": "version", - }, + tags={NAME_KEY: "name", VERSION_KEY: "version"}, ), ], )