Observing traces, metrics and logs via OpenTelemetry
Β· 3 min read
As I remember OpenTelemetry is the second largest project in CNCF (cloud native computing foundation) after kubernate. When developing a good application, it is very useful to apply it to observe the application performance by analyzing telemetry data: trace, metric and log.
OpenTelemetry is currently made up of several main components:
- OpenTelemetry API/SDK in application
- Zero-code Instrumentation
- target library should expose lifecycle hooks
- opentelemetry implement a plugin that leverage those hooks
- Manual-code Instrumentation
- Export Telemetry Data
- gRPC
- HTTP/protobuf
- Zero-code Instrumentation
- Opentelemetry Collector
- Opentelemetry Backend
- Exports traces β Grafana Tempo
- Exports metrics β Prometheus
- Exports logs β Loki / Fluentd / Elastic
- Telemetry Data Visualization
The OpenTelemetry Collector is designed to be a central hub that can:
- Receive traces, metrics, and logs (often via OTLP),
- Process or enrich them,
- Then export each type to the appropriate backend:
Your App (with OpenTelemetry SDKs)
βββ Exports all telemetry via OTLP (Traces, Metrics, Logs)
βββ OpenTelemetry Collector
βββ Exports traces β Grafana Tempo / Jaeger / Elastic APM, etc.
βββ Exports metrics β Prometheus (remote write) / Graphite / Google Cloud Monitoring, etc.
βββ Exports logs β Loki / Fluentd / Elastic, etc.
OpenTelemetry + Grafana Observability Stack (Best Practice for Small-Medium Apps)β
β What You Can Doβ
You can use OpenTelemetry SDKs in your app to collect:
- Traces
- Metrics
- Logs
And export them to the OpenTelemetry Collector, which routes each to the appropriate backend:
- Traces β Tempo
- Metrics β Prometheus
- Logs β Loki
Everything can be visualized in Grafana.
π Replacement Summaryβ
| Replace This | With This |
|---|---|
| Prometheus Client API | OpenTelemetry Metrics API |
| Promtail (log scraper) | OpenTelemetry Logs SDK or Exporter |
| Hardcoded backend exporters in app | OTLP exporter to OTel Collector |
π¦ Collector Pipeline Example (YAML)β
receivers:
otlp:
protocols:
grpc:
http:
exporters:
tempo:
endpoint: "tempo:4317"
tls:
insecure: true
prometheusremotewrite:
endpoint: "http://prometheus:9090/api/v1/write"
loki:
endpoint: "http://loki:3100/loki/api/v1/push"
service:
pipelines:
traces:
receivers: [otlp]
exporters: [tempo]
metrics:
receivers: [otlp]
exporters: [prometheusremotewrite]
logs:
receivers: [otlp]
exporters: [loki]
π Best Practice Stackβ
| Signal Type | OTel SDK in App | OTel Collector Backend | Grafana Visualization |
|---|---|---|---|
| Traces | OTel Tracing API | Tempo | Traces tab |
| Metrics | OTel Metrics API | Prometheus | Dashboards |
| Logs | OTel Logs API | Loki | Explore tab |
β Benefitsβ
- Unified instrumentation for all telemetry signals.
- Vendor-neutral, backend-agnostic design.
- Centralized routing and processing in OTel Collector.
- Grafana-native support for Tempo, Prometheus, and Loki.
- Easy backend switching with no app code changes.
β οΈ Considerationsβ
| Concern | Detail |
|---|---|
| Prometheus is pull-based | Use Remote Write exporter if you're pushing metrics. |
| Promtail features | OTel logs don't automatically add Kubernetes metadata like Promtail. You must enrich logs manually. |
| Sampling & performance | Enable sampling, batching, retry processors in production. |
| OTel logs SDK maturity | Logs support varies by language, but improving rapidly. |
β Final Verdictβ
This modern observability stack is production-worthy for small and medium applications:
- β One SDK for all telemetry
- β Grafana-native ecosystem
- β Flexible, scalable, backend-agnostic
