Skip to main content

Observing traces, metrics and logs via OpenTelemetry

Β· 3 min read
Frank Chen
Backend & Applied ML Engineer

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:

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 ThisWith This
Prometheus Client APIOpenTelemetry Metrics API
Promtail (log scraper)OpenTelemetry Logs SDK or Exporter
Hardcoded backend exporters in appOTLP 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 TypeOTel SDK in AppOTel Collector BackendGrafana Visualization
TracesOTel Tracing APITempoTraces tab
MetricsOTel Metrics APIPrometheusDashboards
LogsOTel Logs APILokiExplore 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​

ConcernDetail
Prometheus is pull-basedUse Remote Write exporter if you're pushing metrics.
Promtail featuresOTel logs don't automatically add Kubernetes metadata like Promtail. You must enrich logs manually.
Sampling & performanceEnable sampling, batching, retry processors in production.
OTel logs SDK maturityLogs 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