better escape prometheus label values (#63)
This commit is contained in:
parent
be7c5151cc
commit
58ffb74b3e
|
@ -181,7 +181,15 @@ fn key_to_parts(key: Key) -> (String, Vec<String>) {
|
|||
let labels = labels
|
||||
.into_iter()
|
||||
.map(Label::into_parts)
|
||||
.map(|(k, v)| format!("{}=\"{}\"", k, v.escape_default().collect::<String>()))
|
||||
.map(|(k, v)| {
|
||||
format!(
|
||||
"{}=\"{}\"",
|
||||
k,
|
||||
v.replace("\\", "\\\\")
|
||||
.replace("\"", "\\\"")
|
||||
.replace("\n", "\\n")
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
|
||||
(name, labels)
|
||||
|
|
Loading…
Reference in New Issue