Home

Awesome


<p align="center"> <strong> <a href="https://opentelemetry.io/docs/languages/js/getting-started/">Getting Started</a> &nbsp;&nbsp;&bull;&nbsp;&nbsp; <a href="https://open-telemetry.github.io/opentelemetry-js">API and SDK Reference</a> </strong> </p> <p align="center"> <a href="https://github.com/open-telemetry/opentelemetry-js/releases"> <img alt="GitHub release (latest by date including pre-releases)" src="https://img.shields.io/github/v/release/open-telemetry/opentelemetry-js?include_prereleases&style=for-the-badge"> </a> <a href="https://codecov.io/gh/open-telemetry/opentelemetry-js/branch/main/"> <img alt="Codecov Status" src="https://img.shields.io/codecov/c/github/open-telemetry/opentelemetry-js?style=for-the-badge"> </a> <a href="https://github.com/open-telemetry/opentelemetry-js/blob/main/LICENSE"> <img alt="license" src="https://img.shields.io/badge/license-Apache_2.0-green.svg?style=for-the-badge"> </a> <br/> <a href="https://circleci.com/gh/open-telemetry/opentelemetry-js"> <img alt="Build Status" src="https://circleci.com/gh/open-telemetry/opentelemetry-js.svg?style=shield"> </a> <img alt="Beta" src="https://img.shields.io/badge/status-beta-informational?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAIRlWElmTU0AKgAAAAgABQESAAMAAAABAAEAAAEaAAUAAAABAAAASgEbAAUAAAABAAAAUgEoAAMAAAABAAIAAIdpAAQAAAABAAAAWgAAAAAAAACQAAAAAQAAAJAAAAABAAOgAQADAAAAAQABAACgAgAEAAAAAQAAABigAwAEAAAAAQAAABgAAAAA8A2UOAAAAAlwSFlzAAAWJQAAFiUBSVIk8AAAAVlpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDUuNC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICA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WvAdQ+hs/zw9savimxUntDSaBdZ2f+Idbm1rlNY8esFffBit9HtK5/MejsrJVxikOXlb1Ukir2X+Rbdkd1KG2Ixfn2Ql4JRmELnYK9mEM8G36fAA3xEQ89fxXihC8q+sAKi9jhHxNqagY2hiaYgRCm0f0QP7H4Fp11LSXiuBY2aYFlh0DeDIVVFUJQn5rCnpiNI2gvLxHnASn9DIVHJJlm5rXvQAGEo4zvKq2w5G1NxENN7jrft1oxMdekETjxdH2Z3x+VTVYsPb+O0C/9/auN6v2hNZw5b2UOmSbG5/rkC3LBA+1PdxFxORjxpQ81GcxKc+ybVjEBvUJvaGJ7p7n5A5KSwe4AzkasA+crmzFtowoIVTiLjANm8GDsrWW35ScI3JY8Urv83tnkF8JR0yLvEt2hO/0qNyy3Jb3YKeHeHeLeOuVLRpNF+pkf85OW7/zJxWdXsbsKBUk2TC0BCPwMq5Q/CPvaJFkNS/1l1qUPe+uH3oD59erYGI/Y4sce6KaXYElAIOLt+0O3t2+/xJDF1XvOlWGC1W1B8VMszbGfOvT5qaRRAIFK3BCO164nZ0uYLH2YjNN8thXS2v2BK9gTfD7jHVxzHr4roOlEvYYz9QIz+Vl/sLDXInsctFsXjqIRnO2ZO387lxmIboLDZCJ59KLFliNIgh9ipt6tLg9SihpRPDO1ia5byw7de1aCQmF5geOQtK509rzfdwxaKOIq+73AvwCC5/5fcV4vo3+3LpMdtWHh0ywsJC/ZGoCb8/9D8F/ifgLLl8S8QWfU8cAAAAASUVORK5CYII="> </p> <p align="center"> <strong> <a href="https://github.com/open-telemetry/opentelemetry-js/blob/main/CONTRIBUTING.md">Contributing</a> &nbsp;&nbsp;&bull;&nbsp;&nbsp; <a href="https://github.com/open-telemetry/opentelemetry-js/tree/main/examples">Examples</a> </strong> </p>

[!WARNING] This is the working branch for the work in progress 2.0 SDK, see this tracking issue for details. If you are a user looking for the current released state, you are probably looking for the 1.x SDK on the v1.x branch.

About this project

This is the JavaScript version of OpenTelemetry, a framework for collecting traces, metrics, and logs from applications.

Quick Start

Much of OpenTelemetry JS documentation is written assuming the compiled application is run as CommonJS. For more details on ECMAScript Modules vs CommonJS, refer to esm-support.

The following describes how to set up tracing for a basic web application. For more detailed documentation, see the website at https://opentelemetry.io/docs/instrumentation/js/.

Installation

Dependencies with the latest tag on NPM should be compatible with each other. See the version compatibility matrix below for more information.

npm install --save @opentelemetry/api
npm install --save @opentelemetry/sdk-node
npm install --save @opentelemetry/auto-instrumentations-node

Note: auto-instrumentations-node is a meta package from opentelemetry-js-contrib that provides a simple way to initialize multiple Node.js instrumentations.

Set up Tracing

// 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-base');
const { Resource } = require('@opentelemetry/resources');
const { SEMRESATTRS_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: new Resource({
    [SEMRESATTRS_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));
});

Run Your Application

node -r ./tracing.js app.js

The above example will emit auto-instrumented telemetry about your Node.js application to the console. For a more in-depth example, see the Getting Started Guide. For more information about automatic instrumentation see @opentelemetry/sdk-trace-node, which provides auto-instrumentation for Node.js applications. If the automatic instrumentation does not suit your needs, or you would like to create manual traces, see @opentelemetry/sdk-trace-base

Library Author

If you are a library author looking to build OpenTelemetry into your library, please see the documentation. As a library author, it is important that you only depend on properties and methods published on the public API. If you use any properties or methods from the SDK that are not officially a part of the public API, your library may break if an application owner uses a different SDK implementation.

Supported Runtimes

Platform VersionSupported
Node.JS v22:heavy_check_mark:
Node.JS v20:heavy_check_mark:
Node.JS v18:heavy_check_mark:
Older Node VersionsSee Node Support
Web BrowsersSee Browser Support below

Node Support

Only Node.js Active or Maintenance LTS versions are supported. Previous versions of node may work, but they are not tested by OpenTelemetry and they are not guaranteed to work.

Browser Support

[!IMPORTANT] Client instrumentation for the browser is experimental and mostly unspecified. If you are interested in helping out, get in touch with the Client Instrumentation SIG.

Rather than define versions of specific browsers / runtimes, OpenTelemetry sets the minimum supported version based on the underlying language features used.

The current minumum language feature support is set as ECMAScript 2020 that are available in all modern browsers / runtimes.

This means that if you are targeting or your end-users are using a browser / runtime that does not support ES2020, you will need to transpile the code and provide any necessary polyfills for the missing features to ensure compatibility with your target environments. Any support issues that arise from using a browser or runtime that does not support ES2020 will be closed as "won't fix".

This minimum support level is subject to change as the project evolves and as the underlying language features evolve.

Package Version Compatibility

OpenTelemetry is released as a set of distinct packages in 3 categories: API, stable SDK, and experimental. The API is located at /api, the stable SDK packages are in the /packages directory, and the experimental packages are listed in the /experimental/packages directory. There may also be API packages for experimental signals in the experimental directory. All stable packages are released with the same version, and all experimental packages are released with the same version. The below table describes which versions of each set of packages are expected to work together.

Stable PackagesExperimental Packages
1.30.x0.57.x
1.29.x0.56.x
1.28.x0.55.x
1.27.x0.54.x
1.25.x0.52.x
<details> <summary>Older version compatibility matrix</summary> <table> <tr><th>Stable Packages</th> <th>Experimental Packages</th></tr> <tr><td>1.24.x</td> <td>0.51.x</td></tr> <tr><td>1.23.x</td> <td>0.50.x</td></tr> <tr><td>1.22.x</td> <td>0.49.x</td></tr> <tr><td>1.21.x</td> <td>0.48.x</td></tr> <tr><td>1.20.x</td> <td>0.47.x</td></tr> <tr><td>1.19.x</td> <td>0.46.x</td></tr> <tr><td>1.18.x</td> <td>0.45.x</td></tr> <tr><td>1.17.x</td> <td>0.43.x, 0.44.x</td></tr> <tr><td>1.16.x</td> <td>0.42.x</td></tr> <tr><td>1.15.x</td> <td>0.41.x</td></tr> <tr><td>1.14.x</td> <td>0.40.x</td></tr> <tr><td>1.13.x</td> <td>0.39.x</td></tr> <tr><td>1.12.x</td> <td>0.38.x</td></tr> <tr><td>1.11.x</td> <td>0.37.x</td></tr> <tr><td>1.10.x</td> <td>0.36.x</td></tr> <tr><td>1.9.x</td> <td>0.35.x</td></tr> <tr><td>1.8.x (this and later versions require API >=1.3.0 for metrics)</td><td>0.34.x</td></tr> <tr><td>1.7.x</td> <td>0.33.x</td></tr> <tr><td>1.6.x</td> <td>0.32.x</td></tr> <tr><td>1.5.x</td> <td>0.31.x</td></tr> <tr><td>1.4.x</td> <td>0.30.x</td></tr> <tr><td>1.3.x</td> <td>0.29.x</td></tr> <tr><td>1.2.x</td> <td>0.29.x</td></tr> <tr><td>1.1.x</td> <td>0.28.x</td></tr> <tr><td>1.0.x</td> <td>0.27.x</td></tr> <tr><td>1.0.x (this and later versions require API >=1.0.0 for traces)</td><td>0.26.x</td></tr> </table> </details>

Versioning

The current version for each package can be found in the respective package.json file for that module. For additional details see the versioning and stability document in the specification.

Feature Status

SignalAPI StatusSDK Status
TracingStableStable
MetricsStableStable
LogsDevelopmentDevelopment

For a more detailed breakdown of feature support see the specification compliance matrix.

Contributing

We'd love your help!. Use tags up-for-grabs and good first issue to get started with the project. For instructions to build and make changes to this project, see the CONTRIBUTING guide.

We have a weekly SIG meeting! See the community page for meeting details and notes.

Community members

Maintainers (@open-telemetry/javascript-maintainers)

Find more about the maintainer role in the community repository.

Approvers (@open-telemetry/javascript-approvers)

Find more about the approver role in the community repository.

Triager (@open-telemetry/javascript-triagers)

Find more about the triager role in the community repository.

Emeriti

Find more about the emeritus role in community repository.

Thanks to all the people who already contributed

<a href="https://github.com/open-telemetry/opentelemetry-js/graphs/contributors"> <img alt="Repo contributors" src="https://contributors-img.web.app/image?repo=open-telemetry/opentelemetry-js" /> </a>

Packages

API

PackageDescription
@opentelemetry/apiThis package provides TypeScript interfaces, enums and no-op implementations for the OpenTelemetry core trace and metrics model. It is intended for use both on the server and in the browser.
@opentelemetry/coreThis package provides default and no-op implementations of the OpenTelemetry api for trace and metrics. It's intended for use both on the server and in the browser.

Implementation / SDKs

PackageDescription
@opentelemetry/sdk-trace-baseThis module provides a full control over instrumentation and span creation. It doesn't load async_hooks or any instrumentation by default. It is intended for use both on the server and in the browser.
@opentelemetry/sdk-metricsThis module provides instruments and meters for reporting of time series data.
@opentelemetry/sdk-trace-nodeThis module provides automatic tracing for Node.js applications. It is intended for use on the server only.
@opentelemetry/sdk-trace-webThis module provides automated instrumentation and tracing for Web applications. It is intended for use in the browser only.

Compatible Exporters

OpenTelemetry is vendor-agnostic and can upload data to any backend with various exporter implementations. Even though, OpenTelemetry provides support for many backends, vendors/users can also implement their own exporters for proprietary and unofficially supported backends.

See the OpenTelemetry registry for a list of exporters available.

Instrumentations

OpenTelemetry can collect tracing data automatically using instrumentations.

To request automatic tracing support for a module not on this list, please file an issue. Alternatively, Vendor/Users can write an instrumentation yourself.

Currently, OpenTelemetry supports automatic tracing for:

Node Instrumentations

Core
Contrib

These instrumentations are hosted at https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/node

Web Instrumentations

Core
Contrib

These instrumentations are hosted at https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/web

Shims

PackageDescription
@opentelemetry/shim-opentracingOpenTracing shim allows existing OpenTracing instrumentation to report to OpenTelemetry

Useful links

License

Apache 2.0 - See LICENSE for more information.