Skip to content

FlaskInstrumentor http.server.request.duration exemplars are missing span context #3913

@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 FlaskInstrumentor 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 FlaskInstrumentor 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 Flask app, with a route that responds after about 500ms.
  4. Make requests to that route and check exported metrics.

Expected Result

otel-collector-1              | Exemplars:
otel-collector-1              | Exemplar #0
otel-collector-1              |      -> Trace ID: <a_valid_trace_id>
otel-collector-1              |      -> Span ID: <a_valid_span_id>
otel-collector-1              |      -> Timestamp: 2025-10-31 22:30:24.370148763 +0000 UTC
otel-collector-1              |      -> Value: 500

Actual Result

Trace ID and Span ID are empty:

otel-collector-1              | Exemplars:
otel-collector-1              | Exemplar #0
otel-collector-1              |      -> Trace ID:
otel-collector-1              |      -> Span ID:
otel-collector-1              |      -> Timestamp: 2025-10-31 22:30:24.370148763 +0000 UTC
otel-collector-1              |      -> Value: 500

Additional context

Related to

  1. Metrics: Add support for exemplars opentelemetry-python#2407
  2. Add exemplar support to all WSGI based instrumentations #2158
  3. 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