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

feat: Add shutdown with timeout for metric exporter #2854

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

mohammadVatandoost
Copy link
Contributor

#2574 Part 1: Adding shutdown_with_timeout for metric exporter

@mohammadVatandoost mohammadVatandoost requested a review from a team as a code owner March 23, 2025 17:07
Copy link

codecov bot commented Mar 23, 2025

Codecov Report

Attention: Patch coverage is 16.66667% with 15 lines in your changes missing coverage. Please review.

Project coverage is 81.0%. Comparing base (99cb67d) to head (25156f0).

Files with missing lines Patch % Lines
opentelemetry-otlp/src/metric.rs 0.0% 3 Missing ⚠️
opentelemetry-sdk/src/metrics/exporter.rs 0.0% 3 Missing ⚠️
...pentelemetry-sdk/src/metrics/in_memory_exporter.rs 0.0% 3 Missing ⚠️
opentelemetry-sdk/src/metrics/periodic_reader.rs 50.0% 3 Missing ⚠️
opentelemetry-stdout/src/metrics/exporter.rs 0.0% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main   #2854     +/-   ##
=======================================
- Coverage   81.1%   81.0%   -0.1%     
=======================================
  Files        124     125      +1     
  Lines      23927   23945     +18     
=======================================
- Hits       19410   19409      -1     
- Misses      4517    4536     +19     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@@ -163,6 +164,10 @@ impl PushMetricExporter for MetricExporter {
}

fn shutdown(&self) -> OTelSdkResult {
self.shutdown_with_timeout(Duration::from_secs(5))
Copy link
Contributor

@TommyCpp TommyCpp Mar 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it from spec? If so please link the document here nvm I think we have it already, maybe worth following up to see if the value is reasonable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 5 second is used in other functions as default timeout. like:

forceflush_timeout: Duration::from_secs(5), // TODO: make this configurable

I don't know why we choose 5 seconds. As it is written in ToDo, I think we need to read it from configuration.
I think this is not related to issue of the PR. we can work on it at another PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no spec on what should be the default, so 5 seconds is our invention. We should recommend users to use the shutdown_with_timeout passing a Duration of their choice, but we also do shutdown() from Drop, where we need to pick some default. 5 secs seems reasonable to me as a default.

@@ -26,6 +28,9 @@ pub trait PushMetricExporter: Send + Sync + 'static {
///
/// After Shutdown is called, calls to Export will perform no operation and
/// instead will return an error indicating the shutdown state.
fn shutdown_with_timeout(&self, timeout: Duration) -> OTelSdkResult;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now that we have both, lets give a default implementation for the shutdown(), invoking the new one passing 5 seconds.

Also please update changelog to reflect this - this is breaking change for custom MetricExporter author.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

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

Successfully merging this pull request may close these issues.

4 participants