Gathering detailed insights and metrics for @opentelemetry/api-metrics
Gathering detailed insights and metrics for @opentelemetry/api-metrics
OpenTelemetry JavaScript Client
npm install @opentelemetry/api-metrics
Typescript
Module System
Min. Node Version
Node Version
NPM Version
99.4
Supply Chain
98.9
Quality
79.7
Maintenance
100
Vulnerability
99.6
License
experimental/v0.57.1
Published on 14 Jan 2025
v1.30.1
Published on 14 Jan 2025
experimental/v0.57.0
Published on 18 Dec 2024
v1.30.0
Published on 18 Dec 2024
experimental/v0.56.0
Published on 04 Dec 2024
v1.29.0
Published on 04 Dec 2024
TypeScript (97.21%)
JavaScript (2.61%)
Jinja (0.1%)
Shell (0.08%)
Total Downloads
171,452,193
Last Day
118,984
Last Week
677,227
Last Month
2,268,400
Last Year
43,358,477
2,806 Stars
2,478 Commits
834 Forks
55 Watching
8 Branches
495 Contributors
Minified
Minified + Gzipped
Latest Version
0.33.0
Package Id
@opentelemetry/api-metrics@0.33.0
Unpacked Size
239.09 kB
Size
26.50 kB
File Count
138
NPM Version
lerna/5.4.3/node@v14.18.1+x64 (darwin)
Node Version
14.18.1
Cumulative downloads
Total Downloads
Last day
-4.4%
118,984
Compared to previous day
Last week
36.6%
677,227
Compared to previous week
Last month
-18.4%
2,268,400
Compared to previous month
Last year
-26.2%
43,358,477
Compared to previous year
Note: This is an experimental package under active development. New releases may include breaking changes.
This package provides everything needed to interact with the unstable OpenTelemetry Metrics API, including all TypeScript interfaces, enums, and no-op implementations. It is intended for use both on the server and in the browser.
The metrics API is considered alpha software and there is no guarantee of stability or long-term support. When the API is stabilized, it will be made available and supported long-term in the @opentelemetry/api
package and this package will be deprecated.
To get started you need to install the SDK and instrumentations, create a MeterProvider, and register it with the API.
1$ # Install metrics dependencies 2$ npm install \ 3 @opentelemetry/api-metrics \ 4 @opentelemetry/sdk-metrics \ 5 @opentelemetry/exporter-prometheus # add exporters as needed
Note: this example is for node.js. See examples/tracer-web for a browser example.
Before any other module in your application is loaded, you must initialize the global tracer and meter providers. If you fail to initialize a provider, no-op implementations will be provided to any library which acquires them from the API.
To collect traces and metrics, you will have to tell the SDK where to export telemetry data to. This example uses Jaeger and Prometheus, but exporters exist for other tracing backends. If you're not sure if there is an exporter for your tracing backend, contact your tracing provider.
1const api = require("@opentelemetry/api-metrics"); 2const { MeterProvider } = require("@opentelemetry/sdk-metrics"); 3const { PrometheusExporter } = require("@opentelemetry/exporter-prometheus"); 4 5// The Prometheus exporter runs an HTTP server which the Prometheus backend 6// scrapes to collect metrics. 7const exporter = new PrometheusExporter({ startServer: true }); 8// Creates MeterProvider and installs the exporter as a MetricReader 9const meterProvider = new MeterProvider(); 10meterProvider.addMetricReader(exporter); 11 12/** 13 * Registering the provider with the API allows it to be discovered 14 * and used by instrumentation libraries. 15 */ 16api.metrics.setGlobalMeterProvider(meterProvider);
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.
If you are writing an instrumentation library, or prefer to call the API methods directly rather than using the register
method on the Tracer/Meter Provider, OpenTelemetry provides direct access to the underlying API methods through the @opentelemetry/api-metrics
package. API entry points are defined as global singleton objects trace
, metrics
, propagation
, and context
which contain methods used to initialize SDK implementations and acquire resources from the API.
1const api = require("@opentelemetry/api-metrics"); 2 3/* Initialize MeterProvider */ 4api.metrics.setGlobalMeterProvider(meterProvider); 5/* returns meterProvider (no-op if a working provider has not been initialized) */ 6api.metrics.getMeterProvider(); 7/* returns a meter from the registered global meter provider (no-op if a working provider has not been initialized) */ 8api.metrics.getMeter(name, version);
Apache 2.0 - See LICENSE for more information.
No vulnerabilities found.
Reason
all changesets reviewed
Reason
30 commit(s) and 11 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
no binaries found in the repo
Reason
security policy file detected
Details
Reason
SAST tool is run on all commits
Details
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
9 existing vulnerabilities detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
Project has not signed or included provenance with any releases.
Details
Reason
project is not fuzzed
Details
Score
Last Scanned on 2025-01-06
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