Commit 8d8d3514 authored by Clarakosi's avatar Clarakosi Committed by Petr Pchelko
Browse files

Move static label normalization to constructor

parent e661dbd0
......@@ -14,6 +14,7 @@ class PrometheusMetric {
if (Object.keys(this.staticLabels).length > 0) {
Object.keys(this.staticLabels).forEach((name) => {
options.labels.names.unshift(name);
this.staticLabels[name] = this._normalize(this.staticLabels[name]);
});
}
}
......@@ -32,9 +33,8 @@ class PrometheusMetric {
_handleStaticLabels(labels) {
if (this.staticLabels !== undefined) {
Object.keys(this.staticLabels).forEach((name) => {
const normalizedLabel = this._normalize(this.staticLabels[name]);
if (labels.indexOf(normalizedLabel) === -1) {
labels.unshift(normalizedLabel);
if (labels.indexOf(this.staticLabels[name]) === -1) {
labels.unshift(this.staticLabels[name]);
}
});
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment