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

aiohttp-server instrumentation doesn't pass attributes to the sampler

Open
#2,169 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
1.1k
Forks
1.1k
Avg merge
4d 15h
Merged PRs (30d)
16

Description

Describe your environment
python 3.11, opentelemetry-instrumentation-aiohttp-server v0.43b0 (installed from git).

Steps to reproduce
Use aiohttp-server instrumentation with a sampler based on attributes (e.g. based on http.target)

What is the expected behavior?
Sampler can access and sample attributes, like for the fastapi instrumentation

What is the actual behavior?
Attributes are not passed to the sampler

Additional context
Instrumentation creates a span without attributes and then updates it with attributes. Sampling decision is happening at the span creation, so attributes are ignored.
https://github.com/open-telemetry/opentelemetry-python-contrib/blob/8fd2105ceae604cf39a67f1c4dd154753b43fcd1/instrumentation/opentelemetry-instrumentation-aiohttp-server/src/opentelemetry/instrumentation/aiohttp_server/__init__.py#L225

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 in instrumentation/opentelemetry-instrumentation-aiohttp-server/src/opentelemetry/instrumentation/aiohttp_server/init.py around line 225, then compare the corresponding FastAPI instrumentation behavior. Reproduce the case with a sampler based on http.target and verify that the sampler can access the instrumentation attributes before sampling. Done means aiohttp-server sampling decisions can use those attributes.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
observability
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.