open-telemetry / open-telemetry/opentelemetry-python-contrib
http server instrumentations: make it possible to sample according to captured headers
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 1.1k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 16
Description
I would like to do sampling depending on any captured request header.
This should be doable with the Composite Rule Based Sampler but we need instrumentations to collect these headers before the span is created. AFAICS no http server instrumentation does that. The capturing of headers is opt-in so any eventual performance hit will be paid only if requested.
Instrumentations to fix:
- aiohttp-server, see
create_aiohttp_middleware - django, see
_DjangoMiddleware.process_request - asgi, see
OpenTelemetryMiddleware.__call__ - falcon, see
_InstrumentedFalconAPI.__call__ - flask, see
_wrapped_before_request - pyramid, see
_before_traversal - tornado, see
_start_span - wsgi, see
OpenTelemetryMiddleware.__call__
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by inspecting the listed entry points: create_aiohttp_middleware, _DjangoMiddleware.process_request, OpenTelemetryMiddleware.call, _InstrumentedFalconAPI.call, _wrapped_before_request, _before_traversal, _start_span, and the WSGI middleware call. Trace when each server span is created and how opt-in captured headers are currently handled. Done means captured request headers are available before span creation in all listed instrumentations so sampling can use them.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100