diff --git a/exporter/opentelemetry-exporter-jaeger/CHANGELOG.md b/exporter/opentelemetry-exporter-jaeger/CHANGELOG.md index 15c4d956d3c..fbca1396925 100644 --- a/exporter/opentelemetry-exporter-jaeger/CHANGELOG.md +++ b/exporter/opentelemetry-exporter-jaeger/CHANGELOG.md @@ -1,9 +1,10 @@ # Changelog ## Unreleased - - Drop support for Python 3.4 ([#1099](https://github.com/open-telemetry/opentelemetry-python/pull/1099)) +- Report instrumentation info + ([#1098](https://github.com/open-telemetry/opentelemetry-python/pull/1098)) ## Version 0.12b0 diff --git a/exporter/opentelemetry-exporter-jaeger/src/opentelemetry/exporter/jaeger/__init__.py b/exporter/opentelemetry-exporter-jaeger/src/opentelemetry/exporter/jaeger/__init__.py index b998a6aecf1..354fe8b85c1 100644 --- a/exporter/opentelemetry-exporter-jaeger/src/opentelemetry/exporter/jaeger/__init__.py +++ b/exporter/opentelemetry-exporter-jaeger/src/opentelemetry/exporter/jaeger/__init__.py @@ -214,6 +214,20 @@ def _translate_to_jaeger(spans: Span): ] ) + if span.instrumentation_info is not None: + tags.extend( + [ + _get_string_tag( + "otel.instrumentation_library.name", + span.instrumentation_info.name, + ), + _get_string_tag( + "otel.instrumentation_library.version", + span.instrumentation_info.version, + ), + ] + ) + # Ensure that if Status.Code is not OK, that we set the "error" tag on the Jaeger span. if status.canonical_code is not StatusCanonicalCode.OK: tags.append(_get_bool_tag("error", True)) diff --git a/exporter/opentelemetry-exporter-jaeger/tests/test_jaeger_exporter.py b/exporter/opentelemetry-exporter-jaeger/tests/test_jaeger_exporter.py index bb852a07988..c7870814226 100644 --- a/exporter/opentelemetry-exporter-jaeger/tests/test_jaeger_exporter.py +++ b/exporter/opentelemetry-exporter-jaeger/tests/test_jaeger_exporter.py @@ -23,6 +23,7 @@ from opentelemetry.exporter.jaeger.gen.jaeger import ttypes as jaeger from opentelemetry.sdk import trace from opentelemetry.sdk.trace import Resource +from opentelemetry.sdk.util.instrumentation import InstrumentationInfo from opentelemetry.trace.status import Status, StatusCanonicalCode @@ -221,6 +222,9 @@ def test_translate_to_jaeger(self): otel_spans[2].start(start_time=start_times[2]) otel_spans[2].resource = Resource({}) otel_spans[2].end(end_time=end_times[2]) + otel_spans[2].instrumentation_info = InstrumentationInfo( + name="name", version="version" + ) # pylint: disable=protected-access spans = jaeger_exporter._translate_to_jaeger(otel_spans) @@ -334,7 +338,33 @@ def test_translate_to_jaeger(self): startTime=start_times[2] // 10 ** 3, duration=durations[2] // 10 ** 3, flags=0, - tags=default_tags, + tags=[ + jaeger.Tag( + key="status.code", + vType=jaeger.TagType.LONG, + vLong=StatusCanonicalCode.OK.value, + ), + jaeger.Tag( + key="status.message", + vType=jaeger.TagType.STRING, + vStr=None, + ), + jaeger.Tag( + key="span.kind", + vType=jaeger.TagType.STRING, + vStr=trace_api.SpanKind.INTERNAL.name, + ), + jaeger.Tag( + key="otel.instrumentation_library.name", + vType=jaeger.TagType.STRING, + vStr="name", + ), + jaeger.Tag( + key="otel.instrumentation_library.version", + vType=jaeger.TagType.STRING, + vStr="version", + ), + ], ), ]