Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

opossum-prometheus

nodeshift24.8kApache-2.00.5.0

Prometheus metrics for opossum circuit breaker

circuit breaker, fail fast, prometheus, metrics

readme

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)
Name Description Default
circuits A list or individual circuit breaker to create metrics for No circuits
registry An existing registry to use for prometheus metrics undefined - The default prometheus registry will be used and default system metrics will be collected
exposePerformanceMetrics Measure the performance of breakers and report them through the registry true
metricPrefix Prefix for circuit breakers metrics name any string

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

0.5.0 (2025-06-10)

⚠ BREAKING CHANGES

  • remove Node 18 support (#108)
  • Bump supported node.js version (#91)

Features

Bug Fixes

  • upgrade opossum from 8.3.0 to 8.4.0 (#96) (2dcebf3)
  • upgrade prom-client from 15.1.0 to 15.1.1 (#80) (e29d378)

0.4.0 (2024-04-08)

⚠ BREAKING CHANGES

  • Drop support for Node.js v14 Update prom-client to v15 metrics is now an async function
  • drop Node.js 12

Features

  • support Node.js v20 (#78) (1f3e050)
  • upgrade opossum from 5.1.3 to 6.2.1 (#62) (88e13d5)
  • using semistandard and greenkeeper badge removed (bdfe980)

Bug Fixes

  • package.json & package-lock.json to reduce vulnerabilities (#56) (5c57b1e)
  • upgrade coveralls from 3.1.0 to 3.1.1 (#51) (1bcbaae)
  • upgrade opossum from 5.0.0 to 5.0.1 (#33) (e9e700a)
  • upgrade opossum from 5.0.1 to 5.0.2 (#36) (c45d4b1)
  • upgrade opossum from 5.0.2 to 5.1.0 (#38) (d3f509d)
  • upgrade opossum from 5.1.0 to 5.1.1 (#39) (ae9f69b)
  • upgrade opossum from 5.1.1 to 5.1.2 (#43) (f0c00fe)
  • upgrade opossum from 5.1.2 to 5.1.3 (#44) (78c826b)
  • upgrade standard-version from 9.0.0 to 9.1.0 (#40) (6c694ed)
  • upgrade standard-version from 9.1.0 to 9.3.0 (#49) (d29b608)
  • upgrade tape from 5.0.1 to 5.1.0 (#41) (c51f9d3)
  • upgrade tape from 5.1.0 to 5.1.1 (#42) (d45e86a)
  • upgrade tape from 5.1.1 to 5.2.2 (#50) (ebeeed4)

0.3.0 (2020-09-02)

Features

  • Providing metric prefix for circuit metrics (#32) (0d85a86)

Bug Fixes

  • upgrade standard-version from 8.0.1 to 8.0.2 (#30) (e8edaa1)

0.2.0 (2020-04-23)

⚠ BREAKING CHANGES

  • Options object is now used to configure custom registry and initial circuits

  • docs: Updates and adds documentation for options object configuration

Features

  • adds option for performance metrics so they can be disabled, default is enabled (#20) (2437eca)
  • Use options object for all configuration (#19) (b353a59)

Bug Fixes

  • upgrade standard-version from 7.0.0 to 7.1.0 (#17) (2b68517)
  • upgrade tape from 4.11.0 to 4.13.2 (#16) (6233d53)

0.1.0 (2020-03-13)

⚠ BREAKING CHANGES

  • Changes event metrics to use labels rather than seporate metrics
  • Changes metrics to use labels for circuit name rather than seporate metrics

Co-authored-by: martlandh HarryMartland@Rentalcars.com

Features

0.0.4 (2019-10-02)

Features

  • add stats (percentiles stats, reponse times) in Prometheus metrics (#10) (712fa2d)

0.0.3 (2019-09-18)

Features

  • allow one circuit to be pass in without an array. (#5) (02ca8f5), closes #4
  • allow to add circuits dynamicaly (#7) (afbaef2)

0.0.2 (2019-08-13)