This is a complete, hands-on OpenTelemetry cheat sheet: install, configure, operate, automate and secure it - with copy-paste commands grouped by task. Bookmark it for day-to-day work, incidents and interviews alike.
OpenTelemetry (OTel) is a CNCF standard and SDK set for generating traces, metrics and logs, plus a Collector that receives, processes and exports them to any backend.
Why you reach for it
- Vendor-neutral instrumentation - swap backends without re-instrumenting
- One Collector pipeline for traces, metrics and logs
- Auto-instrumentation for many languages and frameworks
Installation
docker run -p 4317:4317 -p 4318:4318 \
-v $PWD/otel.yaml:/etc/otelcol/config.yaml otel/opentelemetry-collectorConfiguration reference
A Collector pipeline: receive OTLP, batch, export.
receivers:
otlp: { protocols: { grpc: {}, http: {} } }
processors:
batch: {}
exporters:
prometheus: { endpoint: 0.0.0.0:8889 }
otlphttp: { endpoint: https://tempo:4318 }
service:
pipelines:
traces: { receivers: [otlp], processors: [batch], exporters: [otlphttp] }
metrics: { receivers: [otlp], processors: [batch], exporters: [prometheus] }Core commands you use daily
Auto-instrument a Python app with zero code changes.
pip install opentelemetry-distro opentelemetry-exporter-otlp
opentelemetry-bootstrap -a install
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317 \
opentelemetry-instrument python app.pyEnvironment variables
export OTEL_EXPORTER_OTLP_ENDPOINT=http://collector:4317
export OTEL_SERVICE_NAME=checkout
export OTEL_TRACES_SAMPLER=parentbased_traceidratio
export OTEL_TRACES_SAMPLER_ARG=0.1Collector & auto-instrumentation
otelcol validate --config otel.yaml
# Python auto-instrumentation:
opentelemetry-instrument python app.py
# Node:
node --require @opentelemetry/auto-instrumentations-node/register app.jsUse it in CI/CD
Validate Collector config in CI.
- run: otelcol validate --config otel.yamlBest-practice checklist
- Send everything to a Collector, then fan out to backends
- Use tail-based sampling for traces to keep the interesting ones
- Propagate context across services with W3C tracecontext
Common pitfalls to avoid
- Sampling misconfigured, so you keep everything and blow up cost
- Mixing SDK versions and losing context propagation
- Exporting directly from apps instead of through a Collector
Security quick wins
- Terminate and authenticate OTLP; don't expose the Collector openly
- Strip PII in processors before export
Works well with
- Prometheus - The de-facto standard for metrics - a pull-based time-series database with a powerful query language.
- Grafana - The open dashboarding layer for metrics, logs and traces, with alerting across many data sources.
- datadog
A cheat sheet is muscle memory on paper - keep it close until the commands live in your fingers.
Want senior help putting OpenTelemetry to work - or a team bootcamp on it? CodeWizard runs Israel's largest DevOps community and embeds named senior engineers with a transparent hours log. Book a free consult or explore the Academy.