pub struct TelemetryConfig {
pub enable_fmt_layer: bool,
pub set_global_provider: bool,
pub resource: Option<Resource>,
pub env_var_name: Option<String>,
pub processor_mode: Option<ProcessorMode>,
/* private fields */
}Expand description
Configuration for OpenTelemetry initialization.
Provides configuration options for telemetry setup. Use TelemetryConfig::default()
for standard Lambda configuration, or the builder pattern for customization.
§Fields
enable_fmt_layer- Enable console output for debugging (default: false)set_global_provider- Set as global tracer provider (default: true)resource- Custom resource attributes (default: auto-detected from Lambda)env_var_name- Environment variable name for log level configurationid_generator- Custom ID generator for trace and span IDsprocessor_mode- Span processing mode (sync/async/finalize)
§Examples
Basic usage with default configuration:
use lambda_otel_lite::telemetry::TelemetryConfig;
let config = TelemetryConfig::default();Custom configuration with resource attributes:
use lambda_otel_lite::telemetry::TelemetryConfig;
use opentelemetry::KeyValue;
use opentelemetry_sdk::Resource;
let config = TelemetryConfig::builder()
.resource(Resource::builder()
.with_attributes(vec![KeyValue::new("version", "1.0.0")])
.build())
.build();Custom configuration with logging options:
use lambda_otel_lite::telemetry::TelemetryConfig;
let config = TelemetryConfig::builder()
.enable_fmt_layer(true) // Enable console output for debugging
.env_var_name("MY_CUSTOM_LOG_LEVEL".to_string()) // Custom env var for log level
.build();Fields§
§enable_fmt_layer: boolEnable console output for debugging.
When enabled, spans and events will be printed to the console in addition to being exported through the configured span processors. This is useful for debugging but adds overhead and should be disabled in production.
This can also be controlled via the LAMBDA_TRACING_ENABLE_FMT_LAYER environment variable,
which takes precedence over this setting when present:
- Setting the env var to “true” will enable console output even if this field is false
- Setting the env var to “false” will disable console output even if this field is true
- Invalid values will log a warning and fall back to this code setting
This environment variable override allows toggling logging for debugging without code changes.
Default: false
set_global_provider: boolSet this provider as the global OpenTelemetry provider.
When enabled, the provider will be registered as the global provider for the OpenTelemetry API. This allows using the global tracer API without explicitly passing around the provider.
Default: true
resource: Option<Resource>Custom resource attributes for all spans.
If not provided, resource attributes will be automatically detected from the Lambda environment. Custom resources will override any automatically detected attributes with the same keys.
Default: None (auto-detected from Lambda environment)
env_var_name: Option<String>Environment variable name to use for log level configuration.
This field specifies which environment variable should be used to configure
the tracing subscriber’s log level filter. If not specified, the system will
first check for RUST_LOG and then fall back to AWS_LAMBDA_LOG_LEVEL.
Default: None (uses RUST_LOG or AWS_LAMBDA_LOG_LEVEL)
processor_mode: Option<ProcessorMode>Span processing mode (sync/async/finalize)
Controls how spans are exported from the processor. This can be overridden by the LAMBDA_EXTENSION_SPAN_PROCESSOR_MODE environment variable, which takes precedence.
Default: None (uses environment variable or defaults to ProcessorMode::Sync)
Implementations§
Source§impl TelemetryConfig
impl TelemetryConfig
Sourcepub fn builder() -> TelemetryConfigBuilder
pub fn builder() -> TelemetryConfigBuilder
Create an instance of TelemetryConfig using the builder syntax
Trait Implementations§
Source§impl Debug for TelemetryConfig
impl Debug for TelemetryConfig
Auto Trait Implementations§
impl Freeze for TelemetryConfig
impl !RefUnwindSafe for TelemetryConfig
impl Send for TelemetryConfig
impl Sync for TelemetryConfig
impl Unpin for TelemetryConfig
impl !UnwindSafe for TelemetryConfig
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
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request