Socket
Book a DemoInstallSign in
Socket

@gasbuddy/configured-prometheus-client

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gasbuddy/configured-prometheus-client

A configuration driven prometheus client

2.0.0
latest
npmnpm
Version published
Maintainers
2
Created
Source

configured-prometheus-client

Greenkeeper badge

wercker status

A small wrapper around the Prometheus client to allow configuration from JSON configuration or hydration.

You can create metrics "upfront":

import PrometheusClient from '@gasbuddy/configured-prometheus-client';

const client = new PrometheusClient({}, {
    histograms: {
      TestHisto: {
        help: 'Test Histogram',
        labels: ['foo', 'baz'],
        buckets: [0.1, 0.2, 1],
      },
    },
    counters: {
      TestCount: {
        help: 'Test Counter',
      },
    },
    gauges: {
      TestGauge: {
        help: 'Test Gauge',
      },
    },
    summaries: {
      TestSum: {
        help: 'Test Summary',
      },
    },
  });

// Increment the counter by 5
client.counters.TestCount.inc(5);

Also, since most things you want to time are some sort of asynchronous operation, the client provides a "Promise timer" method:

async function aPromise(value) {
  await Promise.delay(1);
  return value;
}

const rz = await client.promiseTimer('TestHisto')
  .label({ foo: 'bar' })
  .labelSuccess(result => ({ baz: result }))
  .execute(aPromise('beep'));
// rz is now the result of the promise

The foo:bar label will be applied on the call to startTimer, and the baz:beep label will be applied when the timer ends assuming the promise resolves rather than rejects (use labelError for that case). Each of the label functions accepts either a function (so you can examine the result of the promise) or a literal object that just gets added to the labels.

(Note that literal labels applied with .label() will always be applied when the timer STARTS, all others will be applied in order after it resolves or rejects).

Keywords

etcd

FAQs

Package last updated on 17 Oct 2018

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.