# Observability with OpenTelemetry: Traces, Metrics, and Logs

URL: https://www.devopsness.com/blog/observability-with-opentelemetry-traces-metrics-and-logs
Author: Kiril Urbonas
Published: 2025-05-21
Updated: 2025-05-21
Categories: DevOps
Tags: Kubernetes, Docker, Monitoring

Summary: Unify traces, metrics, and logs with OpenTelemetry. Instrumentation, sampling, and backend-agnostic pipelines.

---
# Observability with OpenTelemetry: Traces, Metrics, and Logs

**OpenTelemetry** gives you a single, vendor-neutral way to emit traces, metrics, and logs. Here’s how to adopt it.

## Why OpenTelemetry

- **Vendor-neutral**: Switch backends (Jaeger, Prometheus, Datadog, etc.) without changing app code.
- **Single SDK**: One instrumentation story for many languages.
- **Correlation**: Link trace IDs to logs and metrics for faster debugging.

## Quick Instrumentation (Node.js)

```javascript
const { NodeSDK } = require('@opentelemetry/sdk-node');
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');

const sdk = new NodeSDK({
  traceExporter: myExporter,
  metricReader: myMetricReader,
  instrumentations: [getNodeAutoInstrumentations()],
});
sdk.start();
```

## Best Practices

1. **Sample in production** (e.g. 10% of traces) to control cost and volume.
2. **Set resource attributes** (service.name, deployment.environment) for filtering.
3. **Use semantic conventions** so dashboards and alerts stay consistent.
4. **Secure exporters** (TLS, auth) and avoid PII in spans.

Start with one service and one backend; then roll out and add more signals.
