Gathering detailed insights and metrics for @opentelemetry/api
Gathering detailed insights and metrics for @opentelemetry/api
Gathering detailed insights and metrics for @opentelemetry/api
Gathering detailed insights and metrics for @opentelemetry/api
@opentelemetry/api-logs
Public logs API for OpenTelemetry
@opentelemetry/api-metrics
Public metrics API for OpenTelemetry
@opentelemetry/instrumentation-net
OpenTelemetry instrumentation for `node:net` network API module
@opentelemetry/instrumentation-runtime-node
OpenTelemetry instrumentation for Node.js Performance measurement API
npm install @opentelemetry/api
Typescript
Module System
Min. Node Version
Node Version
NPM Version
semconv/v1.36.0
Updated on Jul 10, 2025
experimental/v0.203.0
Updated on Jul 09, 2025
experimental/v0.202.0
Updated on Jun 02, 2025
semconv/v1.34.0
Updated on May 21, 2025
semconv/v1.33.1
Updated on May 20, 2025
experimental/v0.201.1
Updated on May 19, 2025
TypeScript (96.76%)
JavaScript (2.94%)
Jinja (0.21%)
Shell (0.08%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
Apache-2.0 License
3,034 Stars
2,719 Commits
909 Forks
53 Watchers
19 Branches
340 Contributors
Updated on Jul 15, 2025
Latest Version
1.9.0
Package Id
@opentelemetry/api@1.9.0
Unpacked Size
1.16 MB
Size
123.81 kB
File Count
642
NPM Version
lerna/6.6.2/node@v18.19.0+x64 (linux)
Node Version
18.19.0
Published on
Jun 05, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
This package provides everything needed to interact with the OpenTelemetry API, including all TypeScript interfaces, enums, and no-op implementations. It is intended for use both on the server and in the browser.
The methods in this package perform no operations by default. This means they can be safely called by a library or end-user application whether there is an SDK registered or not. In order to generate and export telemetry data, you will also need an SDK such as the OpenTelemetry JS SDK.
Note: ECMAScript 5+ compatibility is for this package only. Please refer to the documentation for the SDK you are using to determine its minimum ECMAScript version.
Note for library authors: Only your end users will need an OpenTelemetry SDK. If you wish to support OpenTelemetry in your library, you only need to use the OpenTelemetry API. For more information, please read the tracing documentation.
1npm install @opentelemetry/api @opentelemetry/sdk-trace-base
In order to get started with tracing, you will need to first register an SDK. The SDK you are using may provide a convenience method which calls the registration methods for you, but if you would like to call them directly they are documented here: SDK registration methods.
Once you have registered an SDK, you can start and end spans. A simple example of basic SDK registration and tracing a simple operation is below. The example should export spans to the console once per second. For more information, see the tracing documentation.
1const { trace } = require("@opentelemetry/api"); 2const { BasicTracerProvider, ConsoleSpanExporter, SimpleSpanProcessor } = require("@opentelemetry/sdk-trace-base"); 3 4// Create and register an SDK 5const provider = new BasicTracerProvider(); 6provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter())); 7trace.setGlobalTracerProvider(provider); 8 9// Acquire a tracer from the global tracer provider which will be used to trace the application 10const name = 'my-application-name'; 11const version = '0.1.0'; 12const tracer = trace.getTracer(name, version); 13 14// Trace your application by creating spans 15async function operation() { 16 const span = tracer.startSpan("do operation"); 17 18 // mock some work by sleeping 1 second 19 await new Promise((resolve, reject) => { 20 setTimeout(resolve, 1000); 21 }) 22 23 span.end(); 24} 25 26async function main() { 27 while (true) { 28 await operation(); 29 } 30} 31 32main();
Because the npm installer and node module resolution algorithm could potentially allow two or more copies of any given package to exist within the same node_modules
structure, the OpenTelemetry API takes advantage of a variable on the global
object to store the global API. When an API method in the API package is called, it checks if this global
API exists and proxies calls to it if and only if it is a compatible API version. This means if a package has a dependency on an OpenTelemetry API version which is not compatible with the API used by the end user, the package will receive a no-op implementation of the API.
No breaking changes
api.context.bind
arguments reversed and context
is now a required argument.api.trace.wrapSpanContext
with INVALID_SPAN_CONTEXT
instead of using the NOOP_TRACER
.TimedEvent
which was not part of specHttpBaggage
renamed to HttpBaggagePropagator
Span#context
renamed to Span#spanContext
getSpan
/setSpan
/getSpanContext
/setSpanContext
moved to trace
namespacegetBaggage
/setBaggage
/createBaggage
moved to propagation
namespaceApache 2.0 - See LICENSE for more information.
No vulnerabilities found.
Reason
update tool detected
Details
Reason
30 commit(s) and 13 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
GitHub workflow tokens follow principle of least privilege
Details
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
SAST tool is run on all commits
Details
Reason
security policy file detected
Details
Reason
29 out of 29 merged PRs checked by a CI test -- score normalized to 10
Reason
project has 43 contributing companies or organizations
Details
Reason
Found 29/30 approved changesets -- score normalized to 9
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
Project has not signed or included provenance with any releases.
Details
Reason
project is not fuzzed
Details
Reason
13 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-14T20:15:31Z
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More