Use it to configure instrumentation consistently across services.
OpenTelemetry SDK Configuration
OpenTelemetry SDK configuration sets the resource (service.name, version, environment), exporters, propagators, samplers and batch settings — usually via OTEL_* environment variables.
1. Environment: env | grep ^OTEL_ in the container.
2. service.name set.
3. Endpoint and protocol (grpc 4317 / http 4318).
4. Sampler configured.
5. Data visible with correct resource.
env/config → SDK provider → processors → exporter → Collector
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 How to verify Verify boundary
Find the service by name in the tracing backend. Confirm resource attributes appear on spans and metrics.
Step 2 Common failures Narrow the fault
Sending http/protobuf to the gRPC port fails silently in some SDKs. A missing service name shows as unknown_service. Exporting directly to a remote backend from every Pod multiplies connections; use a collector.
Set OTEL_SERVICE_NAME and OTEL_RESOURCE_ATTRIBUTES everywhere. Point OTEL_EXPORTER_OTLP_ENDPOINT to the local Collector. Use the batch processor in production.
env | grep ^OTEL_— first check for this topiccurl -s localhost:9090/-/ready— Prometheus readycurl -s 'localhost:9090/api/v1/query?query=up'— scrape targets up/downpromtool check config prometheus.yml— config valid
ReferenceWhat it is1 section · depth on demand
How it works
Auto-instrumentation agents (Java, .NET, Python, Node.js) read the same variables. The SDK batches telemetry and exports it periodically; failed exports are retried with backoff.
ReferenceImportant terms & boundaries3 sections · depth on demand
Common environment variables
| Variable | Example |
|---|---|
OTEL_SERVICE_NAME | checkout |
OTEL_RESOURCE_ATTRIBUTES | deployment.environment=prod,service.version=1.4.2 |
OTEL_EXPORTER_OTLP_ENDPOINT | http://otel-collector:4318 |
OTEL_EXPORTER_OTLP_PROTOCOL | http/protobuf or grpc |
OTEL_TRACES_SAMPLER / _ARG | parentbased_traceidratio / 0.1 |
OTEL_LOGS_EXPORTER, OTEL_METRICS_EXPORTER | otlp or none |
Always set service.name; without it data shows as unknown_service.
In depth
A complete minimal configuration
OTEL_SERVICE_NAME=checkout
OTEL_RESOURCE_ATTRIBUTES=deployment.environment.name=prod,service.version=1.42.0,service.namespace=shop
OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4318
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
OTEL_TRACES_SAMPLER=parentbased_traceidratio
OTEL_TRACES_SAMPLER_ARG=0.2
OTEL_PROPAGATORS=tracecontext,baggage
OTEL_METRICS_EXPORTER=otlp
OTEL_LOGS_EXPORTER=otlp
Endpoint rules that cause most "no data" problems
| Setting | Behaviour |
|---|---|
OTEL_EXPORTER_OTLP_ENDPOINT with http/protobuf | Base URL; the SDK appends /v1/traces, /v1/metrics, /v1/logs |
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT | Used as is — include /v1/traces yourself |
Protocol grpc | Port 4317, no path |
Protocol http/protobuf | Port 4318 |
The default protocol differs between language SDKs; set it explicitly.
Resource attributes
service.name is the one that matters most; without it everything appears as unknown_service:<process>. Add service.version and deployment.environment.name so dashboards and traces can be split by version and environment. In Kubernetes, the collector's k8sattributes processor can add pod, namespace and node attributes so the application does not have to.
Checking what the SDK does
Set OTEL_TRACES_EXPORTER=console (or otlp,console in SDKs that support lists) temporarily to print spans locally, and enable the SDK's own debug logging (for example OTEL_LOG_LEVEL=debug where supported) to see export errors that are otherwise swallowed.
Common mistakes
- Misconfigured service name/resource attributes.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.