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 number of spans to queue in the LambdaSpanProcessor.
12    pub const QUEUE_SIZE: &str = "LAMBDA_SPAN_PROCESSOR_QUEUE_SIZE";
13
14    /// Maximum batch size for span export.
15    pub const BATCH_SIZE: &str = "LAMBDA_SPAN_PROCESSOR_BATCH_SIZE";
16
17    /// Compression level for OTLP stdout span exporter.
18    pub const COMPRESSION_LEVEL: &str = "OTLP_STDOUT_SPAN_EXPORTER_COMPRESSION_LEVEL";
19
20    /// Service name for telemetry.
21    pub const SERVICE_NAME: &str = "OTEL_SERVICE_NAME";
22
23    /// Resource attributes in KEY=VALUE,KEY2=VALUE2 format.
24    pub const RESOURCE_ATTRIBUTES: &str = "OTEL_RESOURCE_ATTRIBUTES";
25
26    /// AWS Lambda function name (used as fallback service name).
27    pub const AWS_LAMBDA_FUNCTION_NAME: &str = "AWS_LAMBDA_FUNCTION_NAME";
28
29    /// Comma-separated list of context propagators to use.
30    /// Valid values: tracecontext, xray, xray-lambda, none
31    pub const PROPAGATORS: &str = "OTEL_PROPAGATORS";
32
33    /// Controls whether to enable the fmt layer for logging regardless of code settings.
34    /// Set to "true" to force enable logging output.
35    pub const ENABLE_FMT_LAYER: &str = "LAMBDA_TRACING_ENABLE_FMT_LAYER";
36}
37
38/// Default values for configuration parameters.
39pub mod defaults {
40    /// Default maximum queue size for LambdaSpanProcessor.
41    pub const QUEUE_SIZE: usize = 2048;
42
43    /// Default maximum batch size for LambdaSpanProcessor.
44    pub const BATCH_SIZE: usize = 512;
45
46    /// Default compression level for OTLP stdout span exporter.
47    pub const COMPRESSION_LEVEL: u8 = 6;
48
49    /// Default service name if not provided.
50    pub const SERVICE_NAME: &str = "unknown_service";
51
52    /// Default processor mode.
53    pub const PROCESSOR_MODE: &str = "sync";
54
55    /// Default value for enabling fmt layer from environment.
56    pub const ENABLE_FMT_LAYER: bool = false;
57}
58
59/// Resource attribute keys used in the Lambda resource.
60pub mod resource_attributes {
61    /// Resource attribute key for processor mode.
62    pub const PROCESSOR_MODE: &str = "lambda_otel_lite.extension.span_processor_mode";
63
64    /// Resource attribute key for queue size.
65    pub const QUEUE_SIZE: &str = "lambda_otel_lite.lambda_span_processor.queue_size";
66
67    /// Resource attribute key for batch size.
68    pub const BATCH_SIZE: &str = "lambda_otel_lite.lambda_span_processor.batch_size";
69
70    /// Resource attribute key for compression level.
71    pub const COMPRESSION_LEVEL: &str =
72        "lambda_otel_lite.otlp_stdout_span_exporter.compression_level";
73}