Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@opentelemetry/sdk-metrics-base

Package Overview
Dependencies
Maintainers
2
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opentelemetry/sdk-metrics-base

Work in progress OpenTelemetry metrics SDK

  • 0.30.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created

What is @opentelemetry/sdk-metrics-base?

@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.

What are @opentelemetry/sdk-metrics-base's main functionalities?

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 }));

Other packages similar to @opentelemetry/sdk-metrics-base

Keywords

FAQs

Package last updated on 06 Jul 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc