open-telemetry / open-telemetry/opentelemetry-cpp
Manually trigger MetricReader to run callbacks
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 1.4k
- Forks
- 632
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 75
Description
Is your feature request related to a problem?
I need to publish metrics on service shutdown, but PeriodicExportingMetricReader only allows me to publish on the configured interval.
Describe the solution you'd like
I'd like to have the metrics::MetricReader (returned by Provider::GetMeterProvider()) capable of running a round of callbacks across registered observables on demand.
Describe alternatives you've considered
I have tried MetricReader ->ForceFlush() and MetricReader->Shutdown() but those don't trigger the callbacks used to check my observables.
Additional context
I have published and example here with the exact scenario I'm trying to achieve: https://stackoverflow.com/questions/79742765/how-do-you-force-an-opentelemetry-measurement-event
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 tracing MetricReader from Provider::GetMeterProvider(), then compare the existing ForceFlush() and Shutdown() behavior with the callback flow for registered observables. The change is complete when a reader can run those callbacks on demand so metrics can be published during service shutdown; the linked example describes the target scenario.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- observability-sre
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100