Loki: do not special-case __name__ label (#47251)

* loki: do not mutate the caller's data

* Update public/app/plugins/datasource/loki/result_transformer.ts

better comment

Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>

* Update public/app/plugins/datasource/loki/result_transformer.ts

no need to handle __name__

Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>

* simplify code

Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>
This commit is contained in:
Gábor Farkas 2022-04-04 13:52:55 +02:00 committed by GitHub
parent 659cf17e10
commit fdb7bab41a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -290,12 +290,10 @@ export function createMetricLabel(labelData: { [key: string]: string }, options?
}
function getOriginalMetricName(labelData: { [key: string]: string }) {
const metricName = labelData.__name__ || '';
delete labelData.__name__;
const labelPart = Object.entries(labelData)
.map((label) => `${label[0]}="${label[1]}"`)
.join(',');
return `${metricName}{${labelPart}}`;
return `{${labelPart}}`;
}
export function decamelize(s: string): string {