Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
repos
security
Test - Service Runner Fork - NodeJS
Commits
8d8d3514
Commit
8d8d3514
authored
Nov 16, 2020
by
Clarakosi
Committed by
Petr Pchelko
Nov 17, 2020
Browse files
Move static label normalization to constructor
parent
e661dbd0
Changes
1
Hide whitespace changes
Inline
Side-by-side
lib/metrics/prometheus.js
View file @
8d8d3514
...
...
@@ -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
]);
}
});
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment