Describe your environment
OS: Debian 12
Python version: Any
Package version: 0.49b0 and later
What happened?
Since 1.28.0, the opentelemetry Python SDK supports exemplars. However some instrumentation libraries does not add exemplars because the measure are added/recorded outside of the active span.
For example, in the asgi instrumentation, all measures should be taken within the use_span context rather than outside:
|
self.active_requests_counter.add(1, active_requests_count_attrs) |
|
try: |
|
with trace.use_span(span, end_on_exit=False) as current_span: |
Steps to Reproduce
You can test the repository https://github.com/webscit/opentelemetry-demo-python with OTEL_AUTO_INSTRUMENTATION_LEVEL = 1, it uses fastapi instrumentation (but the flaw is actually in the asgi instrumentation).
Expected Result
Exemplars are recorded for all Python instrumentations
Actual Result
Some instrumentations are missing exemplars
Additional context
I don't know if all packages or only a subset of them are concerned by this. I have at least identified 3 cases:
| Package |
Line to blame |
| asgi |
|
with trace.use_span(span, end_on_exit=False) as current_span: |
|
| wsgi |
|
with trace.use_span(span): |
|
| tornado |
|
ctx = _start_span(tracer, handler) |
|
Would you like to implement a fix?
None
Describe your environment
OS: Debian 12
Python version: Any
Package version: 0.49b0 and later
What happened?
Since 1.28.0, the opentelemetry Python SDK supports exemplars. However some instrumentation libraries does not add exemplars because the measure are added/recorded outside of the active span.
For example, in the asgi instrumentation, all measures should be taken within the use_span context rather than outside:
opentelemetry-python-contrib/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py
Lines 707 to 709 in ae13079
Steps to Reproduce
You can test the repository https://github.com/webscit/opentelemetry-demo-python with
OTEL_AUTO_INSTRUMENTATION_LEVEL = 1, it uses fastapi instrumentation (but the flaw is actually in the asgi instrumentation).Expected Result
Exemplars are recorded for all Python instrumentations
Actual Result
Some instrumentations are missing exemplars
Additional context
I don't know if all packages or only a subset of them are concerned by this. I have at least identified 3 cases:
opentelemetry-python-contrib/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py
Line 709 in ae13079
opentelemetry-python-contrib/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/__init__.py
Line 664 in ae13079
opentelemetry-python-contrib/instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/__init__.py
Line 388 in ae13079
Would you like to implement a fix?
None