Skip to content

Commit

Permalink
Jaeger exporter report instrumentation info (open-telemetry#1098)
Browse files Browse the repository at this point in the history
  • Loading branch information
dengliming authored Sep 15, 2020
1 parent 1e34279 commit 071b1b3
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
3 changes: 2 additions & 1 deletion exporter/opentelemetry-exporter-jaeger/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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",
),
],
),
]

Expand Down

0 comments on commit 071b1b3

Please sign in to comment.