Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
@opentelemetry/sdk-metrics-base
Advanced tools
@opentelemetry/sdk-metrics-base is a package that provides the core functionalities for collecting and reporting metrics in applications using OpenTelemetry. It allows developers to create and manage various types of metrics, such as counters, gauges, and histograms, and export them to different backends for monitoring and analysis.
Creating a Meter
This code demonstrates how to create a MeterProvider and obtain a Meter instance. A Meter is used to create and manage metrics.
const { MeterProvider } = require('@opentelemetry/sdk-metrics-base');
const meterProvider = new MeterProvider();
const meter = meterProvider.getMeter('example-meter');
Creating a Counter
This code shows how to create a Counter metric and increment its value. Counters are used to count occurrences of events.
const counter = meter.createCounter('example_counter', {
description: 'An example counter'
});
counter.add(10);
Creating a Histogram
This code demonstrates how to create a Histogram metric and record a value. Histograms are used to measure the distribution of values.
const histogram = meter.createHistogram('example_histogram', {
description: 'An example histogram'
});
histogram.record(100);
Creating an UpDownCounter
This code shows how to create an UpDownCounter metric and adjust its value up or down. UpDownCounters are used to track values that can increase or decrease.
const upDownCounter = meter.createUpDownCounter('example_updowncounter', {
description: 'An example updown counter'
});
upDownCounter.add(5);
upDownCounter.add(-3);
Exporting Metrics
This code demonstrates how to export metrics using a ConsoleMetricExporter. Metrics can be exported to various backends for monitoring and analysis.
const { ConsoleMetricExporter, PeriodicExportingMetricReader } = require('@opentelemetry/sdk-metrics-base');
const exporter = new ConsoleMetricExporter();
meterProvider.addMetricReader(new PeriodicExportingMetricReader({ exporter }));
prom-client is a Prometheus client for Node.js that allows you to create and manage metrics, such as counters, gauges, histograms, and summaries. It is similar to @opentelemetry/sdk-metrics-base in that it provides a way to collect and export metrics, but it is specifically designed for use with Prometheus.
statsd is a simple, lightweight daemon that listens for statistics, like counters and timers, sent over UDP or TCP and sends aggregates to one or more pluggable backend services (e.g., Graphite). It is similar to @opentelemetry/sdk-metrics-base in that it collects and reports metrics, but it is more focused on network-based metric collection.
newrelic is a Node.js agent for New Relic, which provides performance monitoring and management for applications. It is similar to @opentelemetry/sdk-metrics-base in that it collects and reports metrics, but it is specifically designed to work with the New Relic platform.
OpenTelemetry metrics allow a user to collect data and export it to a metrics backend like Prometheus.
The OpenTelemetry SDK in this directory is undergoing drastic changes. If you need to use metrics, we recommend you use version 0.27.0
.
npm install --save "@opentelemetry/sdk-metrics-base@~0.27.0"
Please see the version 0.27.0
README.
TODO: Add usage information for updated SDK
Apache 2.0 - See LICENSE for more information.
FAQs
Work in progress OpenTelemetry metrics SDK
The npm package @opentelemetry/sdk-metrics-base receives a total of 99,853 weekly downloads. As such, @opentelemetry/sdk-metrics-base popularity was classified as popular.
We found that @opentelemetry/sdk-metrics-base demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.