Skip to content
Hystrix metrics for the opossum circuit breaker
Branch: master
Clone or download
greenkeeper chore(package): Update opossum to the latest version 🚀 (#11)
* chore(package): update opossum to version 5.0.0

* chore(package): update lockfile package-lock.json
Latest commit 55c27bc Feb 20, 2020
Type Name Latest commit message Commit time
Failed to load latest commit information.

Hystrix Metrics for Opossum Circuit Breaker

CircleCI Codacy Badge Codacy Badge dependencies Status Known Vulnerabilities

NPM Greenkeeper badge

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

Hystrix Dashboard Stream

A Hystrix Stream is available for use with a Hystrix Dashboard using the HystrixStats#stream property. This property provies a Node.js Stream, making it straightforward to create an Server Side Event stream that will be compliant with a Hystrix Dashboard.

Additional Reading: Hystrix Metrics Event Stream, Turbine, Hystrix Dashboard

Example Usage

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

  const CircuitBreaker = require('opossum');
  const HystrixStats = require('opossum-hystrix');
  const express = require('express');

  const app = express();
  app.use('/', hystrixStream);

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

  // Provide them to the constructor
  const hystrixMetrics = new HystrixStats([c1, c2]);

  // Provide a Server Side Event stream of metrics data
  function hystrixStream (request, response) {
      response.writeHead(200, {
        'Content-Type': 'text/event-stream',
        'Cache-Control': 'no-cache',
        'Connection': 'keep-alive'
      response.write('retry: 10000\n');
      response.write('event: connecttime\n');

You can’t perform that action at this time.