You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wa...@apache.org on 2026/10/14 08:45:44 UTC
(skywalking-horizon-ui) branch main updated: feat(widgets): open a record's trace from the store that holds it (#195)
This is an automated email from the ASF dual-hosted git repository.
wankai123 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-horizon-ui.git
The following commit(s) were added to refs/heads/main by this push:
new 1616ad55 feat(widgets): open a record's trace from the store that holds it (#195)
1616ad55 is described below
commit 1616ad55c12c992798fa3e1bb5284a6a77b78909
Author: Wan Kai <wa...@foxmail.com>
AuthorDate: Wed Oct 14 16:45:38 2026 +0800
feat(widgets): open a record's trace from the store that holds it (#195)
---
.../layers/otlp_virtual_database.i18n.de.json | 2 +-
.../layers/otlp_virtual_database.i18n.es.json | 2 +-
.../layers/otlp_virtual_database.i18n.fr.json | 2 +-
.../layers/otlp_virtual_database.i18n.ja.json | 2 +-
.../layers/otlp_virtual_database.i18n.ko.json | 2 +-
.../layers/otlp_virtual_database.i18n.pt.json | 2 +-
.../layers/otlp_virtual_database.i18n.zh-CN.json | 2 +-
.../layers/otlp_virtual_database.json | 3 +-
apps/bff/src/http/admin/template-sync.test.ts | 110 +++++++++++++++++++++
apps/bff/src/http/admin/template-sync.ts | 18 ++++
apps/bff/src/logic/dashboard/schema.ts | 7 ++
apps/bff/src/logic/templates/bundled-schema.ts | 42 ++++++++
.../src/logic/templates/bundled-validate.test.ts | 24 +++++
apps/ui/src/ai/ChatWidgetRenderer.vue | 1 +
.../admin/layer-templates/WidgetEditorCanvas.vue | 30 +++++-
apps/ui/src/i18n/locales/de.json | 6 +-
apps/ui/src/i18n/locales/en.json | 6 +-
apps/ui/src/i18n/locales/es.json | 6 +-
apps/ui/src/i18n/locales/fr.json | 6 +-
apps/ui/src/i18n/locales/ja.json | 6 +-
apps/ui/src/i18n/locales/ko.json | 6 +-
apps/ui/src/i18n/locales/pt.json | 6 +-
apps/ui/src/i18n/locales/zh-CN.json | 6 +-
apps/ui/src/layer/traceql/TraceQLTracePopout.vue | 57 +++++++++++
.../layer/traceql/useTraceQLTracePopout.test.ts | 64 ++++++++++++
apps/ui/src/layer/traceql/useTraceQLTracePopout.ts | 60 +++++++++++
.../src/render/layer-dashboard/LayerWidgetTile.vue | 1 +
apps/ui/src/render/widgets/RecordList.test.ts | 102 +++++++++++++++++++
apps/ui/src/render/widgets/RecordList.vue | 30 +++++-
apps/ui/src/render/widgets/TabWidget.vue | 1 +
apps/ui/src/shell/AppShell.vue | 3 +
docs/changelog/1.1.0.md | 2 +
docs/components/dashboard-widgets.md | 26 ++++-
docs/customization/layer-templates.md | 18 ++++
docs/dashboards/otlp_virtual_database.md | 2 +-
packages/api-client/src/dashboard.ts | 11 +++
packages/api-client/src/index.ts | 1 +
37 files changed, 653 insertions(+), 22 deletions(-)
diff --git a/apps/bff/src/bundled_templates/layers/otlp_virtual_database.i18n.de.json b/apps/bff/src/bundled_templates/layers/otlp_virtual_database.i18n.de.json
index cc3235ba..915c8124 100644
--- a/apps/bff/src/bundled_templates/layers/otlp_virtual_database.i18n.de.json
+++ b/apps/bff/src/bundled_templates/layers/otlp_virtual_database.i18n.de.json
@@ -37,7 +37,7 @@
{
"id": "slow_statements",
"title": "Langsame Anweisungen",
- "tip": "Die 20 langsamsten Statements, die die Regel `otlp-slow-sql` für diese Datenbank aufgezeichnet hat, in ms. Jede Zeile ist eine Statement-Ausführung; zum Kopieren anklicken."
+ "tip": "Die 20 langsamsten Statements, die die Regel `otlp-slow-sql` für diese Datenbank aufgezeichnet hat, in ms. Jede Zeile ist eine Statement-Ausführung; zum Kopieren anklicken oder über das Trace-Symbol am Zeilenanfang den Trace öffnen."
}
]
}
diff --git a/apps/bff/src/bundled_templates/layers/otlp_virtual_database.i18n.es.json b/apps/bff/src/bundled_templates/layers/otlp_virtual_database.i18n.es.json
index 3103d58c..93e4d478 100644
--- a/apps/bff/src/bundled_templates/layers/otlp_virtual_database.i18n.es.json
+++ b/apps/bff/src/bundled_templates/layers/otlp_virtual_database.i18n.es.json
@@ -37,7 +37,7 @@
{
"id": "slow_statements",
"title": "Statements lentos",
- "tip": "Las 20 sentencias más lentas que la regla `otlp-slow-sql` registró contra esta base de datos, en ms. Cada fila es una ejecución de sentencia; haga clic para copiarla."
+ "tip": "Las 20 sentencias más lentas que la regla `otlp-slow-sql` registró contra esta base de datos, en ms. Cada fila es una ejecución de sentencia; haga clic para copiarla o use el icono de traza al inicio de la fila para abrir su traza."
}
]
}
diff --git a/apps/bff/src/bundled_templates/layers/otlp_virtual_database.i18n.fr.json b/apps/bff/src/bundled_templates/layers/otlp_virtual_database.i18n.fr.json
index 09f3c58d..20a70380 100644
--- a/apps/bff/src/bundled_templates/layers/otlp_virtual_database.i18n.fr.json
+++ b/apps/bff/src/bundled_templates/layers/otlp_virtual_database.i18n.fr.json
@@ -37,7 +37,7 @@
{
"id": "slow_statements",
"title": "Requêtes lentes",
- "tip": "Les 20 instructions les plus lentes que la règle `otlp-slow-sql` a enregistrées pour cette base de données, en ms. Chaque ligne est une exécution d'instruction ; cliquez pour la copier."
+ "tip": "Les 20 instructions les plus lentes que la règle `otlp-slow-sql` a enregistrées pour cette base de données, en ms. Chaque ligne est une exécution d'instruction ; cliquez pour la copier, ou utilisez l'icône de trace en tête de ligne pour ouvrir sa trace."
}
]
}
diff --git a/apps/bff/src/bundled_templates/layers/otlp_virtual_database.i18n.ja.json b/apps/bff/src/bundled_templates/layers/otlp_virtual_database.i18n.ja.json
index 4a62de51..dc8f7a31 100644
--- a/apps/bff/src/bundled_templates/layers/otlp_virtual_database.i18n.ja.json
+++ b/apps/bff/src/bundled_templates/layers/otlp_virtual_database.i18n.ja.json
@@ -37,7 +37,7 @@
{
"id": "slow_statements",
"title": "低速ステートメント",
- "tip": "`otlp-slow-sql` ルールがこのデータベースに対して記録した最も遅い 20 ステートメント (ms)。各行は 1 回のステートメント実行です。クリックするとコピーできます。"
+ "tip": "`otlp-slow-sql` ルールがこのデータベースに対して記録した最も遅い 20 ステートメント (ms)。各行は 1 回のステートメント実行です。クリックするとコピーでき、行頭のトレースアイコンからトレースを開けます。"
}
]
}
diff --git a/apps/bff/src/bundled_templates/layers/otlp_virtual_database.i18n.ko.json b/apps/bff/src/bundled_templates/layers/otlp_virtual_database.i18n.ko.json
index b8e93806..c8a95ee5 100644
--- a/apps/bff/src/bundled_templates/layers/otlp_virtual_database.i18n.ko.json
+++ b/apps/bff/src/bundled_templates/layers/otlp_virtual_database.i18n.ko.json
@@ -37,7 +37,7 @@
{
"id": "slow_statements",
"title": "느린 구문",
- "tip": "`otlp-slow-sql` 규칙이 이 데이터베이스에 대해 기록한 가장 느린 20개 구문(ms)입니다. 각 행은 구문 실행 1회이며, 클릭하면 복사됩니다."
+ "tip": "`otlp-slow-sql` 규칙이 이 데이터베이스에 대해 기록한 가장 느린 20개 구문(ms)입니다. 각 행은 구문 실행 1회이며, 클릭하면 복사되고 행 머리의 트레이스 아이콘으로 해당 트레이스를 열 수 있습니다."
}
]
}
diff --git a/apps/bff/src/bundled_templates/layers/otlp_virtual_database.i18n.pt.json b/apps/bff/src/bundled_templates/layers/otlp_virtual_database.i18n.pt.json
index 82670ed3..bdb0de01 100644
--- a/apps/bff/src/bundled_templates/layers/otlp_virtual_database.i18n.pt.json
+++ b/apps/bff/src/bundled_templates/layers/otlp_virtual_database.i18n.pt.json
@@ -37,7 +37,7 @@
{
"id": "slow_statements",
"title": "Statements lentos",
- "tip": "As 20 instruções mais lentas que a regra `otlp-slow-sql` registrou para este banco de dados, em ms. Cada linha é uma execução de instrução; clique para copiá-la."
+ "tip": "As 20 instruções mais lentas que a regra `otlp-slow-sql` registrou para este banco de dados, em ms. Cada linha é uma execução de instrução; clique para copiá-la ou use o ícone de trace no início da linha para abrir seu trace."
}
]
}
diff --git a/apps/bff/src/bundled_templates/layers/otlp_virtual_database.i18n.zh-CN.json b/apps/bff/src/bundled_templates/layers/otlp_virtual_database.i18n.zh-CN.json
index 1d1e5b61..bcc902dd 100644
--- a/apps/bff/src/bundled_templates/layers/otlp_virtual_database.i18n.zh-CN.json
+++ b/apps/bff/src/bundled_templates/layers/otlp_virtual_database.i18n.zh-CN.json
@@ -37,7 +37,7 @@
{
"id": "slow_statements",
"title": "慢语句",
- "tip": "`otlp-slow-sql` 规则针对该数据库记录的最慢 20 条语句,单位 ms。每行为一次语句执行;点击可复制。"
+ "tip": "`otlp-slow-sql` 规则针对该数据库记录的最慢 20 条语句,单位 ms。每行为一次语句执行;点击可复制,或使用行首的追踪图标打开其追踪。"
}
]
}
diff --git a/apps/bff/src/bundled_templates/layers/otlp_virtual_database.json b/apps/bff/src/bundled_templates/layers/otlp_virtual_database.json
index 6e1b3e98..142378d8 100644
--- a/apps/bff/src/bundled_templates/layers/otlp_virtual_database.json
+++ b/apps/bff/src/bundled_templates/layers/otlp_virtual_database.json
@@ -83,9 +83,10 @@
{
"id": "slow_statements",
"title": "Slow Statements",
- "tip": "Top 20 slowest statements the `otlp-slow-sql` rule recorded against this database, in ms. Each row is one statement execution; click to copy it.",
+ "tip": "Top 20 slowest statements the `otlp-slow-sql` rule recorded against this database, in ms. Each row is one statement execution; click to copy it, or use the trace icon at the row head to open its trace.",
"type": "record",
"unit": "ms",
+ "recordTrace": { "source": "traceql-otlp" },
"expressions": [
"top_n(top_n_database_statement, 20, des)"
],
diff --git a/apps/bff/src/http/admin/template-sync.test.ts b/apps/bff/src/http/admin/template-sync.test.ts
index ea463318..01ab1b69 100644
--- a/apps/bff/src/http/admin/template-sync.test.ts
+++ b/apps/bff/src/http/admin/template-sync.test.ts
@@ -1413,3 +1413,113 @@ describe('POST /api/admin/templates/validate — the save checks, without saving
await app.close();
});
});
+
+describe('a record widget trace store reaching OAP', () => {
+ beforeEach(() => resync());
+
+ function withRecord(recordTrace: unknown, type = 'record'): Json {
+ const content = validLayer('GENERAL');
+ ((content.dashboards as Json).service as Json[]).push({
+ id: 'slow',
+ title: 'Slow statements',
+ type,
+ expressions: ['top_n(top_n_database_statement, 20, des)'],
+ span: 6,
+ rowSpan: 2,
+ recordTrace,
+ });
+ return content;
+ }
+
+ it('publishes a store on a record widget', async () => {
+ const store = makeStore();
+ const { app, cookie: c } = await buildApp(store.fetchImpl);
+ const res = await post(app, '/api/admin/templates/save', c, {
+ name: 'horizon.layer.GENERAL',
+ content: withRecord({ source: 'traceql-otlp' }),
+ });
+ expect(res.statusCode).toBe(200);
+ expect(store.writes).toEqual([{ op: 'create', id: 'horizon.layer.GENERAL' }]);
+ await app.close();
+ });
+
+ it('refuses a store on a widget that is not a record', async () => {
+ const store = makeStore();
+ const { app, cookie: c } = await buildApp(store.fetchImpl);
+ const res = await post(app, '/api/admin/templates/save', c, {
+ name: 'horizon.layer.GENERAL',
+ content: withRecord({ source: 'native' }, 'top'),
+ });
+ expect(res.statusCode).toBe(400);
+ expect((res.json() as { issues: string[] }).issues).toContain(
+ 'dashboards.service.1.recordTrace: `recordTrace` applies to `record` widgets only',
+ );
+ expect(store.writes).toEqual([]);
+ await app.close();
+ });
+
+ // The read path takes it as absent, so storing it would publish a choice
+ // that never takes effect.
+ it('refuses a malformed store instead of storing it', async () => {
+ const store = makeStore();
+ const { app, cookie: c } = await buildApp(store.fetchImpl);
+ const res = await post(app, '/api/admin/templates/save', c, {
+ name: 'horizon.layer.GENERAL',
+ content: withRecord({ source: 'otlp' }),
+ });
+ expect(res.statusCode).toBe(400);
+ const issues = (res.json() as { issues: string[] }).issues;
+ expect(issues.some((i) => i.startsWith('dashboards.service.1.recordTrace: malformed `recordTrace`'))).toBe(true);
+ expect(store.writes).toEqual([]);
+ await app.close();
+ });
+
+ it('refuses a malformed store on a widget inside a tab', async () => {
+ const store = makeStore();
+ const { app, cookie: c } = await buildApp(store.fetchImpl);
+ const content = validLayer('GENERAL');
+ ((content.dashboards as Json).service as Json[]).push({
+ id: 'w2',
+ title: 'Tabs',
+ type: 'tab',
+ expressions: [],
+ span: 6,
+ rowSpan: 4,
+ tabs: [
+ {
+ name: 'Slow',
+ widgets: [
+ {
+ id: 'w2_slow',
+ title: 'Slow statements',
+ type: 'record',
+ expressions: ['top_n(top_n_database_statement, 20, des)'],
+ span: 6,
+ rowSpan: 2,
+ recordTrace: 'traceql-otlp',
+ },
+ ],
+ },
+ ],
+ });
+ const res = await post(app, '/api/admin/templates/save', c, { name: 'horizon.layer.GENERAL', content });
+ expect(res.statusCode).toBe(400);
+ const issues = (res.json() as { issues: string[] }).issues;
+ expect(issues.some((i) => i.startsWith('dashboards.service.1.tabs.0.widgets.0.recordTrace: malformed'))).toBe(true);
+ await app.close();
+ });
+
+ it('answers the malformed store to an import check, with its path', async () => {
+ const store = makeStore();
+ const { app, cookie: c } = await buildApp(store.fetchImpl);
+ const res = await post(app, '/api/admin/templates/validate', c, {
+ name: 'horizon.layer.GENERAL',
+ content: withRecord({ source: 'otlp' }),
+ });
+ expect(res.statusCode).toBe(200);
+ const { problems } = res.json() as { problems: Array<{ path: Array<string | number> }> };
+ expect(problems.map((p) => p.path)).toEqual([['dashboards', 'service', 1, 'recordTrace']]);
+ expect(store.writes).toEqual([]);
+ await app.close();
+ });
+});
diff --git a/apps/bff/src/http/admin/template-sync.ts b/apps/bff/src/http/admin/template-sync.ts
index fe62a63c..4e9c33e2 100644
--- a/apps/bff/src/http/admin/template-sync.ts
+++ b/apps/bff/src/http/admin/template-sync.ts
@@ -64,6 +64,7 @@
import type { FastifyInstance, FastifyReply, FastifyRequest } from 'fastify';
import type { ZodError, ZodType } from 'zod';
import type { UITemplateClient } from '@skywalking-horizon-ui/api-client';
+import { TRACE_STORES } from '@skywalking-horizon-ui/api-client';
import type { AuthDeps } from '../../user/middleware.js';
import { requireAuth } from '../../user/middleware.js';
import { sessionHasVerb } from '../../rbac/policy.js';
@@ -106,6 +107,7 @@ import {
overviewTemplatePushSchema,
themeTemplateSchema,
timeDefaultsTemplateSchema,
+ widgetEntries,
} from '../../logic/templates/bundled-schema.js';
import { templateIdentityIssue } from '../../logic/templates/identity.js';
import { logger } from '../../logger.js';
@@ -931,6 +933,7 @@ function publishProblems(
path: dottedPath(i.path),
message: i.message,
}));
+ problems.push(...malformedRecordTraces(content, v.data));
// The domain half of the link policy needs config, so it cannot live in
// the schema. Applying it HERE too means a publish is refused with the
// reason instead of succeeding and then vanishing on the read path.
@@ -960,6 +963,21 @@ function publishProblems(
return [];
}
+/**
+ * The widget schema reads a bad `recordTrace` as absent, so a stored one only
+ * falls back to the layer's own popout. Publishing it would store a choice
+ * that never takes effect, so compare each raw widget with its parsed one.
+ */
+function malformedRecordTraces(raw: unknown, parsed: unknown): TemplateProblem[] {
+ const parsedByPath = new Map(widgetEntries(parsed).map((e) => [e.path, e.w]));
+ return widgetEntries(raw)
+ .filter(({ path, w }) => w.recordTrace !== undefined && parsedByPath.get(path)?.recordTrace === undefined)
+ .map(({ path }) => ({
+ path: dottedPath(`${path}.recordTrace`),
+ message: `malformed \`recordTrace\` — expected { "source": "<trace store>" }, with ${TRACE_STORES.join(', ')}`,
+ }));
+}
+
/** {@link publishProblems} in the `<path>: <message>` form every publish route
* answers 400 `invalid_content` with, or `null` when the content publishes. */
function publishIssues(
diff --git a/apps/bff/src/logic/dashboard/schema.ts b/apps/bff/src/logic/dashboard/schema.ts
index 098eb3a5..8d4bd141 100644
--- a/apps/bff/src/logic/dashboard/schema.ts
+++ b/apps/bff/src/logic/dashboard/schema.ts
@@ -78,6 +78,13 @@ const leafWidgetSchema = z.object({
.object({ mode: z.enum(['off', 'latency', 'error']) })
.optional()
.catch(undefined),
+ // Which store a `record` widget's trace ids open in. Tolerant too on read: a
+ // bad value falls back to the layer's own popout (native, or Zipkin on a
+ // Zipkin-only layer); push and import refuse it (`publishProblems`).
+ recordTrace: z
+ .object({ source: z.enum(['native', 'zipkin', 'traceql-native', 'traceql-zipkin', 'traceql-otlp']) })
+ .optional()
+ .catch(undefined),
// Legacy x/y/w/h kept optional for back-compat.
x: z.number().int().min(0).optional(),
y: z.number().int().min(0).optional(),
diff --git a/apps/bff/src/logic/templates/bundled-schema.ts b/apps/bff/src/logic/templates/bundled-schema.ts
index fdccbcd0..7095cb04 100644
--- a/apps/bff/src/logic/templates/bundled-schema.ts
+++ b/apps/bff/src/logic/templates/bundled-schema.ts
@@ -617,6 +617,7 @@ export function layerCrossRefIssues(tpl: PushLayer, opts: { complete: boolean })
}
checkWidgetIds(tpl.widgets as DashboardWidget[] | undefined, 'widgets', add);
checkExtPages(tpl, add);
+ checkRecordTraces(tpl, add);
checkDefaultFilters(tpl, add);
checkMenuOrder(tpl, add);
@@ -906,6 +907,47 @@ function checkWidgetIds(
});
}
+/**
+ * Every widget of a layer template with its dotted path: the scope grids, the
+ * legacy flat list, the extension pages, and the children of each tab panel.
+ * Takes raw content as well as parsed, so a caller can pair the two by path.
+ */
+export function widgetEntries(tpl: unknown): Array<{ path: string; w: Record<string, unknown> }> {
+ const out: Array<{ path: string; w: Record<string, unknown> }> = [];
+ if (!isRecord(tpl)) return out;
+ const walk = (list: unknown, path: string): void => {
+ if (!Array.isArray(list)) return;
+ list.forEach((w, i) => {
+ if (!isRecord(w)) return;
+ out.push({ path: `${path}.${i}`, w });
+ if (!Array.isArray(w.tabs)) return;
+ w.tabs.forEach((tab, ti) => {
+ if (isRecord(tab)) walk(tab.widgets, `${path}.${i}.tabs.${ti}.widgets`);
+ });
+ });
+ };
+ const dashboards = isRecord(tpl.dashboards) ? tpl.dashboards : {};
+ for (const [scope, list] of Object.entries(dashboards)) walk(list, `dashboards.${scope}`);
+ walk(tpl.widgets, 'widgets');
+ const extPages = isRecord(tpl.dashboardExtPages) ? tpl.dashboardExtPages : {};
+ for (const [scope, pages] of Object.entries(extPages)) {
+ if (!Array.isArray(pages)) continue;
+ pages.forEach((page, pi) => {
+ if (isRecord(page)) walk(page.widgets, `dashboardExtPages.${scope}.${pi}.widgets`);
+ });
+ }
+ return out;
+}
+
+/** Only a `record` widget has trace ids for `recordTrace` to place. */
+function checkRecordTraces(tpl: PushLayer, add: (path: string, message: string) => void): void {
+ for (const { path, w } of widgetEntries(tpl)) {
+ if (w.recordTrace !== undefined && w.type !== 'record') {
+ add(`${path}.recordTrace`, '`recordTrace` applies to `record` widgets only');
+ }
+ }
+}
+
function checkHeader(
header: PushHeader,
path: string,
diff --git a/apps/bff/src/logic/templates/bundled-validate.test.ts b/apps/bff/src/logic/templates/bundled-validate.test.ts
index b98981d3..51097943 100644
--- a/apps/bff/src/logic/templates/bundled-validate.test.ts
+++ b/apps/bff/src/logic/templates/bundled-validate.test.ts
@@ -522,3 +522,27 @@ describe('singletonPresenceIssues — the four files the runtime loads by exact
expect(singletonPresenceIssues(root)).toEqual([]);
});
});
+
+describe('validateBundledTemplates — record widget trace store', () => {
+ function recordLayer(recordTrace: unknown, type = 'record'): Record<string, unknown> {
+ return layer({
+ dashboards: {
+ service: [{ id: 'slow', title: 'Slow', type, expressions: ['top_n(top_n_database_statement, 20, des)'], recordTrace }],
+ },
+ });
+ }
+
+ it('accepts a store on a record widget', () => {
+ expect(messages(run({ layers: { demo: recordLayer({ source: 'traceql-otlp' }) } }))).toBe('');
+ });
+
+ it('flags recordTrace on a widget that is not a record', () => {
+ const findings = run({ layers: { demo: recordLayer({ source: 'native' }, 'top') } });
+ expect(messages(findings)).toContain('`recordTrace` applies to `record` widgets only');
+ });
+
+ it('flags an unknown store, tolerated at runtime as the layer\'s own popout', () => {
+ const findings = run({ layers: { demo: recordLayer({ source: 'tempo' }) } });
+ expect(messages(findings)).toContain('malformed `recordTrace`');
+ });
+});
diff --git a/apps/ui/src/ai/ChatWidgetRenderer.vue b/apps/ui/src/ai/ChatWidgetRenderer.vue
index f76e33ec..e23c3b47 100644
--- a/apps/ui/src/ai/ChatWidgetRenderer.vue
+++ b/apps/ui/src/ai/ChatWidgetRenderer.vue
@@ -112,6 +112,7 @@ const noValue = computed<boolean>(() => {
v-else-if="spec.type === 'record'"
:items="result.records ?? []"
:unit="spec.unit"
+ :trace="spec.recordTrace"
/>
<div v-else class="cwr-unsupported">{{ spec.title }}</div>
diff --git a/apps/ui/src/features/admin/layer-templates/WidgetEditorCanvas.vue b/apps/ui/src/features/admin/layer-templates/WidgetEditorCanvas.vue
index 9f7eece3..00d04c79 100644
--- a/apps/ui/src/features/admin/layer-templates/WidgetEditorCanvas.vue
+++ b/apps/ui/src/features/admin/layer-templates/WidgetEditorCanvas.vue
@@ -38,7 +38,7 @@ import type {
DashboardWidget,
DashboardTab,
} from '@skywalking-horizon-ui/api-client';
-import { tracesInclude, collectWidgetIds } from '@skywalking-horizon-ui/api-client';
+import { TRACE_STORES, tracesInclude, collectWidgetIds } from '@skywalking-horizon-ui/api-client';
import { useExtPages } from './useExtPages';
import { useCanvasResize } from './useCanvasResize';
import { useCanvasReorder } from './useCanvasReorder';
@@ -408,6 +408,15 @@ function setWidgetTraceDrill(v: string): void {
if (v === 'latency' || v === 'error' || v === 'off') w.traceDrill = { mode: v };
else delete w.traceDrill;
}
+
+function setWidgetRecordTrace(v: string): void {
+ if (props.readOnly) return;
+ const w = editingWidget.value;
+ if (!w) return;
+ const store = TRACE_STORES.find((s) => s === v);
+ if (store) w.recordTrace = { source: store };
+ else delete w.recordTrace;
+}
const layerTracesEnabled = computed<boolean>(() => {
const tpl = props.draft.template;
return Boolean(tpl?.components?.traces) && tracesInclude(tpl?.traces, 'native');
@@ -1203,6 +1212,25 @@ onBeforeUnmount(() => {
{{ t('Click a datapoint on this widget to open the pre-filtered Traces tab.') }} <code>latency</code> {{ t('⇒ slowest traces ≥ the clicked value;') }} <code>error</code> {{ t('⇒ error-status traces. Centered on the clicked time bucket.') }}
</p>
</div>
+ <div v-if="editingWidget.type === 'record'" class="d-section">
+ <span class="d-label">{{ t('Record trace') }}</span>
+ <div class="d-row">
+ <label>
+ <span>{{ t('Trace store') }}</span>
+ <select
+ :value="editingWidget.recordTrace?.source ?? ''"
+ :disabled="readOnly"
+ @change="setWidgetRecordTrace(($event.target as HTMLSelectElement).value)"
+ >
+ <option value="">{{ t('none — the layer\'s trace popout') }}</option>
+ <option v-for="store in TRACE_STORES" :key="store" :value="store">{{ store }}</option>
+ </select>
+ </label>
+ </div>
+ <p class="d-hint">
+ {{ t("The store this widget's trace ids live in. A row's trace icon opens the trace from it, over the page.") }}
+ </p>
+ </div>
<div class="d-section">
<span class="d-label" :title="visibleWhenHint(activeScope)">
{{ t('Visible when (optional)') }}
diff --git a/apps/ui/src/i18n/locales/de.json b/apps/ui/src/i18n/locales/de.json
index cddbcc22..fc1796ba 100644
--- a/apps/ui/src/i18n/locales/de.json
+++ b/apps/ui/src/i18n/locales/de.json
@@ -3559,5 +3559,9 @@
"Enable this record on OAP? It comes back invalid.": "Diesen Datensatz in OAP aktivieren? Er ist danach wieder aktiv, aber weiterhin ungültig.",
"Enable this record on OAP?": "Diesen Datensatz in OAP aktivieren?",
"Enable": "Aktivieren",
- "The content stored on OAP would break the pages built from it. Turning it back on brings it back invalid.": "Der in OAP gespeicherte Inhalt würde die daraus erzeugten Seiten beschädigen. Wird die Vorlage wieder aktiviert, ist sie weiterhin ungültig."
+ "The content stored on OAP would break the pages built from it. Turning it back on brings it back invalid.": "Der in OAP gespeicherte Inhalt würde die daraus erzeugten Seiten beschädigen. Wird die Vorlage wieder aktiviert, ist sie weiterhin ungültig.",
+ "Record trace": "Record-Trace",
+ "Trace store": "Trace-Speicher",
+ "none — the layer's trace popout": "keiner — das Trace-Popout des Layers",
+ "The store this widget's trace ids live in. A row's trace icon opens the trace from it, over the page.": "Der Speicher, in dem die Trace-IDs dieses Widgets liegen. Das Trace-Symbol einer Zeile öffnet den Trace daraus, über der Seite."
}
diff --git a/apps/ui/src/i18n/locales/en.json b/apps/ui/src/i18n/locales/en.json
index 6f05f7c5..2d72c2be 100644
--- a/apps/ui/src/i18n/locales/en.json
+++ b/apps/ui/src/i18n/locales/en.json
@@ -3559,5 +3559,9 @@
"Enable this record on OAP? It comes back invalid.": "Enable this record on OAP? It comes back invalid.",
"Enable this record on OAP?": "Enable this record on OAP?",
"Enable": "Enable",
- "The content stored on OAP would break the pages built from it. Turning it back on brings it back invalid.": "The content stored on OAP would break the pages built from it. Turning it back on brings it back invalid."
+ "The content stored on OAP would break the pages built from it. Turning it back on brings it back invalid.": "The content stored on OAP would break the pages built from it. Turning it back on brings it back invalid.",
+ "Record trace": "Record trace",
+ "Trace store": "Trace store",
+ "none — the layer's trace popout": "none — the layer's trace popout",
+ "The store this widget's trace ids live in. A row's trace icon opens the trace from it, over the page.": "The store this widget's trace ids live in. A row's trace icon opens the trace from it, over the page."
}
diff --git a/apps/ui/src/i18n/locales/es.json b/apps/ui/src/i18n/locales/es.json
index 70c17b7a..f017a890 100644
--- a/apps/ui/src/i18n/locales/es.json
+++ b/apps/ui/src/i18n/locales/es.json
@@ -3559,5 +3559,9 @@
"Enable this record on OAP? It comes back invalid.": "¿Habilitar este registro en OAP? Vuelve, pero sigue sin ser válido.",
"Enable this record on OAP?": "¿Habilitar este registro en OAP?",
"Enable": "Habilitar",
- "The content stored on OAP would break the pages built from it. Turning it back on brings it back invalid.": "El contenido almacenado en OAP rompería las páginas construidas a partir de él. Si vuelves a habilitar la plantilla, seguirá sin ser válida."
+ "The content stored on OAP would break the pages built from it. Turning it back on brings it back invalid.": "El contenido almacenado en OAP rompería las páginas construidas a partir de él. Si vuelves a habilitar la plantilla, seguirá sin ser válida.",
+ "Record trace": "Traza del registro",
+ "Trace store": "Almacén de trazas",
+ "none — the layer's trace popout": "ninguno — la ventana de traza de la capa",
+ "The store this widget's trace ids live in. A row's trace icon opens the trace from it, over the page.": "El almacén donde están los ids de traza de este widget. El icono de traza de una fila abre la traza desde él, sobre la página."
}
diff --git a/apps/ui/src/i18n/locales/fr.json b/apps/ui/src/i18n/locales/fr.json
index d925fe40..1970c3eb 100644
--- a/apps/ui/src/i18n/locales/fr.json
+++ b/apps/ui/src/i18n/locales/fr.json
@@ -3559,5 +3559,9 @@
"Enable this record on OAP? It comes back invalid.": "Activer cet enregistrement dans OAP ? Il sera de nouveau actif, mais toujours invalide.",
"Enable this record on OAP?": "Activer cet enregistrement dans OAP ?",
"Enable": "Activer",
- "The content stored on OAP would break the pages built from it. Turning it back on brings it back invalid.": "Le contenu stocké dans OAP casserait les pages construites à partir de lui. Une fois réactivé, ce modèle reste invalide."
+ "The content stored on OAP would break the pages built from it. Turning it back on brings it back invalid.": "Le contenu stocké dans OAP casserait les pages construites à partir de lui. Une fois réactivé, ce modèle reste invalide.",
+ "Record trace": "Trace de l'enregistrement",
+ "Trace store": "Stockage des traces",
+ "none — the layer's trace popout": "aucun — la fenêtre de trace de la couche",
+ "The store this widget's trace ids live in. A row's trace icon opens the trace from it, over the page.": "Le stockage qui contient les ids de trace de ce widget. L'icône de trace d'une ligne ouvre la trace depuis celui-ci, par-dessus la page."
}
diff --git a/apps/ui/src/i18n/locales/ja.json b/apps/ui/src/i18n/locales/ja.json
index fa4bc4e0..5ebecfa8 100644
--- a/apps/ui/src/i18n/locales/ja.json
+++ b/apps/ui/src/i18n/locales/ja.json
@@ -3559,5 +3559,9 @@
"Enable this record on OAP? It comes back invalid.": "OAP 上のこのレコードを有効化しますか? 内容は無効なまま戻ります。",
"Enable this record on OAP?": "OAP 上のこのレコードを有効化しますか?",
"Enable": "有効化",
- "The content stored on OAP would break the pages built from it. Turning it back on brings it back invalid.": "OAP に保存された内容は、そこから作られるページを壊してしまいます。再度有効化しても、内容は無効なまま戻ります。"
+ "The content stored on OAP would break the pages built from it. Turning it back on brings it back invalid.": "OAP に保存された内容は、そこから作られるページを壊してしまいます。再度有効化しても、内容は無効なまま戻ります。",
+ "Record trace": "レコードのトレース",
+ "Trace store": "トレースストア",
+ "none — the layer's trace popout": "なし — レイヤーのトレースポップアウト",
+ "The store this widget's trace ids live in. A row's trace icon opens the trace from it, over the page.": "このウィジェットのトレース ID が保存されているストア。行のトレースアイコンは、そこからトレースをページ上に開きます。"
}
diff --git a/apps/ui/src/i18n/locales/ko.json b/apps/ui/src/i18n/locales/ko.json
index 00abf78b..68818d5d 100644
--- a/apps/ui/src/i18n/locales/ko.json
+++ b/apps/ui/src/i18n/locales/ko.json
@@ -3559,5 +3559,9 @@
"Enable this record on OAP? It comes back invalid.": "OAP에서 이 레코드를 활성화할까요? 잘못된 상태 그대로 돌아옵니다.",
"Enable this record on OAP?": "OAP에서 이 레코드를 활성화할까요?",
"Enable": "활성화",
- "The content stored on OAP would break the pages built from it. Turning it back on brings it back invalid.": "OAP에 저장된 내용은 이를 기반으로 만든 페이지를 깨뜨립니다. 다시 활성화해도 잘못된 상태 그대로 돌아옵니다."
+ "The content stored on OAP would break the pages built from it. Turning it back on brings it back invalid.": "OAP에 저장된 내용은 이를 기반으로 만든 페이지를 깨뜨립니다. 다시 활성화해도 잘못된 상태 그대로 돌아옵니다.",
+ "Record trace": "레코드 트레이스",
+ "Trace store": "트레이스 저장소",
+ "none — the layer's trace popout": "없음 — 레이어의 트레이스 팝아웃",
+ "The store this widget's trace ids live in. A row's trace icon opens the trace from it, over the page.": "이 위젯의 트레이스 ID가 저장된 저장소입니다. 행의 트레이스 아이콘은 이 저장소에서 트레이스를 페이지 위에 엽니다."
}
diff --git a/apps/ui/src/i18n/locales/pt.json b/apps/ui/src/i18n/locales/pt.json
index 5c3dcbfa..d3c265c4 100644
--- a/apps/ui/src/i18n/locales/pt.json
+++ b/apps/ui/src/i18n/locales/pt.json
@@ -3559,5 +3559,9 @@
"Enable this record on OAP? It comes back invalid.": "Ativar este registro no OAP? Ele volta, mas continua inválido.",
"Enable this record on OAP?": "Ativar este registro no OAP?",
"Enable": "Ativar",
- "The content stored on OAP would break the pages built from it. Turning it back on brings it back invalid.": "O conteúdo armazenado no OAP quebraria as páginas construídas a partir dele. Ao ativar o modelo novamente, ele continua inválido."
+ "The content stored on OAP would break the pages built from it. Turning it back on brings it back invalid.": "O conteúdo armazenado no OAP quebraria as páginas construídas a partir dele. Ao ativar o modelo novamente, ele continua inválido.",
+ "Record trace": "Trace do registro",
+ "Trace store": "Armazenamento de traces",
+ "none — the layer's trace popout": "nenhum — o popout de trace da camada",
+ "The store this widget's trace ids live in. A row's trace icon opens the trace from it, over the page.": "O armazenamento onde ficam os ids de trace deste widget. O ícone de trace de uma linha abre o trace a partir dele, sobre a página."
}
diff --git a/apps/ui/src/i18n/locales/zh-CN.json b/apps/ui/src/i18n/locales/zh-CN.json
index 4b0499cd..886f90de 100644
--- a/apps/ui/src/i18n/locales/zh-CN.json
+++ b/apps/ui/src/i18n/locales/zh-CN.json
@@ -3559,5 +3559,9 @@
"Enable this record on OAP? It comes back invalid.": "启用 OAP 上的这条记录?启用后它仍然无效。",
"Enable this record on OAP?": "启用 OAP 上的这条记录?",
"Enable": "启用",
- "The content stored on OAP would break the pages built from it. Turning it back on brings it back invalid.": "OAP 中存储的内容会破坏据此生成的页面。重新启用后它仍然无效。"
+ "The content stored on OAP would break the pages built from it. Turning it back on brings it back invalid.": "OAP 中存储的内容会破坏据此生成的页面。重新启用后它仍然无效。",
+ "Record trace": "记录追踪",
+ "Trace store": "追踪存储",
+ "none — the layer's trace popout": "无 — 该层的追踪弹窗",
+ "The store this widget's trace ids live in. A row's trace icon opens the trace from it, over the page.": "该部件的追踪 ID 所在的存储。行首的追踪图标会从该存储打开追踪,显示在当前页面之上。"
}
diff --git a/apps/ui/src/layer/traceql/TraceQLTracePopout.vue b/apps/ui/src/layer/traceql/TraceQLTracePopout.vue
new file mode 100644
index 00000000..1926de62
--- /dev/null
+++ b/apps/ui/src/layer/traceql/TraceQLTracePopout.vue
@@ -0,0 +1,57 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!--
+ Global TraceQL trace popout: a trace read through a TraceQL store, opened
+ over the current page by `useTraceQLTracePopout().openTrace(id, ds)`, as the
+ native popout opens a native trace.
+-->
+<script setup lang="ts">
+import { useEscapeToClose } from '@/components/primitives/useEscapeToClose';
+import TraceQLTraceDetail from './TraceQLTraceDetail.vue';
+import { useTraceQLTracePopout } from './useTraceQLTracePopout';
+
+const { open, closeTrace } = useTraceQLTracePopout();
+useEscapeToClose(() => open.value !== null, closeTrace);
+</script>
+
+<template>
+ <div v-if="open" class="tqp-overlay" @click.self="closeTrace">
+ <TraceQLTraceDetail class="tqp-card" :ds="open.ds" :trace-id="open.traceId" @close="closeTrace" />
+ </div>
+</template>
+
+<style scoped>
+/* The layer TraceQL view's URL overlay, over any page. */
+.tqp-overlay {
+ position: fixed;
+ inset: 0;
+ background: rgba(0, 0, 0, 0.55);
+ z-index: 40;
+ display: flex;
+ align-items: flex-start;
+ justify-content: center;
+ padding: 40px 16px;
+ overflow: auto;
+}
+.tqp-card {
+ width: min(1100px, 100%);
+ min-height: min(640px, calc(100vh - 80px));
+ display: flex;
+ flex-direction: column;
+}
+.tqp-card :deep(> *) { flex: 1 1 auto; min-height: 0; }
+</style>
diff --git a/apps/ui/src/layer/traceql/useTraceQLTracePopout.test.ts b/apps/ui/src/layer/traceql/useTraceQLTracePopout.test.ts
new file mode 100644
index 00000000..71eacfee
--- /dev/null
+++ b/apps/ui/src/layer/traceql/useTraceQLTracePopout.test.ts
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { describe, expect, it } from 'vitest';
+import { defineComponent, h } from 'vue';
+import { mount } from '@vue/test-utils';
+import { createMemoryHistory, createRouter } from 'vue-router';
+import { useTraceQLTracePopout } from './useTraceQLTracePopout';
+
+const Blank = { template: '<div />' };
+
+async function harness(path: string) {
+ const router = createRouter({
+ history: createMemoryHistory(),
+ routes: [
+ { path: '/layer/:layerKey/service', component: Blank, meta: { layerRow: 'service' } },
+ { path: '/layer/:layerKey/traceql-otlp-trace', component: Blank, meta: { layerRow: 'traceql-otlp-trace' } },
+ ],
+ });
+ await router.push(path);
+ await router.isReady();
+ let api!: ReturnType<typeof useTraceQLTracePopout>;
+ mount(defineComponent({ setup() { api = useTraceQLTracePopout(); return () => h('div'); } }), { global: { plugins: [router] } });
+ return { router, api };
+}
+
+describe('useTraceQLTracePopout', () => {
+ it('opens on the current page and closes back to it', async () => {
+ const { router, api } = await harness('/layer/otlp_virtual_database/service?service=db');
+ api.openTrace('abc123', 'otlp');
+ await router.isReady();
+ await new Promise((r) => setTimeout(r));
+ expect(router.currentRoute.value.path).toBe('/layer/otlp_virtual_database/service');
+ expect(router.currentRoute.value.query).toEqual({ service: 'db', traceqlId: 'abc123', ds: 'otlp' });
+ expect(api.open.value).toEqual({ traceId: 'abc123', ds: 'otlp' });
+ api.closeTrace();
+ await new Promise((r) => setTimeout(r));
+ expect(router.currentRoute.value.query).toEqual({ service: 'db' });
+ expect(api.open.value).toBeNull();
+ });
+
+ it('stands aside on a TraceQL row, whose view opens the id itself', async () => {
+ const { api } = await harness('/layer/otlp_service/traceql-otlp-trace?traceqlId=abc123&ds=otlp');
+ expect(api.open.value).toBeNull();
+ });
+
+ it('needs a known datasource', async () => {
+ const { api } = await harness('/layer/general/service?traceqlId=abc123&ds=tempo');
+ expect(api.open.value).toBeNull();
+ });
+});
diff --git a/apps/ui/src/layer/traceql/useTraceQLTracePopout.ts b/apps/ui/src/layer/traceql/useTraceQLTracePopout.ts
new file mode 100644
index 00000000..66a72bf8
--- /dev/null
+++ b/apps/ui/src/layer/traceql/useTraceQLTracePopout.ts
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/** URL-backed popout for one trace read through a TraceQL store, over any
+ * page: `?traceqlId=` with `?ds=` naming the store, as the TraceQL card's
+ * shareable URL writes them. The layer TraceQL rows read the same id with a
+ * list beside it, so the popout stands aside on those routes. */
+
+import { computed } from 'vue';
+import { useRoute, useRouter } from 'vue-router';
+import type { TraceQLDatasource } from '@skywalking-horizon-ui/api-client';
+import { routeRow } from '@/utils/layerRoute';
+import { TRACEQL_POPOUT_QUERY } from './traceqlDetailShared';
+
+const DS_QUERY = 'ds';
+const DATASOURCES: readonly TraceQLDatasource[] = ['native', 'zipkin', 'otlp'];
+
+export function useTraceQLTracePopout() {
+ const route = useRoute();
+ const router = useRouter();
+
+ const onTraceQLRow = computed(() => routeRow(route)?.startsWith('traceql-') === true);
+ const open = computed<{ traceId: string; ds: TraceQLDatasource } | null>(() => {
+ if (onTraceQLRow.value) return null;
+ const id = route.query[TRACEQL_POPOUT_QUERY];
+ const ds = route.query[DS_QUERY];
+ if (typeof id !== 'string' || !id) return null;
+ if (typeof ds !== 'string' || !(DATASOURCES as readonly string[]).includes(ds)) return null;
+ return { traceId: id, ds: ds as TraceQLDatasource };
+ });
+
+ function openTrace(id: string, ds: TraceQLDatasource): void {
+ if (!id) return;
+ void router.push({ path: route.path, query: { ...route.query, [TRACEQL_POPOUT_QUERY]: id, [DS_QUERY]: ds } });
+ }
+
+ function closeTrace(): void {
+ if (!open.value) return;
+ const query = { ...route.query };
+ delete query[TRACEQL_POPOUT_QUERY];
+ delete query[DS_QUERY];
+ void router.replace({ path: route.path, query });
+ }
+
+ return { open, openTrace, closeTrace };
+}
diff --git a/apps/ui/src/render/layer-dashboard/LayerWidgetTile.vue b/apps/ui/src/render/layer-dashboard/LayerWidgetTile.vue
index e7508837..6de36ad6 100644
--- a/apps/ui/src/render/layer-dashboard/LayerWidgetTile.vue
+++ b/apps/ui/src/render/layer-dashboard/LayerWidgetTile.vue
@@ -268,6 +268,7 @@ function chipRows(w: DashboardWidget, res: DashboardWidgetResult | undefined): C
:items="result(widget.id)!.records!"
:unit="widget.unit"
:color="widgetColor(widget)"
+ :trace="widget.recordTrace"
/>
<span v-else class="muted">{{ (compareMode ? compareLoading : (isFetching && !results.has(widget.id))) ? t('loading…') : t('no data') }}</span>
</template>
diff --git a/apps/ui/src/render/widgets/RecordList.test.ts b/apps/ui/src/render/widgets/RecordList.test.ts
new file mode 100644
index 00000000..598e4d0b
--- /dev/null
+++ b/apps/ui/src/render/widgets/RecordList.test.ts
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { afterEach, describe, expect, it, vi } from 'vitest';
+import { mount } from '@vue/test-utils';
+import { createMemoryHistory, createRouter } from 'vue-router';
+import type { RecordTrace } from '@skywalking-horizon-ui/api-client';
+import { i18n } from '@/i18n';
+import RecordList from './RecordList.vue';
+
+const openNative = vi.fn();
+const openZipkin = vi.fn();
+const openTraceQL = vi.fn();
+vi.mock('@/layer/traces/useTracePopout', () => ({ useTracePopout: () => ({ openTrace: openNative }) }));
+vi.mock('@/layer/traces/useZipkinTracePopout', () => ({ useZipkinTracePopout: () => ({ openTrace: openZipkin }) }));
+vi.mock('@/layer/traceql/useTraceQLTracePopout', () => ({ useTraceQLTracePopout: () => ({ openTrace: openTraceQL }) }));
+
+const Blank = { template: '<div />' };
+
+async function mountAt(path: string, trace?: RecordTrace) {
+ const router = createRouter({
+ history: createMemoryHistory(),
+ routes: [
+ { path: '/', component: Blank },
+ { path: '/layer/:layerKey', component: Blank, children: [{ path: ':row', component: Blank }] },
+ ],
+ });
+ await router.push(path);
+ await router.isReady();
+ return mount(RecordList, {
+ props: {
+ items: [
+ { name: 'SELECT 1', value: 250, traceId: 'abc123' },
+ { name: 'SELECT 2', value: 210 },
+ ],
+ unit: 'ms',
+ trace,
+ },
+ global: { plugins: [router, i18n] },
+ });
+}
+
+describe('RecordList — trace icon', () => {
+ afterEach(() => {
+ vi.restoreAllMocks();
+ openNative.mockClear();
+ openZipkin.mockClear();
+ openTraceQL.mockClear();
+ });
+
+ it('draws the icon only on a row that carries a trace id', async () => {
+ const w = await mountAt('/');
+ const rows = w.findAll('.rec-row');
+ expect(rows[0].find('.rec-trace').exists()).toBe(true);
+ expect(rows[1].find('.rec-trace').exists()).toBe(false);
+ });
+
+ it('opens the native popout when the widget names no store', async () => {
+ const w = await mountAt('/');
+ await w.find('.rec-trace').trigger('click');
+ expect(openNative).toHaveBeenCalledWith('abc123');
+ expect(openZipkin).not.toHaveBeenCalled();
+ });
+
+ it('forces the native popout when the widget names the native store', async () => {
+ const w = await mountAt('/', { source: 'native' });
+ await w.find('.rec-trace').trigger('click');
+ expect(openNative).toHaveBeenCalledWith('abc123', undefined, 'SKYWALKING_NATIVE');
+ });
+
+ it('opens the Zipkin popout for the zipkin store', async () => {
+ const w = await mountAt('/', { source: 'zipkin' });
+ await w.find('.rec-trace').trigger('click');
+ expect(openZipkin).toHaveBeenCalledWith('abc123');
+ expect(openNative).not.toHaveBeenCalled();
+ });
+
+ it.each([
+ ['traceql-otlp', 'otlp'],
+ ['traceql-zipkin', 'zipkin'],
+ ['traceql-native', 'native'],
+ ] as const)('opens the %s store in the TraceQL popout over the page', async (source, ds) => {
+ const w = await mountAt('/layer/otlp_virtual_database/service', { source });
+ await w.find('.rec-trace').trigger('click');
+ expect(openTraceQL).toHaveBeenCalledWith('abc123', ds);
+ expect(openNative).not.toHaveBeenCalled();
+ expect(openZipkin).not.toHaveBeenCalled();
+ });
+});
diff --git a/apps/ui/src/render/widgets/RecordList.vue b/apps/ui/src/render/widgets/RecordList.vue
index 643cf6a3..a2977d97 100644
--- a/apps/ui/src/render/widgets/RecordList.vue
+++ b/apps/ui/src/render/widgets/RecordList.vue
@@ -19,7 +19,9 @@
widget). Each row is one sampled statement execution:
- a jump-to-trace icon at the head, shown ONLY when the sample carries
- a trace id (these are sampled, so the trace can be absent);
+ a trace id (these are sampled, so the trace can be absent). The
+ widget's `recordTrace` names the store the id lives in; absent, it is
+ the layer's own popout (native, or Zipkin on a Zipkin-only layer);
- the statement text, click-to-copy;
- the metric value (latency) + unit.
@@ -29,8 +31,11 @@
<script setup lang="ts">
import { ref } from 'vue';
import { useI18n } from 'vue-i18n';
+import type { RecordTrace, TraceQLDatasource } from '@skywalking-horizon-ui/api-client';
import Icon from '@/components/icons/Icon.vue';
import { useTracePopout } from '@/layer/traces/useTracePopout';
+import { useZipkinTracePopout } from '@/layer/traces/useZipkinTracePopout';
+import { useTraceQLTracePopout } from '@/layer/traceql/useTraceQLTracePopout';
import { fmtMetric } from '@/utils/formatters';
interface RecordRow {
@@ -38,10 +43,29 @@ interface RecordRow {
value?: number | null;
traceId?: string;
}
-defineProps<{ items: ReadonlyArray<RecordRow>; unit?: string; color?: string }>();
+const props = defineProps<{ items: ReadonlyArray<RecordRow>; unit?: string; color?: string; trace?: RecordTrace }>();
const { t } = useI18n({ useScope: 'global' });
-const { openTrace } = useTracePopout();
+const { openTrace: openNativeTrace } = useTracePopout();
+const { openTrace: openZipkinTrace } = useZipkinTracePopout();
+const { openTrace: openTraceQLTrace } = useTraceQLTracePopout();
+
+const TRACEQL_DS: Record<string, TraceQLDatasource> = {
+ 'traceql-native': 'native',
+ 'traceql-zipkin': 'zipkin',
+ 'traceql-otlp': 'otlp',
+};
+
+/** Every store opens its popout over this page, so the menu stays put. With
+ * no store named, the layer's trace config picks the native or Zipkin popout,
+ * as it always has; a named `native` says so outright. */
+function openTrace(id: string): void {
+ const source = props.trace?.source;
+ if (source === 'zipkin') openZipkinTrace(id);
+ else if (source && TRACEQL_DS[source]) openTraceQLTrace(id, TRACEQL_DS[source]);
+ else if (source === 'native') openNativeTrace(id, undefined, 'SKYWALKING_NATIVE');
+ else openNativeTrace(id);
+}
const copiedIdx = ref<number | null>(null);
let copiedTimer: ReturnType<typeof setTimeout> | null = null;
diff --git a/apps/ui/src/render/widgets/TabWidget.vue b/apps/ui/src/render/widgets/TabWidget.vue
index 2c4d41c5..3b0ea564 100644
--- a/apps/ui/src/render/widgets/TabWidget.vue
+++ b/apps/ui/src/render/widgets/TabWidget.vue
@@ -218,6 +218,7 @@ function loadingOrEmpty(w: DashboardWidget): string {
:items="resultOf(w)!.records!"
:unit="w.unit"
:color="host.widgetColor(w)"
+ :trace="w.recordTrace"
/>
<span v-else class="muted">{{ loadingOrEmpty(w) }}</span>
</template>
diff --git a/apps/ui/src/shell/AppShell.vue b/apps/ui/src/shell/AppShell.vue
index 20312f32..a867697d 100644
--- a/apps/ui/src/shell/AppShell.vue
+++ b/apps/ui/src/shell/AppShell.vue
@@ -27,6 +27,7 @@ import PreviewModeBanner from './PreviewModeBanner.vue';
import TracePopout from '@/layer/traces/TracePopout.vue';
import EventsPopout from '@/features/events/EventsPopout.vue';
import ZipkinTracePopout from '@/layer/traces/ZipkinTracePopout.vue';
+import TraceQLTracePopout from '@/layer/traceql/TraceQLTracePopout.vue';
import AiChatLauncher from '@/ai/AiChatLauncher.vue';
import AiChatPanel from '@/ai/AiChatPanel.vue';
import TemplateConflictPrompt from './TemplateConflictPrompt.vue';
@@ -174,6 +175,8 @@ function startSidebarResize(e: PointerEvent): void {
<!-- Shares `?traceId=`; native vs Zipkin self-select by ID shape
(see isZipkinTraceId). -->
<ZipkinTracePopout />
+ <!-- `?traceqlId=` + `?ds=`: a trace read through a TraceQL store, over any page. -->
+ <TraceQLTracePopout />
<!-- Per-service events popout: a layer's service banner calls
useEventsPopout().open(layer, service) to peek that service's
instance events without leaving the page. -->
diff --git a/docs/changelog/1.1.0.md b/docs/changelog/1.1.0.md
index 67ae5fba..79eac8df 100644
--- a/docs/changelog/1.1.0.md
+++ b/docs/changelog/1.1.0.md
@@ -184,6 +184,8 @@ The **3D Infra Map** opens framed on the tiers that hold services. A deployment
**Every MQE field in the layer template editor can now be run where you type it.** A run button beside each expression opens a panel that picks a service (and, where the metric needs one, an instance, endpoint or process), picks a time range with the same precision-tabbed picker the top of the page uses (custom ranges included), fires the expression against your OAP and shows exactly what came back — a graph of the series it returned, aligned on one time axis with a legend per label, the [...]
+**A record widget's trace icon opens the store the trace is in.** The new `recordTrace` widget field names the store a `record` widget's trace ids belong to, with the store names of `traces.sources`, and the icon opens the trace in that store's popout over the dashboard; the widget editor sets it under **Record trace → Trace store**, and the AI assistant's record figures follow it too. The icon used to open every record's trace in the native popout, which holds no OTLP trace. Absent, it [...]
+
### Fixes
**One broken template no longer takes down the sidebar or every dashboard.** A layer template stored on OAP without the `components` section made the sidebar say **OAP unreachable** — with OAP fine — and drop every layer, including ones with live services; other broken shapes made every layer and overview disappear behind the template-store banner. Such a template now loses only itself.
diff --git a/docs/components/dashboard-widgets.md b/docs/components/dashboard-widgets.md
index 40f58980..b34ee3f9 100644
--- a/docs/components/dashboard-widgets.md
+++ b/docs/components/dashboard-widgets.md
@@ -29,6 +29,7 @@ Six widget types render on per-layer dashboards. Each `widget.type` you set in a
| `valueMap` | `card` with `format: "enum"` — maps a coded metric value (or label value) to the display label. |
| `valueColors` | `card` with `format: "enum"` — maps a value to a status-chip color: `ok`, `warn`, `err`, `info`, or `neutral`. See [Status chips](#status-chips-valuecolors). |
| `traceDrill` | `line` only — `{ "mode": "latency" \| "error" }` links data points to the matching traces. See [Metric-to-trace drill](#metric-to-trace-drill-tracedrill). |
+| `recordTrace` | `record` only — `{ "source": "<trace store>" }` names the store a record's trace id opens in. See [Which store a record's trace opens in](#which-store-a-records-trace-opens-in-recordtrace). |
| `tabs[]` | `tab` only — the named panels, each `{ "name": "…", "widgets": [ … ] }`. See [`tab`](#tab). |
| `tableHeaders` | `table` only — `[, valueHeader]`; the value column's header. Label columns are headed by their dimension name. |
| `showTableValues` | `table` only — show the value column. `false` for presence-only lists (e.g. node conditions). Default `true`. |
@@ -204,10 +205,33 @@ The data source returns a record set (rows × typed columns) rather than a numer
### Behavior
-- Each row is one sampled record: the statement / command text, its value (e.g. latency), and — when the sample carries a trace id — a jump-to-trace icon at the row head that opens the originating trace in the trace viewer.
+- Each row is one sampled record: the statement / command text, its value (e.g. latency), and — when the sample carries a trace id — a jump-to-trace icon at the row head that opens the originating trace.
- Records are sampled, so a row's trace id can be absent; the jump-to-trace icon appears only when the sample has one.
- Click a row's statement text to copy it to the clipboard.
+### Which store a record's trace opens in (`recordTrace`)
+
+A record's trace id belongs to whichever store kept the trace, and the widget cannot tell which one from the id. Records the SkyWalking agents produce live in the native store; records drawn from other spans, such as the OTLP slow statements, live in another one, so the widget names it.
+
+**In the editor:** open the layer in **Dashboard setup → Layer dashboards**, select the `record` widget, and pick the store under **Record trace → Trace store**. The choices are the store names a layer lists in its trace stores:
+
+| Trace store | Where the trace opens |
+|---|---|
+| none | The layer's own trace popout: the native one, or the Zipkin one on a layer whose traces are Zipkin only. |
+| `native` | The native trace popout, whatever the layer's trace stores. |
+| `zipkin` | The Zipkin trace popout. |
+| `traceql-native`, `traceql-zipkin`, `traceql-otlp` | The TraceQL trace popout, reading that store. |
+
+Each popout opens over the dashboard and closes back to it, so the page and its menu stay where they are; the address carries the open trace, so it can be shared. A TraceQL store needs OAP's TraceQL module with that datasource on, and Horizon's `oap.traceql` pointing at it.
+
+**Stored format:** the choice is saved on the widget as `recordTrace`, absent for none:
+
+```json
+"recordTrace": { "source": "traceql-otlp" }
+```
+
+Publishing or importing a template refuses a `recordTrace` that names no known store, and one on a widget that is not a `record`. A template already stored with a bad value still loads; its trace icon opens the layer's own popout.
+
## `table`
**Renders:** A key→value table for a **labeled** `latest(…)` metric — one row per label combination, one column per label dimension, plus an optional value column.
diff --git a/docs/customization/layer-templates.md b/docs/customization/layer-templates.md
index 7cd4e1f8..12ad353b 100644
--- a/docs/customization/layer-templates.md
+++ b/docs/customization/layer-templates.md
@@ -221,6 +221,7 @@ A layer without an explicit `instance` widget set will reuse `service` widgets o
| `format` | Value formatting: `int`, `decimal`, `compact` (K / M suffixes), `duration` (a seconds value rendered as a human time-ago), `enum` (a coded value mapped to a label via `valueMap`). |
| `valueMap` / `valueColors` | Enum-card display maps — value → label, and value → status-chip color (`ok` / `warn` / `err` / `info` / `neutral`). See [Dashboard Widgets → Status chips](../components/dashboard-widgets.md#status-chips-valuecolors). |
| `traceDrill` | `line` only — `{ "mode": "latency" \| "error" }` makes data points clickable, opening the layer's Traces tab pre-filtered to the slow or error traces around the clicked moment. See [Dashboard Widgets → Metric-to-trace drill](../components/dashboard-widgets.md#metric-to-trace-drill-tracedrill). |
+| `recordTrace` | `record` only — `{ "source": "<trace store>" }` names the trace store a record's trace id lives in, with the store names of `traces.sources`; set in the editor under **Record trace → Trace store**. Absent, the trace icon opens the layer's own trace popout. See [Dashboard Widgets → Which store a record's trace opens in](../components/dashboard-widgets.md#which-store-a-records-trace-opens-in-recordtrace). |
| `span` | Column span in the 12-col grid. Default 4 = three widgets per row. |
| `rowSpan` | Vertical span. Default 1 (one 120 px row). |
| `visibleWhen` | Structured visibility predicate (object form). An MQE gate `{ "kind": "mqe", "expression": "<mqe>", "op": "exists" \| "gt" \| "lt", "value"?: <n> }` shows the widget only when the expression returns data (`exists`) or crosses a threshold; an entity gate `{ "kind": "entity", "attribute": "<attr>", "op": "exists" \| "eq", "value"?: "<v>" }` shows it only when the selected entity has that attribute — entity gates are Instance-scope only. |
@@ -701,3 +702,20 @@ The Logs tab disappears from the layer page nav. Existing direct-URL navigation
```
`traceDrill` makes the line's data points clickable — a click opens the layer's Traces tab pre-filtered to the slow (`latency` mode) or error (`error` mode) traces around the clicked moment. It needs the layer's `traces` component enabled and the `native` trace store among its `traces.sources` — the drill filter is a native-trace query. See [Dashboard Widgets → Metric-to-trace drill](../components/dashboard-widgets.md#metric-to-trace-drill-tracedrill).
+
+### Open a record's trace in the store that holds it
+
+A `record` widget's trace icon opens the layer's own trace popout unless the widget names the store its trace ids live in. Select the widget and pick the store under **Record trace → Trace store**; the trace then opens in that store's popout over the dashboard, so the page and its menu stay where they are. The bundled OTLP Virtual Database layer has no Traces tab of its own, and its Slow Statements widget names `traceql-otlp`, reading its traces from the OTLP store through TraceQL. See [ [...]
+
+The stored widget, for reference:
+
+```json
+{
+ "id": "slow_statements",
+ "type": "record",
+ "title": "Slow Statements",
+ "expressions": ["top_n(top_n_database_statement, 20, des)"],
+ "unit": "ms",
+ "recordTrace": { "source": "traceql-otlp" }
+}
+```
diff --git a/docs/dashboards/otlp_virtual_database.md b/docs/dashboards/otlp_virtual_database.md
index 8ce11448..5b99959e 100644
--- a/docs/dashboards/otlp_virtual_database.md
+++ b/docs/dashboards/otlp_virtual_database.md
@@ -42,7 +42,7 @@ The landing page lists every database with three sortable columns, sorted by **A
- **Success Rate** — percent of the callers' spans that did not fail, as in the list (`otlp_database_access_sla/100`).
-- **Slow Statements** — the top 20 slowest statements the shipped `otlp-slow-sql` rule recorded against this database, in ms, worst-first (`top_n(top_n_database_statement, 20, des)`). Each row is one statement execution; click a row to copy the statement. The rule records a statement at 200 ms or more by default; the threshold is in the rule file.
+- **Slow Statements** — the top 20 slowest statements the shipped `otlp-slow-sql` rule recorded against this database, in ms, worst-first (`top_n(top_n_database_statement, 20, des)`). Each row is one statement execution; click a row to copy the statement, or use the trace icon at the row head to open its trace from the OTLP trace store, over this page. The rule records a statement at 200 ms or more by default; the threshold is in the rule file.
## Databases without an address
diff --git a/packages/api-client/src/dashboard.ts b/packages/api-client/src/dashboard.ts
index 92867f40..56ee7317 100644
--- a/packages/api-client/src/dashboard.ts
+++ b/packages/api-client/src/dashboard.ts
@@ -15,6 +15,8 @@
* limitations under the License.
*/
+import type { TraceStore } from './trace.js';
+
/**
* Per-layer dashboard wire types.
*
@@ -96,6 +98,13 @@ export type VisibleWhen =
*/
export type TraceDrill = { mode: 'off' | 'latency' | 'error' };
+/**
+ * Where a `record` widget's trace ids live, named as in `traces.sources`. The
+ * trace opens in that store's popout over the current page. Absent ⇒ the
+ * layer's own popout: native, or Zipkin on a Zipkin-only layer.
+ */
+export type RecordTrace = { source: TraceStore };
+
/**
* Per-entity dashboard scope. Each layer carries an independent widget
* set per scope; the SPA picks the right set based on the active
@@ -241,6 +250,8 @@ export interface DashboardWidget {
topNOrder?: 'asc' | 'des';
/** Optional metric→trace drill on a `line` widget — see {@link TraceDrill}. */
traceDrill?: TraceDrill;
+ /** Which store a `record` widget's trace ids open in — see {@link RecordTrace}. */
+ recordTrace?: RecordTrace;
/** Legacy 24-col grid coordinates — kept for back-compat during the
* span-based flow-layout migration. New widgets should leave these
* unset and use `span` / `rowSpan` instead. */
diff --git a/packages/api-client/src/index.ts b/packages/api-client/src/index.ts
index 55491335..8f99a95b 100644
--- a/packages/api-client/src/index.ts
+++ b/packages/api-client/src/index.ts
@@ -48,6 +48,7 @@ export type {
DashboardWidget,
DashboardWidgetResult,
DashboardWidgetType,
+ RecordTrace,
VisibleWhen,
} from './dashboard.js';
export { walkWidgets, findWidgetById, collectWidgetIds } from './dashboard.js';