Skip to content

Commit 033cfc9

Browse files
authored
Bugfix: clone labels when interpolating metric name (#235)
When the log metrics output is first in line, `metrics.utils.formatLabels` will mutate the labels array. This mutation will leak to the other metrics clients and manifest as an Invalid number of arguments in prom-client. Bump to 2.8.2 Bug: T278141
1 parent cd92380 commit 033cfc9

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

lib/metrics/utils/index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,16 @@ function zipLabels(options, labels) {
2828

2929
// Formats label set with metric name
3030
function formatLabels(options, labels) {
31+
let formattedLabels = [...labels];
3132
if (options.labels.names) {
32-
labels = zipLabels(options, labels);
33+
formattedLabels = zipLabels(options, formattedLabels);
3334
}
3435
if (options.labels.labelPosition === 'before') {
35-
labels.push(options.name);
36+
formattedLabels.push(options.name);
3637
} else {
37-
labels.unshift(options.name);
38+
formattedLabels.unshift(options.name);
3839
}
39-
return labels;
40+
return formattedLabels;
4041
}
4142

4243
module.exports.normalizeName = normalizeName;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "service-runner",
3-
"version": "2.8.1",
3+
"version": "2.8.2",
44
"description": "Generic nodejs service supervisor / cluster runner",
55
"main": "service-runner.js",
66
"bin": {

0 commit comments

Comments
 (0)