OpenTelemetry
Standard APIs and SDKs for distributed tracing and observability.
3. Used by agents' projects
Dependency in 91 public GitHub projects set up for AI coding agents that we scanned (1.5%).
4. Agent access
Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.
opentelemetry.io/llms.txtFrom the package registry and GitHub, checked daily. Tap a verdict to see its source.How we checkedReport an error
What OpenTelemetry does
<code>@opentelemetry/api</code> is the public interface layer of OpenTelemetry JS. Libraries and app code record traces, metrics and logs against it, while the application chooses the SDK and where the data goes.
OpenTelemetry popularity
Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated
How OpenTelemetry is used
- OpenTelemetry is a dependency in 91 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (1.9% of the 4,867 JavaScript/TypeScript ones), #5 of 121 in logging, monitoring and analytics.
- Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 456; those are left out of every share on this page.
- The most used alternative in our scan is Sentry Node SDK (40 projects).
- Projects that use it most often also use Zod (76.9%), dotenv (51.6%), tsx (50.5%).
By coding agent
Often used with
OpenTelemetry in practice
Strengths
The README tells library authors to depend only on the public API. If a library uses SDK internals instead, it may break when an application owner picks a different SDK implementation. That separation is what lets a library ship instrumentation without choosing an SDK for its users.
The project site says telemetry can go to Jaeger, Prometheus, commercial vendors or your own system. It also says you can change backends without touching application code.
The README's <code>tracing.js</code> setup registers <code>getNodeAutoInstrumentations()</code>. Without writing any spans by hand, it emits telemetry about the app to the console.
All stable packages share one version number, and all experimental packages share another. A published table maps which stable line goes with which experimental line, for example 2.0.x with 0.200.x.
Watch out for
The README warns that much of the documentation assumes the compiled app runs as CommonJS. ESM projects are pointed to a separate esm-support document.
Client instrumentation for the browser is marked experimental and mostly unspecified.
The minimum language level is ES2022. Older targets need transpiling and polyfills, and issues from runtimes without ES2022 are closed.
Set up tracing for a Node.js app
// tracing.js
'use strict'
const process = require('process');
const opentelemetry = require('@opentelemetry/sdk-node');
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');
const { ConsoleSpanExporter } = require('@opentelemetry/sdk-trace');
const { resourceFromAttributes } = require('@opentelemetry/resources');
const { ATTR_SERVICE_NAME } = require('@opentelemetry/semantic-conventions');
// configure the SDK to export telemetry data to the console
// enable all auto-instrumentations from the meta package
const traceExporter = new ConsoleSpanExporter();
const sdk = new opentelemetry.NodeSDK({
resource: resourceFromAttributes({
[ATTR_SERVICE_NAME]: 'my-service',
}),
traceExporter,
instrumentations: [getNodeAutoInstrumentations()]
});
// initialize the SDK and register with the OpenTelemetry API
// this enables the API to record telemetry
sdk.start();
// gracefully shut down the SDK on process exit
process.on('SIGTERM', () => {
sdk.shutdown()
.then(() => console.log('Tracing terminated'))
.catch((error) => console.log('Error terminating tracing', error))
.finally(() => process.exit(0));
});More about OpenTelemetry
Agent Skills for it
- opentelemetry-llm: OpenTelemetry instrumentation for LLM applications with distributed tracing
- opentelemetry-net-instrumentation: Provides guidance for implementing OpenTelemetry instrumentation in .NET codebases, covering tracing (Activities/Spans), metrics, logs, nami
- opentelemetry: Instrument applications and infrastructure with OpenTelemetry for unified traces, metrics, and logs. Use when implementing distributed traci
Packages around it
- @opentelemetry/sdk-node: Node.js SDK setup
- @opentelemetry/resources: Resource attributes
- @opentelemetry/sdk-trace-base: Core tracing SDK
- @opentelemetry/exporter-trace-otlp-http: OTLP trace exporter (HTTP)
- @opentelemetry/sdk-trace-node: Node tracer provider
- @opentelemetry/core: Shared core and propagators
More in Logging, monitoring and analytics
Alternatives
OpenTelemetry This page
Error tracking and performance monitoring for Node.js with OpenTelemetry instrumentation.
Official Sentry SDK for React error tracking and performance monitoring.
Get started
Install it.
npm install @opentelemetry/apiRules for your agent
## OpenTelemetry (JS)
- Install `@opentelemetry/api`, `@opentelemetry/sdk-node` and `@opentelemetry/auto-instrumentations-node` together. Use the `latest` tag on all of them, or follow the stable/experimental compatibility table (for example 2.0.x with 0.200.x).
- Put SDK setup in its own file and preload it before the app, e.g. `node -r ./tracing.js app.js`. Call `sdk.start()`, and call `sdk.shutdown()` on `SIGTERM`.
- In library code, import only from `@opentelemetry/api`. Never rely on SDK properties that are not part of the public API.
- If no data reaches the collector, add `diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG)` from `@opentelemetry/api`.
- Docs assume CommonJS. For ESM output, check the project's esm-support document before copying examples.
- When recording a handled error, call `span.recordException(error)` and also `span.setStatus({ code: SpanStatusCode.ERROR })`.
- Compile with TypeScript 5.2.2 or higher. Target ES2022, or transpile and polyfill for older runtimes.