prom-client
Advanced tools
Comparing version 3.0.1 to 3.0.2
@@ -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() { |
@@ -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; | ||
}, []); | ||
} | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44305
19
966
1