Skip to content

[Bug]: Global metrics provider gets shutdown when local provider is dropped #1661

@bwalk-at-ibm

Description

@bwalk-at-ibm

What happened?

#1623 introduced Drop implementation for SdkMeterProvider for proper shutdown semantics. This however introduced a bug with the preferred usage pattern like it is demonstrated in the demo.

Here's what I assume happens: when building the metrics provider we register a copy of the provider as the global metrics provider. The SdkMeterProvider holds references to the underlying data like the pipelines in an Arc, so this behaviour is all good. However, when any provider (like the original provider) is dropped (like it happens in the example code and which seems to be the expected pattern because it is encouraged to use the global metrics provider) and since Drop is implemented on the SdkMeterProvider will call shutdown() which will terminate the associated pipelines which are shared with the registered global metrics provider. Hence, we see no metrics and get an error when the global metrics provider gets dropped at application end.

API Version

0.22

SDK Version

0.22.1

What Exporters are you seeing the problem on?

OTLP

Relevant log output

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingtriage:todoNeeds to be traiged.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions