Socket
Socket
Sign inDemoInstall

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 3.0.1 to 3.0.2

LICENSE

5

example/server.js

@@ -16,5 +16,6 @@ 'use strict';

setInterval(function() {
setTimeout(function() {
h.labels('200').observe(Math.random());
}, 1000);
h.labels('300').observe(Math.random());
}, 10);

@@ -21,0 +22,0 @@ setInterval(function() {

7

lib/histogram.js

@@ -16,2 +16,3 @@ /**

var validateLabelNames = require('./validation').validateLabelName;
var objectHash = require('object-hash');

@@ -48,2 +49,3 @@ /**

Object.freeze(this.bucketValues);
Object.freeze(this.upperBounds);

@@ -175,7 +177,6 @@ this.sum = 0;

var objectHash = require('object-hash');
var hash = objectHash(labelValuePair.labels);
var valueFromMap = histogram.hashMap[hash];
if(!valueFromMap) {
valueFromMap = createBaseValues(labelValuePair.labels, histogram.bucketValues);
valueFromMap = createBaseValues(labelValuePair.labels, extend({}, histogram.bucketValues));
}

@@ -188,3 +189,3 @@

if(histogram.bucketValues.hasOwnProperty(b)) {
if(valueFromMap.bucketValues.hasOwnProperty(b)) {
valueFromMap.bucketValues[b] += 1;

@@ -191,0 +192,0 @@ }

{
"name": "prom-client",
"version": "3.0.1",
"version": "3.0.2",
"description": "Client for prometheus",

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

@@ -55,2 +55,10 @@ 'use strict';

});
it('should group counts on each label set', function() {
var histogram = new Histogram('test_histogram', 'test', [ 'code' ]);
histogram.observe({ code: '200' }, 1);
histogram.observe({ code: '300' }, 1);
var values = getValuesByLabel(1, histogram.get().values);
expect(values[0].value).to.equal(1);
expect(values[1].value).to.equal(1);
});

@@ -148,2 +156,10 @@ it('should time requests', function() {

}
function getValuesByLabel(label, values, key) {
return values.reduce(function(acc, val) {
if(val.labels && val.labels[key || 'le'] === label) {
acc.push(val);
}
return acc;
}, []);
}
});
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