Socket
Socket
Sign inDemoInstall

opossum-prometheus

Package Overview
Dependencies
Maintainers
10
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

opossum-prometheus

Prometheus metrics for opossum circuit breaker


Version published
Maintainers
10
Created
Source

Prometheus Metrics for Opossum Circuit Breaker

Node.js CI Coverage Status Known Vulnerabilities

This module provides Prometheus metrics for opossum circuit breakers. To use it with your circuit breakers, just pass them in to the PrometheusMetrics constructor.

For each circuit breaker, the metrics are:

  • a prometheus counter for each event name
  • a prometheus summary for the events success, failed execution time.

Example:

  const CircuitBreaker = require('opossum');
  const PrometheusMetrics = require('opossum-prometheus');

  // create a couple of circuit breakers
  const c1 = new CircuitBreaker(someFunction);
  const c2 = new CircuitBreaker(someOtherFunction);

  // Provide them to the constructor
  const prometheus = new PrometheusMetrics({ circuits: [c1, c2] });

  //...
  // Provide other circuit breaker later
  const c3 = new CircuitBreaker(someOtherFunction3);
  prometheus.add([c3]);
  
  // Write metrics to the console
  console.log(await prometheus.metrics());

This module would typically be used in an application that can provide an endpoint for the Prometheus server to monitor.

The prometheusRegistry constructor parameter allows you to provide an existing prom-client registry. The metrics about the circuit will be added to the provided registry instead of the global registry. The default metrics will not be added to the provided registry.

const CircuitBreaker = require('opossum');
const PrometheusMetrics = require('opossum-prometheus');
const { Registry } = require('prom-client');

// Create a registry
const registry = new Registry();

// create a circuit
const circuit = new CircuitBreaker(functionThatMightFail);
const metrics = new PrometheusMetrics({ circuits: [circuit], registry: registry })

Options

The PrometheusMetrics constructor takes an options object as detailed below.

const options = {};
new PrometheusMetrics(options)
NameDescriptionDefault
circuitsA list or individual circuit breaker to create metrics forNo circuits
registryAn existing registry to use for prometheus metricsundefined - The default prometheus registry will be used and default system metrics will be collected
exposePerformanceMetricsMeasure the performance of breakers and report them through the registrytrue
metricPrefixPrefix for circuit breakers metrics nameany string

Keywords

FAQs

Package last updated on 08 Apr 2024

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