Skip to content

DjangoInstrumentor http.server.request.duration exemplars are missing span context #3951

@tammy-baylis-swi

Description

@tammy-baylis-swi

Describe your environment

OS: Ubuntu
Python version: Python 3.12.7
Package version: 1.38.0/0.59b0

An app instrumented with DjangoInstrumentor via auto-instrumentation.

What happened?

If exemplars are enabled (by setting exemplar filter), some metrics generated by some instrumentors export incomplete exemplars that have timestamps and values, but are missing trace ID and span ID (not very useful). Specific metrics affected include semconv-defined http.server.request.duration and http.server.duration from DjangoInstrumentor histogram record calls.

Steps to Reproduce

  1. Follow the example and provide MeterProvider with exemplar_filter=AlwaysOnExemplarFilter.
  2. Run an otel-collector locally with debug metrics export.
  3. Auto-instrument and run a Django app, with a route that responds after about 500ms.
  4. Make requests to that route and check exported metrics.

Expected Result

Exemplar #0
     -> Trace ID: <a_valid_trace_id>
     -> Span ID: <a_valid_span_id>
     -> Timestamp: 2025-11-14 21:47:09.021649 +0000 UTC
     -> Value: 167.652562

Actual Result

Exemplar #0
     -> Trace ID:
     -> Span ID:
     -> Timestamp: 2025-11-14 21:47:09.021649 +0000 UTC
     -> Value: 167.652562

Additional context

Related to

  1. FlaskInstrumentor http.server.request.duration exemplars are missing span context #3913
  2. Fix exemplar support #3031

Would you like to implement a fix?

Yes

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions