-
Notifications
You must be signed in to change notification settings - Fork 431
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
Avoid redundant shutdown in TracerProvider::drop when already shut down #2197
base: main
Are you sure you want to change the base?
Avoid redundant shutdown in TracerProvider::drop when already shut down #2197
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2197 +/- ##
=======================================
+ Coverage 79.0% 79.2% +0.2%
=======================================
Files 122 122
Lines 21059 21068 +9
=======================================
+ Hits 16651 16705 +54
+ Misses 4408 4363 -45 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets make it similar to #2195
…TracerProviderInner::Shutdown
…tb/opentelemetry-rust into tracer-provider-drop-shutdown-check
Done. |
drop(provider3); | ||
|
||
// Verify shutdown was called exactly once | ||
assert!(assert_handle.0.is_shutdown.load(Ordering::SeqCst)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this verify that shutdown was called only once? It looks like it's only verifying that shutdown was called (could have been called once or multiple times)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I think I should be using CountingShutdownProcessor which was added in #2195.
// Drop providers without explicit shutdown | ||
drop(provider); | ||
drop(provider2); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should verify that shutdown was not called by asserting that assert_handle.0.is_shutdown
is still false
.
opentelemetry/src/trace/mod.rs
Outdated
@@ -200,6 +200,10 @@ pub enum TraceError { | |||
#[error("Exporting timed out after {} seconds", .0.as_secs())] | |||
ExportTimedOut(time::Duration), | |||
|
|||
/// already shutdown error | |||
#[error("{0} already shutdown")] | |||
AlreadyShutdown(String), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we expect to use this variant for anything other than TracerProvider
?
Co-authored-by: Utkarsh Umesan Pillai <[email protected]>
Co-authored-by: Utkarsh Umesan Pillai <[email protected]>
/// users can call the [`force_flush`](TracerProvider::force_flush) method at any time to trigger | ||
/// an immediate flush of all pending spans for **batch processors** to the exporters. Note that | ||
/// calling [`force_flush`](TracerProvider::force_flush) is optional before shutdown, as `shutdown` | ||
/// will automatically trigger a flush for batch processors, but not for simple processors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// will automatically trigger a flush for batch processors, but not for simple processors. | |
/// will automatically trigger a flush for batch processors, but not for simple processors. |
Flush is triggered for all processors, irrespective of batch vs simple or something else. It is upto processor to decide if it is a no-op or not.
/// collecting, processing, and exporting spans. To ensure all spans are processed before shutdown, | ||
/// users can call the [`force_flush`](TracerProvider::force_flush) method at any time to trigger | ||
/// an immediate flush of all pending spans for **batch processors** to the exporters. Note that | ||
/// calling [`force_flush`](TracerProvider::force_flush) is optional before shutdown, as `shutdown` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if we mentioning "optional" for force_flush is a good idea.
/// // create spans... | ||
/// | ||
/// // Flush all spans before shutdown (optional for batch processors) | ||
/// for result in provider.force_flush() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why we need to show force_flush in here?
Changes
changes similar to #2195 for TracerProvider
Merge requirement checklist
CHANGELOG.md
files updated for non-trivial, user-facing changes