From 64e9c38b66eda0a14952fcd8127df6fd6d16a104 Mon Sep 17 00:00:00 2001 From: Joey <90795735+joey-grafana@users.noreply.github.com> Date: Thu, 30 Jan 2025 15:14:38 +0000 Subject: [PATCH] Tempo: Show consistently named links for external reference types (#99008) * Show consistently named links for external reference types * Update betterer --- .betterer.results | 4 +--- .../TraceView/components/types/trace.ts | 2 +- .../explore/TraceView/createSpanLink.tsx | 19 +++++++++++++++---- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.betterer.results b/.betterer.results index bc0dd082f2a..26eff410c4f 100644 --- a/.betterer.results +++ b/.betterer.results @@ -5021,9 +5021,7 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "1"], [0, 0, 0, "No untranslated strings in text props. Wrap text with or use t()", "2"], [0, 0, 0, "No untranslated strings in text props. Wrap text with or use t()", "3"], - [0, 0, 0, "No untranslated strings in text props. Wrap text with or use t()", "4"], - [0, 0, 0, "No untranslated strings in text props. Wrap text with or use t()", "5"], - [0, 0, 0, "No untranslated strings in text props. Wrap text with or use t()", "6"] + [0, 0, 0, "No untranslated strings in text props. Wrap text with or use t()", "4"] ], "public/app/features/explore/extensions/ConfirmNavigationModal.tsx:5381": [ [0, 0, 0, "No untranslated strings. Wrap text with ", "0"], diff --git a/public/app/features/explore/TraceView/components/types/trace.ts b/public/app/features/explore/TraceView/components/types/trace.ts index 0c38b7ba584..3c7dc4733e5 100644 --- a/public/app/features/explore/TraceView/components/types/trace.ts +++ b/public/app/features/explore/TraceView/components/types/trace.ts @@ -29,7 +29,7 @@ export type TraceProcess = { }; export type TraceSpanReference = { - refType: 'CHILD_OF' | 'FOLLOWS_FROM'; + refType: 'CHILD_OF' | 'FOLLOWS_FROM' | 'EXTERNAL'; // eslint-disable-next-line no-use-before-define span?: TraceSpan | null | undefined; spanID: string; diff --git a/public/app/features/explore/TraceView/createSpanLink.tsx b/public/app/features/explore/TraceView/createSpanLink.tsx index 43024dd7cd7..662876c3b21 100644 --- a/public/app/features/explore/TraceView/createSpanLink.tsx +++ b/public/app/features/explore/TraceView/createSpanLink.tsx @@ -29,6 +29,7 @@ import { ExploreFieldLinkModel, getFieldLinksForExplore, getVariableUsageInfo } import { SpanLinkDef, SpanLinkFunc, Trace, TraceSpan } from './components'; import { SpanLinkType } from './components/types/links'; +import { TraceSpanReference } from './components/types/trace'; /** * This is a factory for the link creator. It returns the function mainly so it can return undefined in which case @@ -323,11 +324,12 @@ function legacyCreateSpanLinkFactory( } const link = createFocusSpanLink(reference.traceID, reference.spanID); + const title = getReferenceTitle(reference); links!.push({ href: link.href, - title: reference.span ? reference.span.operationName : 'View linked span', - content: , + title, + content: , onClick: link.onClick, field: link.origin, type: SpanLinkType.Traces, @@ -338,11 +340,12 @@ function legacyCreateSpanLinkFactory( if (span.subsidiarilyReferencedBy && createFocusSpanLink) { for (const reference of span.subsidiarilyReferencedBy) { const link = createFocusSpanLink(reference.traceID, reference.spanID); + const title = getReferenceTitle(reference); links!.push({ href: link.href, - title: reference.span ? reference.span.operationName : 'View linked span', - content: , + title, + content: , onClick: link.onClick, field: link.origin, type: SpanLinkType.Traces, @@ -366,6 +369,14 @@ function legacyCreateSpanLinkFactory( }; } +const getReferenceTitle = (reference: TraceSpanReference) => { + let title = reference.span ? reference.span.operationName : 'View linked span'; + if (reference.refType === 'EXTERNAL') { + title = 'View linked span'; + } + return title; +}; + function getQueryForLoki( span: TraceSpan, options: TraceToLogsOptionsV2,