diff --git a/public/app/plugins/datasource/tempo/datasource.test.ts b/public/app/plugins/datasource/tempo/datasource.test.ts index 6b46d252b8f..957eefec24a 100644 --- a/public/app/plugins/datasource/tempo/datasource.test.ts +++ b/public/app/plugins/datasource/tempo/datasource.test.ts @@ -724,12 +724,14 @@ describe('Tempo service graph view', () => { '/actuator/health/**', '$type + [test]|HTTP POST - post', 'server.cluster.local:9090^/sample.test(.*)?', + 'test\\path', ]; let escaped = getEscapedSpanNames(spanNames); expect(escaped).toEqual([ '/actuator/health/\\\\*\\\\*', '\\\\$type \\\\+ \\\\[test\\\\]\\\\|HTTP POST - post', 'server\\\\.cluster\\\\.local:9090\\\\^/sample\\\\.test\\\\(\\\\.\\\\*\\\\)\\\\?', + 'test\\\\\\\\path', ]); }); diff --git a/public/app/plugins/datasource/tempo/datasource.ts b/public/app/plugins/datasource/tempo/datasource.ts index a453700ed83..04b3ac936e1 100644 --- a/public/app/plugins/datasource/tempo/datasource.ts +++ b/public/app/plugins/datasource/tempo/datasource.ts @@ -955,8 +955,10 @@ function makePromLink(title: string, expr: string, datasourceUid: string, instan }; } +// TODO: this is basically the same as prometheus/datasource.ts#prometheusSpecialRegexEscape which is used to escape +// template variable values. It would be best to move it to some common place. export function getEscapedSpanNames(values: string[]) { - return values.map((value: string) => value.replace(/[.*+?^${}()|[\]\\]/g, '\\\\$&')); + return values.map((value: string) => value.replace(/\\/g, '\\\\\\\\').replace(/[$^*{}\[\]\'+?.()|]/g, '\\\\$&')); } export function getFieldConfig(