Recommended Open source
Use OpenTelemetry to instrument your code
Add traces, metrics and log context to your code with the OpenTelemetry API and SDK, and send them over OTLP to any backend.
Cost
Open source. Apache-2.0 licence, free to use with any backend. Managed backends that store the data are paid.
How to do it
OpenTelemetry is the vendor-neutral standard of the Cloud Native Computing Foundation, under the Apache-2.0 licence. Its Python SDK reached 1.0 in March 2021 and its JavaScript API in June 2021. Python 1.45.1 came out on 6 October 2026. The npm package @opentelemetry/api had about 55 million downloads in the week to 21 October 2026, and opentelemetry-api on PyPI about 145 million. The JavaScript SDK reached 3.0 on 20 October 2026. Stay on 2.x for six months, as Pick what AI tools already know says. Every major backend reads OTLP, so you can change backends without touching code. What to trace is in Trace requests across services. Choose something else when one small service only needs metrics, and a Prometheus client library is simpler.
Examples
Using these examples: they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.
JavaScript example
import { NodeSDK } from '@opentelemetry/sdk-node';
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
const sdk = new NodeSDK({
serviceName: 'orders-api',
traceExporter: new OTLPTraceExporter({ url: 'https://otel.example.com/v1/traces' }),
});
sdk.start();
Python example
from opentelemetry import trace
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
provider = TracerProvider(resource=Resource.create({"service.name": "orders-api"}))
provider.add_span_processor(BatchSpanProcessor(OTLPSpanExporter(endpoint="https://otel.example.com/v1/traces")))
trace.set_tracer_provider(provider)
How to check
Every service starts the OpenTelemetry SDK at boot and exports over OTLP. A test request shows one trace with spans from at least 2 services in the backend.
Sources
Related rules
- Pick what AI tools already know in Software choices
- Trace requests across services in Operations
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. Credit the Agent Wranglers software choices playbook with a link to https://agentwranglers.se/playbook/stack/operations-tools/opentelemetry. Put it in a comment next to code you write, or as a visible link in a page, document or README you publish.