OpenTelemetry
Overview
OpenTelemetry (OTel) is the unified observability standard for instrumenting applications with traces, metrics, and logs. It supports auto-instrumentation across Node.js, Python, Java, and Go, and exports telemetry to backends like Jaeger, Grafana, Datadog, and Honeycomb through a flexible Collector pipeline.
Instructions
- When adding tracing, create spans with meaningful names, set span kinds (
CLIENT, SERVER, PRODUCER, CONSUMER), add business-relevant attributes, and use W3C Trace Context for propagation.
- When adding metrics, choose the right instrument type: Counter for monotonic values, Histogram for distributions like latency, UpDownCounter for fluctuating values, and Gauge for point-in-time readings.
- When setting up auto-instrumentation, use the language-specific packages (
@opentelemetry/auto-instrumentations-node, opentelemetry-instrumentation for Python, etc.) to capture HTTP, database, and messaging spans without code changes.
- When configuring the OTel Collector, define pipelines with receivers (OTLP, Prometheus), processors (batch, memory_limiter, tail_sampling), and exporters (OTLP, Jaeger, Datadog) in the collector config.
- When deploying Collectors, choose sidecar mode for per-pod collection, agent mode for per-node, or gateway mode for centralized processing.
- When setting resource attributes, always include
service.name, service.version, and deployment.environment, and use cloud/container resource detectors for infrastructure metadata.
- When naming attributes, follow OTel semantic conventions (
http.request.method, db.system, messaging.system) instead of inventing custom names.
Examples
Example 1: Add distributed tracing to a Node.js microservice
User request: "Instrument my Express API with OpenTelemetry tracing"
Actions:
- Install
@opentelemetry/auto-instrumentations-node and OTLP exporter
- Configure SDK with service name, version, and
BatchSpanProcessor
- Set up OTLP exporter pointing to the Collector endpoint
- Add custom spans with business attributes for key operations
Output: An auto-instrumented Express API sending traces to the OTel Collector with correlated spans across services.
Example 2: Set up an OTel Collector pipeline
User request: "Configure an OTel Collector to receive traces and export to Grafana Tempo"
Actions:
- Define OTLP gRPC receiver in the Collector config
- Add batch processor and memory_limiter for production safety
- Configure Tempo exporter with endpoint and authentication
- Wire the traces pipeline: receiver -> processor -> exporter
Output: A Collector config file routing traces from applications to Grafana Tempo with batching and memory protection.
Guidelines
- Always set
service.name and service.version as resource attributes.
- Use semantic conventions for attribute names; never invent custom names when a standard exists.
- Configure
BatchSpanProcessor in production, not SimpleSpanProcessor, to avoid blocking the application.
- Set
memory_limiter processor on the Collector to prevent OOM crashes.
- Sample in production:
TraceIdRatioBased(0.1) captures 10% of traces, sufficient for most services.
- Add custom attributes to spans for business context (
user.tier, feature.flag, order.total).
- Never log sensitive data in span attributes (PII, secrets, tokens).
1---2name: opentelemetry3description: >-4 Assists with instrumenting applications using OpenTelemetry for distributed tracing, metrics,5 and logs. Use when adding observability, configuring auto-instrumentation, building custom spans,6 setting up OTel Collectors, or exporting telemetry to Jaeger, Grafana, or Datadog.7 Trigger words: opentelemetry, otel, tracing, spans, metrics, observability, collector.8license: Apache-2.09compatibility: "Supports Node.js, Python, Java, Go with respective SDKs"10metadata:11 source: https://skillmd.com/skills/eliferjunior/opentelemetry12 author: terminal-skills13 version: "1.0.0"14 category: devops15 tags: ["opentelemetry", "observability", "tracing", "metrics", "monitoring"]16---1718# OpenTelemetry1920## Overview2122OpenTelemetry (OTel) is the unified observability standard for instrumenting applications with traces, metrics, and logs. It supports auto-instrumentation across Node.js, Python, Java, and Go, and exports telemetry to backends like Jaeger, Grafana, Datadog, and Honeycomb through a flexible Collector pipeline.2324## Instructions2526- When adding tracing, create spans with meaningful names, set span kinds (`CLIENT`, `SERVER`, `PRODUCER`, `CONSUMER`), add business-relevant attributes, and use W3C Trace Context for propagation.27- When adding metrics, choose the right instrument type: Counter for monotonic values, Histogram for distributions like latency, UpDownCounter for fluctuating values, and Gauge for point-in-time readings.28- When setting up auto-instrumentation, use the language-specific packages (`@opentelemetry/auto-instrumentations-node`, `opentelemetry-instrumentation` for Python, etc.) to capture HTTP, database, and messaging spans without code changes.29- When configuring the OTel Collector, define pipelines with receivers (OTLP, Prometheus), processors (batch, memory_limiter, tail_sampling), and exporters (OTLP, Jaeger, Datadog) in the collector config.30- When deploying Collectors, choose sidecar mode for per-pod collection, agent mode for per-node, or gateway mode for centralized processing.31- When setting resource attributes, always include `service.name`, `service.version`, and `deployment.environment`, and use cloud/container resource detectors for infrastructure metadata.32- When naming attributes, follow OTel semantic conventions (`http.request.method`, `db.system`, `messaging.system`) instead of inventing custom names.3334## Examples3536### Example 1: Add distributed tracing to a Node.js microservice3738**User request:** "Instrument my Express API with OpenTelemetry tracing"3940**Actions:**411. Install `@opentelemetry/auto-instrumentations-node` and OTLP exporter422. Configure SDK with service name, version, and `BatchSpanProcessor`433. Set up OTLP exporter pointing to the Collector endpoint444. Add custom spans with business attributes for key operations4546**Output:** An auto-instrumented Express API sending traces to the OTel Collector with correlated spans across services.4748### Example 2: Set up an OTel Collector pipeline4950**User request:** "Configure an OTel Collector to receive traces and export to Grafana Tempo"5152**Actions:**531. Define OTLP gRPC receiver in the Collector config542. Add batch processor and memory_limiter for production safety553. Configure Tempo exporter with endpoint and authentication564. Wire the traces pipeline: receiver -> processor -> exporter5758**Output:** A Collector config file routing traces from applications to Grafana Tempo with batching and memory protection.5960## Guidelines6162- Always set `service.name` and `service.version` as resource attributes.63- Use semantic conventions for attribute names; never invent custom names when a standard exists.64- Configure `BatchSpanProcessor` in production, not `SimpleSpanProcessor`, to avoid blocking the application.65- Set `memory_limiter` processor on the Collector to prevent OOM crashes.66- Sample in production: `TraceIdRatioBased(0.1)` captures 10% of traces, sufficient for most services.67- Add custom attributes to spans for business context (`user.tier`, `feature.flag`, `order.total`).68- Never log sensitive data in span attributes (PII, secrets, tokens).