Describe the Problem
When using auto_instrument(middlewares=[StarletteIASTelemetryMiddleware(...)]), W3C baggage headers from incoming HTTP requests are not visible on spans as baggage is not extracted from the request headers into the OTel context.
Propose a Solution
In _IASMiddleware.dispatch(), extract and attach the OTel context.
from opentelemetry import context as otel_context, propagate
async def dispatch(self, request: Request, call_next: Any) -> Response:
token = self._attrs_var.set(_extract_ias_attrs(request))
ctx = propagate.extract(request.headers)
ctx_token = otel_context.attach(ctx)
try:
return await call_next(request)
finally:
otel_context.detach(ctx_token)
self._attrs_var.reset(token)
Describe Alternatives
Users would need to separately instrument their server.
Affected Development Phase
Development
Impact
Inconvenience
Timeline
No response
Describe the Problem
When using
auto_instrument(middlewares=[StarletteIASTelemetryMiddleware(...)]), W3C baggage headers from incoming HTTP requests are not visible on spans as baggage is not extracted from the request headers into the OTel context.Propose a Solution
In
_IASMiddleware.dispatch(), extract and attach the OTel context.Describe Alternatives
Users would need to separately instrument their server.
Affected Development Phase
Development
Impact
Inconvenience
Timeline
No response