-
Notifications
You must be signed in to change notification settings - Fork 821
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
OTLPMetricExporter forceFlush() doesn't flush metrics #5116
Comments
Hi @douglasg14b, thanks for reaching out. 🙂 I vaguely remember that there was some contention on this back in the day when we implemented this because it was not part of the spec, and we ended up with a The spec issue for this is still open: open-telemetry/opentelemetry-specification#2983 I'm sure I completely understand the setup code from issue description - are you saying that |
Hi, thanks for the response. Correct, none of the above code actually flushes any metrics for me. The only way I can get metrics out of a process before it exits is to wait for at least the export interval. const collectResult = await metricsReader.collect();
const metrics = collectResult.resourceMetrics; // <---- metrics exist here
exporter.export(metrics, (result) => { // <--- No metrics are exported to the receiver
console.log(result); // {code: 0 }
});
await exporter.forceFlush(); // <--- No metrics are exported to the receiver
await metricsReader.forceFlush(); // <--- No metrics are exported to the receiver |
Ah, I think I see what's wrong now - I believe that there's a bug in the opentelemetry-js/packages/sdk-metrics/src/export/PeriodicExportingMetricReader.ts Lines 139 to 149 in 72c9af9
If async attributes are pending, the promise is not awaited by and |
What happened?
Steps to Reproduce
exportIntervalMillis
Expected Result
Metrics are flushed and exported
Actual Result
No metrics are exported at all
Additional Details
If I setup a very short
exportIntervalMillis
like500ms
and ensure the process waits a second or two before exiting I get metrics. This isn't a tenable solution though since we need to be able to force this flush for quickly running scripts.OpenTelemetry Setup Code
package.json
Relevant log output
No response
The text was updated successfully, but these errors were encountered: