Skip to content

Commit

Permalink
Update InstrumentationInfo tag keys for Jaeger and Zipkin exporters (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
srikanthccv authored Jan 19, 2021
1 parent 5184c51 commit 98f7b60
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 21 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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,
}
)

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

0 comments on commit 98f7b60

Please sign in to comment.