Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shutting down a MeterProvider with a asynchronous instrument can take a long time #131

Open
duncanpo opened this issue Jun 28, 2024 · 0 comments

Comments

@duncanpo
Copy link
Member

Run the following code in a loop. Many iterations take only about 0.01 seconds to run but some can take a long time (~30 seconds).

function out = currentsecond()
% callback function for an observable gauge

dt = datetime("now");
s = second(dt);

out = opentelemetry.metrics.ObservableResult;
out = out.observe(s);
for i=1:10, 
   mp = opentelemetry.sdk.metrics.MeterProvider();  
   opentelemetry.metrics.Provider.setMeterProvider(mp);
   clear
   mp = opentelemetry.metrics.Provider.getMeterProvider();   
   m = getMeter(mp, "foo"); 
   g = createObservableGauge(m, @currentsecond, "bar");
   tic;   
   opentelemetry.sdk.common.Cleanup.shutdown(mp);   
   toc; 
end

In comparison, if the code is changed to create a synchronous instrument (e.g. counter) instead of an asynchronous one, then shutdown never takes a long time, always around 0.01 seconds.

This issue causes an asynchronous example test in test/texamples.m to be filtered out due to the time it takes to run the test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant