Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

prom-client

Package Overview
Dependencies
Maintainers
1
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prom-client - npm Package Compare versions

Comparing version 8.0.0 to 8.1.0

53

lib/register.js

@@ -12,28 +12,32 @@ 'use strict';

var getMetrics = function getMetrics() {
return getMetricsAsArray().reduce(function(acc, metric) {
var item = metric.get();
var name = escapeString(item.name);
var help = escapeString(item.help);
help = ['#', 'HELP', name, help].join(' ');
var type = ['#', 'TYPE', name, item.type].join(' ');
function getMetricAsPrometheusString(metric) {
var item = metric.get();
var name = escapeString(item.name);
var help = escapeString(item.help);
help = ['#', 'HELP', name, help].join(' ');
var type = ['#', 'TYPE', name, item.type].join(' ');
var values = (item.values || []).reduce(function(valAcc, val) {
var labels = Object.keys(val.labels || {}).map(function(key) {
return key + '="' + escapeLabelValue(val.labels[key]) + '"';
});
var values = (item.values || []).reduce(function(valAcc, val) {
var labels = Object.keys(val.labels || {}).map(function(key) {
return key + '="' + escapeLabelValue(val.labels[key]) + '"';
});
var metricName = val.metricName || item.name;
if(labels.length) {
metricName += '{' + labels.join(',') + '}';
}
var metricName = val.metricName || item.name;
if(labels.length) {
metricName += '{' + labels.join(',') + '}';
}
valAcc += [metricName, val.value].join(' ');
valAcc += '\n';
return valAcc;
}, '');
valAcc += [metricName, val.value].join(' ');
valAcc += '\n';
return valAcc;
}, '');
acc += [help, type, values].join('\n');
return acc;
}, '');
var acc = [help, type, values].join('\n');
return acc;
}
var getMetrics = function getMetrics() {
return getMetricsAsArray()
.map(getMetricAsPrometheusString)
.join('\n');
};

@@ -73,2 +77,6 @@

var getSingleMetricAsString = function getSingleMetricAsString(name) {
return getMetricAsPrometheusString(metrics[name]);
};
var getSingleMetric = function getSingleMetric(name) {

@@ -85,3 +93,4 @@ return metrics[name];

getSingleMetric: getSingleMetric,
getSingleMetricAsString: getSingleMetricAsString,
contentType: 'text/plain; version=0.0.4; charset=utf-8'
};
{
"name": "prom-client",
"version": "8.0.0",
"version": "8.1.0",
"description": "Client for prometheus",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -204,2 +204,6 @@ # Prometheus client for node.js [![Build Status](https://travis-ci.org/siimon/prom-client.svg?branch=master)](https://travis-ci.org/siimon/prom-client) [![Build status](https://ci.appveyor.com/api/projects/status/k2e0gwonkcee3lp9/branch/master?svg=true)](https://ci.appveyor.com/project/siimon/prom-client/branch/master)

##### Geting a single metric for Prometheus displaying
If you need to output a single metric for Prometheus, you can use `register.getSingleMetricAsString(*name of metric*)`, it will output a string for Prometheus to consume.
##### Getting a single metric

@@ -216,3 +220,3 @@

It is possible to push metrics via a [Pushgateway](https://github.com/prometheus/pushgateway).
It is possible to push metrics via a [Pushgateway](https://github.com/prometheus/pushgateway).

@@ -237,3 +241,3 @@ ```js

For convenience, there are 2 bucket generator functions - linear and exponential.
For convenience, there are 2 bucket generator functions - linear and exponential.

@@ -240,0 +244,0 @@ ```js

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc