Skip to content

Error from Metricreader::Collect at shutdown when using PeriodicExportingMetricReader #2056

@timwoj

Description

@timwoj

Describe your environment
macOS Ventura, otel-cpp 1.8.3

Steps to reproduce
Run the metrics_simple example

What is the expected behavior?
Example should run without error printouts

What is the actual behavior?
During shutdown, the error MetricReader::Collect invoked while Shutdown in progress! is printed.

Additional context
I found this while implementing metrics in a project I work on, but I then discovered that the metrics_simple example does the same.

I’m using a PeriodicExportingMetricReader. An lldb run confirms that PeriodicExportingMetricReader::OnShutDown is being called, but the log message is emitted during the join() call there on the thread. A backtrace shows that OnShutDown is called from MetricReader::Shutdown(), but that doesn’t happen until after MetricReader::shutdown_ is already set to true. If PeriodicExportingMetricReader::OnShutDown does one more call to Collect during the join (which I wouldn’t be surprised if it does), then it’s going to always output that error.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions