-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
154 additions
and
144 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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 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 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 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 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 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 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 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 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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use anyhow::anyhow; | ||
use std::env; | ||
|
||
const OTLP_TRACING_ENV: &str = "MOVEMENT_OTLP"; | ||
|
||
/// Options for tracing configuration. | ||
#[derive(Debug, Default)] | ||
pub struct Config { | ||
/// URL of the OpenTelemetry collector endpoint using the OTLP gRPC protocol. | ||
/// If the value is `None`, telemetry is not exported. | ||
pub otlp_grpc_url: Option<String>, | ||
} | ||
|
||
impl Config { | ||
/// Get the tracing configuration from well-known environment variables. | ||
pub fn from_env() -> Result<Self, anyhow::Error> { | ||
let otlp_grpc_url = match env::var(OTLP_TRACING_ENV) { | ||
Ok(url) => Some(url), | ||
Err(env::VarError::NotPresent) => None, | ||
Err(env::VarError::NotUnicode(s)) => { | ||
return Err(anyhow!( | ||
"value of environment variable {OTLP_TRACING_ENV} is not valid UTF-8: {}", | ||
s.to_string_lossy() | ||
)); | ||
} | ||
}; | ||
Ok(Self { otlp_grpc_url }) | ||
} | ||
} |
This file contains 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,4 +1,13 @@ | ||
pub mod telemetry; | ||
//! Tracing setup for Movement services. | ||
//! | ||
//! Exporting of tracing data via [OpenTelemetry] is optionally supported | ||
//! by setting "movement_telemetry" as the target in tracing spans and events. | ||
//! | ||
//! [OpenTelemetry]: https://opentelemetry.io/ | ||
mod config; | ||
mod telemetry; | ||
mod tracing; | ||
|
||
pub use config::Config; | ||
pub use tracing::init_tracing_subscriber; |
Oops, something went wrong.