grafana/public/app/plugins/datasource/jaeger/util.ts
Zoltán Bedi 1a504ce673
Jaeger: Search traces (#32805)
* WIP: Search jaeger traces

* Add more customizable query params

* Fix failing test

* Fix e2e test

* Add tags input field

* Minor changes

* Fix tests

* Add docs

* Make sure linking is working

* Add tests to datasource.ts

* Apply suggestions from code review

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>

* Update Jaeger doc

* UI updates

* Address review comments

* Add new screenshots to docs

* Update placeholder text for tags

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
2021-05-11 10:38:10 +02:00

27 lines
536 B
TypeScript

import logfmt from 'logfmt';
export function convertTagsLogfmt(tags: string | undefined) {
if (!tags) {
return '';
}
const data: any = logfmt.parse(tags);
Object.keys(data).forEach((key) => {
const value = data[key];
if (typeof value !== 'string') {
data[key] = String(value);
}
});
return JSON.stringify(data);
}
export function transformToLogfmt(tags: string | undefined) {
if (!tags) {
return '';
}
try {
return logfmt.stringify(JSON.parse(tags));
} catch {
return tags;
}
}