open-telemetry / open-telemetry/opentelemetry-python
Make it possible to disable specific signals when using auto-instrumentation
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.6k
- Forks
- 1k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 19
Description
Is your feature request related to a problem?
I'll describe this in terms of disabling metrics, because that's the issue that vexes me the most, but this should be applicable to other signals as well
I use OpenTelemetry purely for tracing and I'd like as little as possible instrumentation code to run for other signals. This is both for performance reasons (though the impact is not that big) and because certain instrumentations can emit warnings related to the other signals, which I'd have to silence (a good example of that is the aiohttp-server instrumentation, which gets the same meters for each request, resulting in "meter already exists warnings").
Describe the solution you'd like
opentelemetry-instrument has the --meter_provider arguments(and corresponding env var), which is ignored, as far as I can see (configuration code uses MeterProvider unconditionally). These could accept the none value, and the auto-instrumentation code would react by selecting the NoOpMeterProvider. As is, this wouldn't help with the aiohttp-server issue described above, because NoOpMeter still emits warnings, so I think it should also be changed, to emit no warnings.
Describe alternatives you've considered
I don't think there are better alternatives, since it seems like some instrumentations (again aiohttp-server is an example) are implemented in a way where you can't choose which signals to instrument. So, to continue to work they should at least be able to get meters (and corresponding objects for other signals) and create metric objects. Which is why, I think, using the no-op versions of these objects, and having the no-op objects emit no warnings is the best we can do
Additional Context
No response
Would you like to implement a fix?
Yes
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 with the opentelemetry-instrument entry point and its --meter_provider configuration, then inspect how auto-instrumentation creates MeterProvider instances and how aiohttp-server obtains meters. Done means a none setting selects NoOpMeterProvider for the chosen signal and no-op meters avoid the reported warnings without affecting tracing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- observability-sre
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100