lambda_otel_lite/
constants.rs

1//! Constants for the lambda-otel-lite package.
2//!
3//! This file centralizes all constants to ensure consistency across the codebase
4//! and provide a single source of truth for configuration parameters.
5
6/// Environment variable names for configuration.
7pub mod env_vars {
8    /// Mode for the Lambda Extension span processor (sync or async).
9    pub const PROCESSOR_MODE: &str = "LAMBDA_EXTENSION_SPAN_PROCESSOR_MODE";
10
11    /// Maximum queue size for LambdaSpanProcessor.
12    pub const QUEUE_SIZE: &str = "LAMBDA_SPAN_PROCESSOR_QUEUE_SIZE";
13
14    /// Compression level for OTLP stdout span exporter.
15    pub const COMPRESSION_LEVEL: &str = "OTLP_STDOUT_SPAN_EXPORTER_COMPRESSION_LEVEL";
16
17    /// Service name for telemetry.
18    pub const SERVICE_NAME: &str = "OTEL_SERVICE_NAME";
19
20    /// Resource attributes in KEY=VALUE,KEY2=VALUE2 format.
21    pub const RESOURCE_ATTRIBUTES: &str = "OTEL_RESOURCE_ATTRIBUTES";
22
23    /// AWS Lambda function name (used as fallback service name).
24    pub const AWS_LAMBDA_FUNCTION_NAME: &str = "AWS_LAMBDA_FUNCTION_NAME";
25
26    /// Comma-separated list of context propagators to use.
27    /// Valid values: tracecontext, xray, xray-lambda, none
28    pub const PROPAGATORS: &str = "OTEL_PROPAGATORS";
29
30    /// Controls whether to enable the fmt layer for logging regardless of code settings.
31    /// Set to "true" to force enable logging output.
32    pub const ENABLE_FMT_LAYER: &str = "LAMBDA_TRACING_ENABLE_FMT_LAYER";
33}
34
35/// Default values for configuration parameters.
36pub mod defaults {
37    /// Default maximum queue size for LambdaSpanProcessor.
38    pub const QUEUE_SIZE: usize = 2048;
39
40    /// Default compression level for OTLP stdout span exporter.
41    pub const COMPRESSION_LEVEL: u8 = 6;
42
43    /// Default service name if not provided.
44    pub const SERVICE_NAME: &str = "unknown_service";
45
46    /// Default processor mode.
47    pub const PROCESSOR_MODE: &str = "sync";
48
49    /// Default value for enabling fmt layer from environment.
50    pub const ENABLE_FMT_LAYER: bool = false;
51
52    /// Default minimum event level.
53    pub const EVENT_LEVEL: &str = "info";
54}
55
56/// Resource attribute keys used in the Lambda resource.
57pub mod resource_attributes {
58    /// Resource attribute key for processor mode.
59    pub const PROCESSOR_MODE: &str = "lambda_otel_lite.extension.span_processor_mode";
60
61    /// Resource attribute key for queue size.
62    pub const QUEUE_SIZE: &str = "lambda_otel_lite.lambda_span_processor.queue_size";
63
64    /// Resource attribute key for compression level.
65    pub const COMPRESSION_LEVEL: &str =
66        "lambda_otel_lite.otlp_stdout_span_exporter.compression_level";
67}