pub struct MonocleConfig {
pub api_key: Option<String>,
pub endpoint: String,
pub environment: String,
pub service_name: String,
pub service_version: String,
pub log_filter: String,
pub extra_resource_attributes: Vec<KeyValue>,
}Expand description
Configuration for the Monocle telemetry exporter.
Build it from the environment with MonocleConfig::from_env (the usual
path) and tweak it with the with_* builder methods. Export stays off
until an API key is present (MonocleConfig::is_enabled).
let cfg = monocle_agent::MonocleConfig::from_env(
env!("CARGO_PKG_NAME"),
env!("CARGO_PKG_VERSION"),
)
.with_environment("staging");Fields§
§api_key: Option<String>Monocle API key. None disables all OTLP export (stdout logging only).
endpoint: StringOTLP/HTTP base endpoint. Per-signal paths (/v1/traces, …) are appended internally.
environment: StringDeployment environment (development | staging | production).
service_name: Stringservice.name resource attribute.
service_version: Stringservice.version resource attribute.
log_filter: StringFallback tracing filter used when RUST_LOG is unset (e.g. "my_svc=debug,info").
extra_resource_attributes: Vec<KeyValue>Extra OpenTelemetry resource attributes, merged on top of the defaults.
Implementations§
Source§impl MonocleConfig
impl MonocleConfig
Sourcepub fn from_env(
service_name: impl Into<String>,
service_version: impl Into<String>,
) -> Self
pub fn from_env( service_name: impl Into<String>, service_version: impl Into<String>, ) -> Self
Resolve configuration from environment variables.
service_name / service_version are the fallbacks used when the
matching env vars are unset — pass env!("CARGO_PKG_NAME") and
env!("CARGO_PKG_VERSION") so they resolve to your crate (the env!
macro must expand in the calling crate, not in this library).
| Env var | Field | Default |
|---|---|---|
MONOCLE_API_KEY | api_key | None (export disabled) |
MONOCLE_ENDPOINT | endpoint | https://ingest.monocle.sh |
MONOCLE_ENV | environment | production |
OTEL_SERVICE_NAME | service_name | service_name arg |
MONOCLE_SERVICE_VERSION | service_version | service_version arg |
Sourcepub fn with_api_key(self, key: impl Into<String>) -> Self
pub fn with_api_key(self, key: impl Into<String>) -> Self
Override the API key (and thereby enable export).
Sourcepub fn with_endpoint(self, endpoint: impl Into<String>) -> Self
pub fn with_endpoint(self, endpoint: impl Into<String>) -> Self
Override the OTLP/HTTP base endpoint.
Sourcepub fn with_environment(self, environment: impl Into<String>) -> Self
pub fn with_environment(self, environment: impl Into<String>) -> Self
Override the deployment environment.
Sourcepub fn with_log_filter(self, filter: impl Into<String>) -> Self
pub fn with_log_filter(self, filter: impl Into<String>) -> Self
Override the fallback tracing filter (used only when RUST_LOG is unset).
Sourcepub fn with_resource_attribute(
self,
key: impl Into<Key>,
value: impl Into<Value>,
) -> Self
pub fn with_resource_attribute( self, key: impl Into<Key>, value: impl Into<Value>, ) -> Self
Append an extra OpenTelemetry resource attribute.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Whether OTLP export is enabled (i.e. an API key is present).
Trait Implementations§
Source§impl Clone for MonocleConfig
impl Clone for MonocleConfig
Source§fn clone(&self) -> MonocleConfig
fn clone(&self) -> MonocleConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more