SDK Variables
OpenTelemetry SDK behavior is controlled through environment variables that configure various aspects of telemetry collection, processing, and export. The Instrumentation custom resource allows you to set these variables to customize how your instrumented applications generate and send telemetry data.
TOC
Common SDK Environment VariablesService IdentificationExporter ConfigurationOTLP Endpoint ConfigurationProtocol ConfigurationConfiguring SDK Variables in Instrumentation CRSampling ConfigurationPropagation ConfigurationBatch Processing ConfigurationLogging ConfigurationVariable PrecedenceCommon SDK Environment Variables
The following environment variables are commonly used to configure OpenTelemetry SDK behavior:
Service Identification
OTEL_SERVICE_NAME- Defines the logical name of the serviceOTEL_RESOURCE_ATTRIBUTES- Specifies additional resource attributes as key-value pairs
Exporter Configuration
OTEL_TRACES_EXPORTER- Configures the trace exporter (e.g.,otlp,jaeger,zipkin)OTEL_METRICS_EXPORTER- Configures the metrics exporter (e.g.,otlp,prometheus)OTEL_LOGS_EXPORTER- Configures the logs exporter (e.g.,otlp)
OTLP Endpoint Configuration
OTEL_EXPORTER_OTLP_ENDPOINT- Sets the OTLP endpoint for all signalsOTEL_EXPORTER_OTLP_TRACES_ENDPOINT- Sets the OTLP endpoint specifically for tracesOTEL_EXPORTER_OTLP_METRICS_ENDPOINT- Sets the OTLP endpoint specifically for metricsOTEL_EXPORTER_OTLP_LOGS_ENDPOINT- Sets the OTLP endpoint specifically for logs
Protocol Configuration
OTEL_EXPORTER_OTLP_PROTOCOL- Specifies the OTLP protocol (grpcorhttp/protobuf)OTEL_EXPORTER_OTLP_TRACES_PROTOCOL- Protocol for tracesOTEL_EXPORTER_OTLP_METRICS_PROTOCOL- Protocol for metrics
Configuring SDK Variables in Instrumentation CR
You can set SDK environment variables in the Instrumentation custom resource:
These variables are automatically injected into instrumented application containers.
Sampling Configuration
Control trace sampling behavior with these variables:
OTEL_TRACES_SAMPLER- Sampling strategy (e.g.,always_on,always_off,traceidratio,parentbased_always_on)OTEL_TRACES_SAMPLER_ARG- Argument for the sampler (e.g., sampling ratio fortraceidratio)
Example configuration:
This configuration samples 10% of traces while respecting parent span sampling decisions.
Propagation Configuration
Configure context propagation formats:
OTEL_PROPAGATORS- Comma-separated list of propagators (e.g.,tracecontext,baggage,b3)
Example:
Batch Processing Configuration
Control how telemetry data is batched before export:
OTEL_BSP_SCHEDULE_DELAY- Delay interval between batch exports (milliseconds)OTEL_BSP_EXPORT_TIMEOUT- Maximum time to wait for export (milliseconds)OTEL_BSP_MAX_QUEUE_SIZE- Maximum queue size for batchingOTEL_BSP_MAX_EXPORT_BATCH_SIZE- Maximum batch size for export
Logging Configuration
Configure SDK logging behavior:
OTEL_LOG_LEVEL- SDK log level (e.g.,debug,info,warn,error)
SDK environment variables follow the OpenTelemetry specification. For a complete list of available variables and their descriptions, refer to the OpenTelemetry Environment Variable Specification.
Variable Precedence
When the same variable is defined in multiple places, the following precedence order applies (highest to lowest):
- Environment variables defined directly in the pod specification
- Environment variables from the Instrumentation CR
- Default values from the instrumentation library
Use the Instrumentation CR to define common configuration across multiple applications, and override specific values in individual pod specifications when needed.