Pcornel
Browse topics
Options
Recent
Favorites
Observability · Technical reference

OpenTelemetry SDK Configuration

Direct answer

OpenTelemetry SDK configuration sets the resource (service.name, version, environment), exporters, propagators, samplers and batch settings — usually via OTEL_* environment variables.

When to use this

Use it to configure instrumentation consistently across services.

First 30 seconds

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.

Operational verification

env/config → SDK provider → processors → exporter → Collector

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
OpenTelemetry / Prometheus / Grafana / common metrics-log-trace pipelines
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformOpenTelemetry / Prometheus / Grafana / common metrics-log-trace pipelines
Scope / prerequisiteUse it to configure instrumentation consistently across services.
What next?2 suggested next steps
Evidence0
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

2 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

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.

Key points

Set OTEL_SERVICE_NAME and OTEL_RESOURCE_ATTRIBUTES everywhere. Point OTEL_EXPORTER_OTLP_ENDPOINT to the local Collector. Use the batch processor in production.

Key checks
  • env | grep ^OTEL_ — first check for this topic
  • curl -s localhost:9090/-/ready — Prometheus ready
  • curl -s 'localhost:9090/api/v1/query?query=up' — scrape targets up/down
  • promtool 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

VariableExample
OTEL_SERVICE_NAMEcheckout
OTEL_RESOURCE_ATTRIBUTESdeployment.environment=prod,service.version=1.4.2
OTEL_EXPORTER_OTLP_ENDPOINThttp://otel-collector:4318
OTEL_EXPORTER_OTLP_PROTOCOLhttp/protobuf or grpc
OTEL_TRACES_SAMPLER / _ARGparentbased_traceidratio / 0.1
OTEL_LOGS_EXPORTER, OTEL_METRICS_EXPORTERotlp 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

SettingBehaviour
OTEL_EXPORTER_OTLP_ENDPOINT with http/protobufBase URL; the SDK appends /v1/traces, /v1/metrics, /v1/logs
OTEL_EXPORTER_OTLP_TRACES_ENDPOINTUsed as is — include /v1/traces yourself
Protocol grpcPort 4317, no path
Protocol http/protobufPort 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.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

Common mistakes

  • Misconfigured service name/resource attributes.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Terminology layer

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.

Aliases that resolve here
opentelemetry sdk configurationopentelemetry environment variablesotlp exporter
Confirmation

Confirm action

Continue?