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

aiohttp-server instrumentation creates metrics instance for each request and spam with warnings

Open
#2,168 2 comments 2 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
Start aiohttp server with instrumentation and make several requests.

What is the expected behavior?
No warning shows

What is the actual behavior?
Warnings in logs for each request:

An instrument with name http.server.duration, type Histogram, unit ms and description measures the duration of the inbound HTTP request has been created already.
An instrument with name http.server.active_requests, type UpDownCounter, unit requests and description measures the number of concurrent HTTP requests those are currently in flight has been created already.

Additional context
Aiohttp instrumentation creates middleware that runs for each request and init metric each time. Instead, it should attach metrics to the app and only increment/decrement it.
https://github.com/open-telemetry/opentelemetry-python-contrib/blob/8fd2105ceae604cf39a67f1c4dd154753b43fcd1/instrumentation/opentelemetry-instrumentation-aiohttp-server/src/opentelemetry/instrumentation/aiohttp_server/__init__.py#L207

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 207 and reproduce the behavior with several requests. Check how the middleware initializes metrics and how metrics are attached to the app. Done means repeated requests no longer create new metric instances or emit duplicate warnings while request metrics still update.

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
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.