open-telemetry / open-telemetry/opentelemetry-python-contrib

http server instrumentations: make it possible to sample according to captured headers

Open
#4,975 1 comment 1 reaction 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.