open-telemetry / open-telemetry/opentelemetry-cpp

Manually trigger MetricReader to run callbacks

Open
#3,608 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Stale triage/accepted
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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.