How to use the prom-client.exponentialBuckets function in prom-client

To help you get started, we’ve selected a few prom-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github joao-fontenele / express-prometheus-middleware / src / index.js View on Github external
requestDurationGenerator,
} = require('./metrics');

const {
  normalizeStatusCode,
  normalizePath,
} = require('./normalizers');

const defaultOptions = {
  metricsPath: '/metrics',
  metricsApp: null,
  authenticate: null,
  collectDefaultMetrics: true,
  // buckets for response time from 0.05s to 2.5s
  // these are aribtrary values since i dont know any better ¯\_(ツ)_/¯
  requestDurationBuckets: Prometheus.exponentialBuckets(0.05, 1.75, 8),
  extraMasks: [],
};

module.exports = (userOptions = {}) => {
  const options = { ...defaultOptions, ...userOptions };

  const { metricsPath, metricsApp } = options;

  // if no app is provided, instantiate one
  const app = metricsApp || express();
  app.disable('x-powered-by');

  const requestDuration = requestDurationGenerator(options.requestDurationBuckets, options.prefix);
  const requestCount = requestCountGenerator(options.prefix);

  /**