-
Notifications
You must be signed in to change notification settings - Fork 524
Use dedicated ShutdownResult for Metric SDK shutdown #2573
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
Merged
cijothomas
merged 9 commits into
open-telemetry:main
from
cijothomas:cijothomas/metric-shutdown
Jan 31, 2025
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
0a0d9ee
Use dedicated ShutdownResult for Metric SDK shutdown
cijothomas 8a4230c
revert ff change
cijothomas 2f8756e
demo some shutdown code
cijothomas 2f074dd
rename to InternalFailure
cijothomas ad94202
fmt
cijothomas 32035cb
doc comment
cijothomas 58d5e8e
Merge branch 'main' into cijothomas/metric-shutdown
cijothomas cf86974
nits
cijothomas 8ab63bf
Merge branch 'main' into cijothomas/metric-shutdown
cijothomas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,45 @@ | ||
//! Wrapper for error from trace, logs and metrics part of open telemetry. | ||
|
||
use std::{result::Result, time::Duration}; | ||
|
||
use thiserror::Error; | ||
|
||
/// Trait for errors returned by exporters | ||
pub trait ExportError: std::error::Error + Send + Sync + 'static { | ||
/// The name of exporter that returned this error | ||
fn exporter_name(&self) -> &'static str; | ||
} | ||
|
||
#[derive(Error, Debug)] | ||
/// Errors that can occur during shutdown. | ||
pub enum ShutdownError { | ||
/// Shutdown has already been invoked. | ||
/// | ||
/// While shutdown is idempotent and calling it multiple times has no | ||
/// impact, this error suggests that another part of the application is | ||
/// invoking `shutdown` earlier than intended. Users should review their | ||
/// code to identify unintended or duplicate shutdown calls and ensure it is | ||
/// only triggered once at the correct place. | ||
#[error("Shutdown already invoked")] | ||
AlreadyShutdown, | ||
|
||
/// Shutdown timed out before completing. | ||
/// | ||
/// This does not necessarily indicate a failure—shutdown may still be | ||
/// complete. If this occurs frequently, consider increasing the timeout | ||
/// duration to allow more time for completion. | ||
#[error("Shutdown timed out after {0:?}")] | ||
Timeout(Duration), | ||
|
||
/// Shutdown failed due to an internal error. | ||
/// | ||
/// The error message is intended for logging purposes only and should not | ||
/// be used to make programmatic decisions. It is implementation-specific | ||
/// and subject to change without notice. Consumers of this error should not | ||
/// rely on its content beyond logging. | ||
#[error("Shutdown failed: {0}")] | ||
InternalFailure(String), | ||
} | ||
|
||
/// A specialized `Result` type for Shutdown operations. | ||
pub type ShutdownResult = Result<(), ShutdownError>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.