Skip to content

Manually trigger MetricReader to run callbacks #3608

@charles1024

Description

@charles1024

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage/acceptedIndicates an issue or PR is ready to be actively worked on.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions