Skip to content

Commit 98f7b60

Browse files
authored
Update InstrumentationInfo tag keys for Jaeger and Zipkin exporters (open-telemetry#1535)
1 parent 5184c51 commit 98f7b60

File tree

6 files changed

+24
-21
lines changed

6 files changed

+24
-21
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5757
([#1533](https://github.com/open-telemetry/opentelemetry-python/pull/1533))
5858
- `opentelemetry-sdk` The JaegerPropagator has been moved into its own package: `opentelemetry-propagator-jaeger`
5959
([#1525](https://github.com/open-telemetry/opentelemetry-python/pull/1525))
60+
- `opentelemetry-exporter-jaeger`, `opentelemetry-exporter-zipkin` Update InstrumentationInfo tag keys for Jaeger and Zipkin exporters
61+
([#1535](https://github.com/open-telemetry/opentelemetry-python/pull/1535))
6062

6163
### Removed
6264
- `opentelemetry-api` Remove ThreadLocalRuntimeContext since python3.4 is not supported.

exporter/opentelemetry-exporter-jaeger/src/opentelemetry/exporter/jaeger/translate/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
SpanKind.INTERNAL: "internal",
2525
}
2626

27-
NAME_KEY = "otel.instrumentation_library.name"
28-
VERSION_KEY = "otel.instrumentation_library.version"
27+
NAME_KEY = "otel.library.name"
28+
VERSION_KEY = "otel.library.version"
2929

3030

3131
def _nsec_to_usec_round(nsec: int) -> int:

exporter/opentelemetry-exporter-jaeger/tests/test_jaeger_exporter_thrift.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,12 +399,12 @@ def test_translate_to_jaeger(self):
399399
vStr="internal",
400400
),
401401
jaeger.Tag(
402-
key="otel.instrumentation_library.name",
402+
key=jaeger_exporter.translate.NAME_KEY,
403403
vType=jaeger.TagType.STRING,
404404
vStr="name",
405405
),
406406
jaeger.Tag(
407-
key="otel.instrumentation_library.version",
407+
key=jaeger_exporter.translate.VERSION_KEY,
408408
vType=jaeger.TagType.STRING,
409409
vStr="version",
410410
),

exporter/opentelemetry-exporter-jaeger/tests/test_jarget_exporter_protobuf.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@
2424
from opentelemetry import trace as trace_api
2525
from opentelemetry.configuration import Configuration
2626
from opentelemetry.exporter.jaeger import JaegerSpanExporter
27-
from opentelemetry.exporter.jaeger.translate import Translate
27+
from opentelemetry.exporter.jaeger.translate import (
28+
NAME_KEY,
29+
VERSION_KEY,
30+
Translate,
31+
)
2832
from opentelemetry.sdk import trace
2933
from opentelemetry.sdk.trace import Resource
3034
from opentelemetry.sdk.util.instrumentation import InstrumentationInfo
@@ -358,12 +362,12 @@ def test_translate_to_jaeger(self):
358362
v_str="internal",
359363
),
360364
model_pb2.KeyValue(
361-
key="otel.instrumentation_library.name",
365+
key=NAME_KEY,
362366
v_type=model_pb2.ValueType.STRING,
363367
v_str="name",
364368
),
365369
model_pb2.KeyValue(
366-
key="otel.instrumentation_library.version",
370+
key=VERSION_KEY,
367371
v_type=model_pb2.ValueType.STRING,
368372
v_str="version",
369373
),

exporter/opentelemetry-exporter-zipkin/src/opentelemetry/exporter/zipkin/__init__.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@
107107
SpanKind.CONSUMER: zipkin_pb2.Span.Kind.CONSUMER,
108108
}
109109

110+
NAME_KEY = "otel.library.name"
111+
VERSION_KEY = "otel.library.version"
112+
110113
SUCCESS_STATUS_CODES = (200, 202)
111114

112115
logger = logging.getLogger(__name__)
@@ -231,11 +234,9 @@ def _translate_to_json(self, spans: Sequence[Span]):
231234
}
232235

233236
if span.instrumentation_info is not None:
237+
zipkin_span["tags"][NAME_KEY] = span.instrumentation_info.name
234238
zipkin_span["tags"][
235-
"otel.instrumentation_library.name"
236-
] = span.instrumentation_info.name
237-
zipkin_span["tags"][
238-
"otel.instrumentation_library.version"
239+
VERSION_KEY
239240
] = span.instrumentation_info.version
240241

241242
if span.status.status_code is not StatusCode.UNSET:
@@ -313,8 +314,8 @@ def _translate_to_protobuf(self, spans: Sequence[Span]):
313314
if span.instrumentation_info is not None:
314315
pbuf_span.tags.update(
315316
{
316-
"otel.instrumentation_library.name": span.instrumentation_info.name,
317-
"otel.instrumentation_library.version": span.instrumentation_info.version,
317+
NAME_KEY: span.instrumentation_info.name,
318+
VERSION_KEY: span.instrumentation_info.version,
318319
}
319320
)
320321

exporter/opentelemetry-exporter-zipkin/tests/test_zipkin_exporter.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@
2020
from opentelemetry import trace as trace_api
2121
from opentelemetry.configuration import Configuration
2222
from opentelemetry.exporter.zipkin import (
23+
NAME_KEY,
2324
SPAN_KIND_MAP_JSON,
2425
SPAN_KIND_MAP_PROTOBUF,
2526
TRANSPORT_FORMAT_JSON,
2627
TRANSPORT_FORMAT_PROTOBUF,
28+
VERSION_KEY,
2729
ZipkinSpanExporter,
2830
nsec_to_usec_round,
2931
)
@@ -297,10 +299,7 @@ def test_export_json(self):
297299
"duration": durations[3] // 10 ** 3,
298300
"localEndpoint": local_endpoint,
299301
"kind": span_kind,
300-
"tags": {
301-
"otel.instrumentation_library.name": "name",
302-
"otel.instrumentation_library.version": "version",
303-
},
302+
"tags": {NAME_KEY: "name", VERSION_KEY: "version"},
304303
"annotations": None,
305304
},
306305
]
@@ -833,10 +832,7 @@ def test_export_protobuf(self):
833832
duration=nsec_to_usec_round(durations[3]),
834833
local_endpoint=local_endpoint,
835834
kind=span_kind,
836-
tags={
837-
"otel.instrumentation_library.name": "name",
838-
"otel.instrumentation_library.version": "version",
839-
},
835+
tags={NAME_KEY: "name", VERSION_KEY: "version"},
840836
),
841837
],
842838
)

0 commit comments

Comments
 (0)