prom-client
Advanced tools
Comparing version 3.4.2 to 3.4.3
@@ -10,2 +10,3 @@ /** | ||
var createValue = require('./util').incValue; | ||
var hashObject = require('./util').hashObject; | ||
var validateLabels = require('./validation').validateLabel; | ||
@@ -57,2 +58,3 @@ var validateMetricName = require('./validation').validateMetricName; | ||
} | ||
return inc.call(this, labels)(value); | ||
@@ -71,10 +73,11 @@ }; | ||
Counter.prototype.labels = function() { | ||
var labels = getLabels(this.labelNames, arguments); | ||
var labels = getLabels(this.labelNames, arguments) || {}; | ||
var hash = hashObject(labels); | ||
validateLabels(this.labelNames, labels); | ||
return { | ||
inc: inc.call(this, labels) | ||
inc: inc.call(this, labels, hash) | ||
}; | ||
}; | ||
var inc = function(labels) { | ||
var inc = function(labels, hash) { | ||
var that = this; | ||
@@ -88,6 +91,6 @@ return function(value) { | ||
} | ||
labels = labels || {}; | ||
validateLabels(that.labelNames, labels); | ||
that.hashMap = createValue(that.hashMap, value || 1, labels); | ||
that.hashMap = createValue(that.hashMap, value || 1, labels, hash); | ||
}; | ||
@@ -94,0 +97,0 @@ }; |
@@ -12,4 +12,3 @@ 'use strict'; | ||
exports.incValue = function createValue(hashMap, value, labels) { | ||
var hash = hashObject(labels); | ||
exports.incValue = function createValue(hashMap, value, labels, hash) { | ||
if(hashMap[hash]){ | ||
@@ -16,0 +15,0 @@ hashMap[hash].value += value || 1; |
{ | ||
"name": "prom-client", | ||
"version": "3.4.2", | ||
"version": "3.4.3", | ||
"description": "Client for prometheus", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -21,9 +21,2 @@ 'use strict'; | ||
it('should not allow non numbers', function() { | ||
var fn = function() { | ||
instance.inc('asd'); | ||
}; | ||
expect(fn).to.throw(Error); | ||
}); | ||
it('should not be possible to decrease a counter', function() { | ||
@@ -30,0 +23,0 @@ var fn = function() { |
Sorry, the diff of this file is not supported yet
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
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
65333
1526