#[non_exhaustive]pub struct OtelConfig {
pub endpoint: Url,
pub level: Level,
pub timeout: Duration,
pub environment: String,
}Expand description
Otel configuration. This struct is intended to be loaded from the env vars
The env vars it checks are:
OTEL_EXPORTER_OTLP_ENDPOINT- optional. The endpoint to send traces to, should be some valid URL. If not specified, thenOtelConfig::loadwill returnNone.- OTEL_LEVEL - optional. Specifies the minimum
tracing::Levelto export. Defaults totracing::Level::DEBUG. - OTEL_TIMEOUT - optional. Specifies the timeout for the exporter in milliseconds. Defaults to 1000ms, which is equivalent to 1 second.
- OTEL_ENVIRONMENT_NAME - optional. Value for the
deployment.environment. nameresource key according to the OTEL conventions.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.endpoint: UrlThe endpoint to send traces to, should be some valid HTTP endpoint for OTLP.
level: LevelDefaults to DEBUG.
timeout: DurationDefaults to 1 second. Specified in Milliseconds.
environment: StringOTEL convenition deployment.environment.name
Implementations§
Source§impl OtelConfig
impl OtelConfig
Sourcepub fn load() -> Option<Self>
pub fn load() -> Option<Self>
Load from env vars.
The env vars it checks are:
OTEL_EXPORTER_OTLP_ENDPOINT- optional. The endpoint to send traces to. If missing or unparsable, this function will returnNone, and OTLP exporting will be disabled.OTEL_LEVEL- optional. Specifies the minimumtracing::Levelto export. Defaults totracing::Level::DEBUG.OTEL_TIMEOUT- optional. Specifies the timeout for the exporter in milliseconds. Defaults to 1000ms, which is equivalent to 1 second.OTEL_ENVIRONMENT_NAME- optional. Value for thedeployment.environment.nameresource key according to the OTEL conventions. Defaults to"unknown".
Trait Implementations§
Source§impl Clone for OtelConfig
impl Clone for OtelConfig
Source§fn clone(&self) -> OtelConfig
fn clone(&self) -> OtelConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for OtelConfig
impl Debug for OtelConfig
Source§impl FromEnv for OtelConfig
impl FromEnv for OtelConfig
Source§type Error = ParseError
type Error = ParseError
Error type produced when loading from the environment.
Source§fn inventory() -> Vec<&'static EnvItemInfo>
fn inventory() -> Vec<&'static EnvItemInfo>
Get the required environment variable names for this type. Read more
Source§fn check_inventory() -> Result<(), Vec<&'static EnvItemInfo>>
fn check_inventory() -> Result<(), Vec<&'static EnvItemInfo>>
Get a list of missing environment variables. Read more
Auto Trait Implementations§
impl Freeze for OtelConfig
impl RefUnwindSafe for OtelConfig
impl Send for OtelConfig
impl Sync for OtelConfig
impl Unpin for OtelConfig
impl UnwindSafe for OtelConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more