Enables prometheus Metrics Sets using 'prom-client'.
Takes ENVIRONMENT_VARIABLES:
variable | purpose | required |
---|---|---|
SERVICE_NAME | identify service | yes |
import { MetricSet } from '@numbereight/metric';
const MetricSet = require('@numbereight/metric').MetricSet;
MetricSet
is a wrapper for a prom-client object. Refer to the prom-client documentation for usage.
import { MetricSet, prometheus } from '@numbereight/metric';
const metrics = new MetricSet();
const counter = new prometheus.Counter({
name: 'example_counter',
help: 'help',
registers: [],
});
metrics.registerMetrics([counter]);
app.use(makeDefaultMetricMiddleware({ registry: metrics.registry }));