OpenTelemetry provides a unified standard for collecting traces, metrics, and logs from your applications. It is the future of observability and is supported by all major monitoring platforms.
Setting Up the OpenTelemetry Collector
# docker-compose.yml
version: "3.8"
services:
otel-collector:
image: otel/opentelemetry-collector-contrib:latest
command: ["--config=/etc/otel-collector-config.yaml"]
volumes:
- ./otel-collector-config.yaml:/etc/otel-collector-config.yaml
ports:
- "4317:4317" # OTLP gRPC
- "4318:4318" # OTLP HTTP
- "8888:8888" # Prometheus metrics
restart: unless-stopped
Collector Configuration
# otel-collector-config.yaml
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
http:
endpoint: 0.0.0.0:4318
processors:
batch:
timeout: 10s
exporters:
prometheus:
endpoint: "0.0.0.0:8888"
logging:
loglevel: info
service:
pipelines:
traces:
receivers: [otlp]
processors: [batch]
exporters: [logging]
metrics:
receivers: [otlp]
processors: [batch]
exporters: [prometheus]
Instrumenting Applications
Most languages have OpenTelemetry SDKs that provide automatic instrumentation for popular frameworks. For Python, Node.js, Java, and Go, you can often add observability with minimal code changes.
Summary
OpenTelemetry standardizes observability data collection, making it easy to switch between monitoring backends and correlate traces, metrics, and logs across your entire infrastructure.