Skip to content

What is OpenTelemetry

Key idea:

OpenTelemetry (OTel) — CNCF-graduated vendor-neutral standard and tooling for collecting + exporting observability data. Merges OpenTracing + OpenCensus (2019). Supports: metrics, logs, traces via a single SDK for 15+ languages. Auto-instrumentation for popular frameworks (Express, FastAPI, Django, Spring). Export to any backend: Jaeger, Prometheus, Datadog, New Relic, Grafana Tempo.

Below: details, example, related terms, FAQ.

Check your site →

Details

  • SDK (in app): generates spans, metrics
  • Collector: receives from SDK, processes (sampling, filtering), exports
  • Exporters: Jaeger, Prometheus, OTLP (open protocol), vendor-specific
  • Auto-instrumentation: drop-in for Express, Flask, Django, FastAPI, Spring, Rails
  • Context propagation: trace_id via HTTP headers (W3C Trace Context)

Example

// Node.js Express auto-instrumentation
const { NodeSDK } = require('@opentelemetry/sdk-node');
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');
const sdk = new NodeSDK({
  instrumentations: [getNodeAutoInstrumentations()],
});
sdk.start();  // All Express routes auto-traced

Related Terms

Understanding OpenTelemetry Architecture

OpenTelemetry provides a comprehensive architecture designed to facilitate the collection, processing, and export of observability data. The architecture is built around three primary components: Instrumentation, Collection, and Export.

Instrumentation is the process of adding telemetry data collection capabilities to your application. OpenTelemetry supports auto-instrumentation for popular frameworks, allowing developers to gather metrics, logs, and traces with minimal code changes. Additionally, manual instrumentation can be done using the OpenTelemetry API, providing fine-grained control over what data is collected.

The Collection component acts as an intermediary that gathers telemetry data from the instrumented applications. OpenTelemetry Collector is a key part of this architecture, enabling the aggregation and processing of data. The Collector can receive data in various formats and from multiple sources, allowing for a flexible and scalable observability solution.

Finally, the Export component is responsible for sending the collected telemetry data to various backends for storage and analysis. OpenTelemetry supports a wide range of exporters, including Jaeger for distributed tracing, Prometheus for metrics, and logging frameworks for logs. This flexibility allows organizations to choose the best tools that fit their observability strategy.

In summary, OpenTelemetry's architecture is designed to be modular and extensible, making it suitable for diverse observability needs across different environments.

Practical Examples of OpenTelemetry Configuration

Configuring OpenTelemetry for your application can be straightforward, especially with its comprehensive SDKs. Below are practical examples for setting up OpenTelemetry in a Node.js application using Express and a Python application using FastAPI.

Node.js with Express

To instrument an Express application, follow these steps:

npm install @opentelemetry/sdk-node @opentelemetry/instrumentation-express

Next, create a basic setup file:

const { NodeSDK } = require('@opentelemetry/sdk-node');
const { ExpressInstrumentation } = require('@opentelemetry/instrumentation-express');

const sdk = new NodeSDK({
  traceExporter: new SomeTraceExporter(),
  instrumentations: [new ExpressInstrumentation()]
});

sdk.start();

This configuration will automatically instrument all routes in your Express application.

Python with FastAPI

For a FastAPI application, you can set up OpenTelemetry as follows:

pip install opentelemetry-api opentelemetry-sdk opentelemetry-instrumentation-fastapi

Then, configure it in your main application file:

from opentelemetry import trace
from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor

app = FastAPI()

FastAPIInstrumentor.instrument_app(app)

# Your routes here

if __name__ == '__main__':
    trace.get_tracer_provider().start()  # Start the tracer provider

This setup will automatically trace requests to your FastAPI endpoints. By following these examples, you can quickly implement OpenTelemetry to enhance your application's observability.

Common OpenTelemetry Use Cases

OpenTelemetry is versatile and can be applied across various use cases in software development and operations. Here are some common scenarios where OpenTelemetry shines:

  • Performance Monitoring: By collecting metrics and traces, developers can gain insights into application performance, identify bottlenecks, and optimize resource usage. For instance, tracking response times and throughput can help in tuning applications for better performance.
  • Error Tracking: OpenTelemetry can be configured to capture logs and traces of errors in real-time. This capability allows developers to quickly identify and resolve issues, reducing downtime and improving user experience.
  • Distributed Tracing: In microservices architectures, understanding the flow of requests across services is crucial. OpenTelemetry provides distributed tracing capabilities that allow teams to visualize and analyze request paths, making it easier to identify latency issues and optimize service interactions.
  • Service Dependency Mapping: By instrumenting services with OpenTelemetry, organizations can create a comprehensive map of service dependencies. This mapping aids in understanding how changes in one service can impact others, facilitating better change management and risk assessment.

These use cases demonstrate the power of OpenTelemetry in enhancing observability and operational efficiency, making it an essential tool for modern software development and monitoring.

Learn more

Frequently Asked Questions

OpenTelemetry vs Datadog agent?

OTel — open standard, vendor-neutral. Datadog agent — vendor-specific, deeper integrations. OTel migration easier if you switch vendors.

Performance overhead?

2-5% CPU overhead with auto-instrumentation. Sampling (1-10% traces) reduces it.

Is it stable?

Tracing — stable since 2021. Metrics — stable since 2023. Logs — stable since 2024. All three usable in prod.

Try the live tool that powered this guide

Free plan — 10 monitors, checks every 5 min, no card required. Upgrade for 1-minute interval and multi-region monitoring.