Tempo: Create trace to logs links with traces in structured metadata (#93923)

This commit is contained in:
Sven Grossmann 2024-09-27 18:11:09 +02:00 committed by GitHub
parent f3ba16d3b7
commit 157ded7c3f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 3 deletions

View File

@ -200,7 +200,7 @@ describe('createSpanLinkFactory', () => {
datasource: 'loki1_uid',
queries: [
{
expr: '{cluster="cluster1", hostname="hostname1", service_namespace="namespace1"} |="7946b05c2e2e4e5a" |="6605c7b08e715d6c"',
expr: '{cluster="cluster1", hostname="hostname1", service_namespace="namespace1"} | label_format log_line_contains_trace_id=`{{ contains "7946b05c2e2e4e5a" __line__ }}` | log_line_contains_trace_id="true" OR trace_id="7946b05c2e2e4e5a" | label_format log_line_contains_span_id=`{{ contains "6605c7b08e715d6c" __line__ }}` | log_line_contains_span_id="true" OR span_id="6605c7b08e715d6c"',
refId: '',
},
],

View File

@ -384,10 +384,12 @@ function getQueryForLoki(
let expr = '{${__tags}}';
if (filterByTraceID && span.traceID) {
expr += ' |="${__span.traceId}"';
expr +=
' | label_format log_line_contains_trace_id=`{{ contains "${__span.traceId}" __line__ }}` | log_line_contains_trace_id="true" OR trace_id="${__span.traceId}"';
}
if (filterBySpanID && span.spanID) {
expr += ' |="${__span.spanId}"';
expr +=
' | label_format log_line_contains_span_id=`{{ contains "${__span.spanId}" __line__ }}` | log_line_contains_span_id="true" OR span_id="${__span.spanId}"';
}
return {