@juice-js/observability 0.0.0-stage → 1.0.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -2
- package/fesm2022/juice-js-observability-alert.page-BHKAUvR-.mjs +404 -0
- package/fesm2022/juice-js-observability-alert.page-BHKAUvR-.mjs.map +1 -0
- package/fesm2022/juice-js-observability-alerts.page-C2tXzLQl.mjs +208 -0
- package/fesm2022/juice-js-observability-alerts.page-C2tXzLQl.mjs.map +1 -0
- package/fesm2022/juice-js-observability-logs.page--j6W1Ej-.mjs +413 -0
- package/fesm2022/juice-js-observability-logs.page--j6W1Ej-.mjs.map +1 -0
- package/fesm2022/juice-js-observability-metrics.page-DR6qZtfl.mjs +267 -0
- package/fesm2022/juice-js-observability-metrics.page-DR6qZtfl.mjs.map +1 -0
- package/fesm2022/juice-js-observability-overview.page-DU0GxSXQ.mjs +243 -0
- package/fesm2022/juice-js-observability-overview.page-DU0GxSXQ.mjs.map +1 -0
- package/fesm2022/juice-js-observability-resource.page-D6qpvo_f.mjs +274 -0
- package/fesm2022/juice-js-observability-resource.page-D6qpvo_f.mjs.map +1 -0
- package/fesm2022/juice-js-observability-resources.page-CR7-DFsh.mjs +209 -0
- package/fesm2022/juice-js-observability-resources.page-CR7-DFsh.mjs.map +1 -0
- package/fesm2022/juice-js-observability-rules.page-fq-wO5I_.mjs +175 -0
- package/fesm2022/juice-js-observability-rules.page-fq-wO5I_.mjs.map +1 -0
- package/fesm2022/juice-js-observability-service.page-Qc6FYChB.mjs +726 -0
- package/fesm2022/juice-js-observability-service.page-Qc6FYChB.mjs.map +1 -0
- package/fesm2022/juice-js-observability-services.page-CX6S7sUu.mjs +251 -0
- package/fesm2022/juice-js-observability-services.page-CX6S7sUu.mjs.map +1 -0
- package/fesm2022/juice-js-observability-telemetry-D9EYxkdr.mjs +1783 -0
- package/fesm2022/juice-js-observability-telemetry-D9EYxkdr.mjs.map +1 -0
- package/fesm2022/juice-js-observability-topology.page-CLz7J5pq.mjs +483 -0
- package/fesm2022/juice-js-observability-topology.page-CLz7J5pq.mjs.map +1 -0
- package/fesm2022/juice-js-observability-trace.page-DccvH1SV.mjs +518 -0
- package/fesm2022/juice-js-observability-trace.page-DccvH1SV.mjs.map +1 -0
- package/fesm2022/juice-js-observability-traces.page-BZxnac4Y.mjs +520 -0
- package/fesm2022/juice-js-observability-traces.page-BZxnac4Y.mjs.map +1 -0
- package/fesm2022/juice-js-observability.mjs +396 -0
- package/fesm2022/juice-js-observability.mjs.map +1 -0
- package/package.json +48 -4
- package/styles/_observability.scss +216 -0
- package/types/juice-js-observability.d.ts +387 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"juice-js-observability-topology.page-CLz7J5pq.mjs","names":[],"sources":["../../../../projects/juice-js/observability/src/lib/pages/topology.page.ts"],"sourcesContent":["import { LinkPipe, ObservabilityLinks } from '../core/options';\nimport {\n ChangeDetectionStrategy, Component, ElementRef, OnDestroy, afterNextRender, computed, effect, inject, input, viewChild,\n} from '@angular/core';\nimport { apiResource } from '../shared/resource';\nimport { MatButtonModule } from '@angular/material/button';\nimport { MatIconModule } from '@angular/material/icon';\nimport { MatProgressBarModule } from '@angular/material/progress-bar';\nimport { Router, RouterLink } from '@angular/router';\nimport type { Core, StylesheetJson } from 'cytoscape';\nimport { ApiService } from '../core/api.service';\nimport { ContextService } from '../core/context.service';\nimport { Topology } from '../core/models';\nimport { AgoPipe, DurationPipe, PercentPipe } from '../shared/format';\nimport { ConfidenceBadge, ContextBar, HealthBadge } from '../shared/ui';\nimport { problemText } from '../shared/telemetry';\nimport { onThemeChange, themeColor } from '../shared/theme';\n\n/** A service's health → its --jc-* colour from the app's theme (observability.colors). */\nconst HEALTH_TOKENS: Record<string, string> = {\n Healthy: 'ok', Degraded: 'warn', Unhealthy: 'bad', Critical: 'crit', Offline: 'off', Unknown: 'none',\n};\n\n/**\n * Dependency topology (Console requirements §9): services, databases and destinations; zoom, pan and selection.\n * Observed edges are solid, inferred ones dashed and labelled, so an inference never reads as a confirmed call. A\n * selected edge shows its evidence and representative traces; the selection is in the URL.\n */\n@Component({\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [LinkPipe, RouterLink, MatButtonModule, MatIconModule, MatProgressBarModule, ContextBar, HealthBadge, ConfidenceBadge,\n AgoPipe, DurationPipe, PercentPipe],\n template: `\n <jc-context-bar><h1>Dependencies</h1></jc-context-bar>\n @if (topology.isLoading()) { <mat-progress-bar mode=\"indeterminate\" /> }\n @if (topology.error()) { <p class=\"jc-error\">{{ error() }}</p> }\n <div class=\"jc-topology\">\n <div class=\"jc-graph-wrap\">\n <div #graph class=\"jc-graph\" aria-label=\"Dependency graph\"></div>\n <div class=\"jc-graph-legend\">\n <span><i class=\"jc-line\"></i> observed</span><span><i class=\"jc-line jc-dashed\"></i> inferred</span>\n <span>■ service ◆ database ⬣ destination</span>\n <button mat-button (click)=\"fit()\">Fit</button>\n </div>\n @if (topology.value()?.truncated) { <p class=\"jc-muted\">Showing the most recent edges only.</p> }\n @if (topology.hasValue() && topology.value()!.nodes.length === 0) { <p class=\"jc-muted\">No dependencies seen{{ ctx.environment() ? ' in ' + ctx.environment() : '' }}.</p> }\n </div>\n\n <aside class=\"jc-card jc-side\">\n @if (selectedEdge(); as e) {\n <h2>{{ name(e.source) }} → {{ name(e.target) }}</h2>\n <p>{{ e.relation }} <jc-confidence [confidence]=\"e.confidence\" /></p>\n @if (e.confidence.toLowerCase() !== 'observed') {\n <p class=\"jc-muted jc-small\">Inferred from span attributes (for example db.system.name or messaging.destination.name), not a call\n seen between two instrumented services.</p>\n }\n @if (evidence.isLoading()) { <mat-progress-bar mode=\"indeterminate\" /> }\n @if (evidence.value(); as ev) {\n <dl class=\"jc-facts\">\n <dt>Calls in window</dt><dd>{{ ev.count }}</dd>\n <dt>Error rate</dt><dd [class.jc-bad]=\"ev.errorRate >= 0.05\">{{ ev.count ? (ev.errorRate | percent2) : 'no data' }}</dd>\n <dt>p95</dt><dd>{{ ev.p95Ms | duration }}</dd>\n <dt>Last seen</dt><dd>{{ ev.lastSeen ?? e.lastSeen | ago }}</dd>\n </dl>\n <h3>Representative traces</h3>\n @for (t of ev.errorTraces; track t) { <div><a [routerLink]=\"['traces', t] | jcLink\" [queryParams]=\"ctx.keep()\" class=\"jc-mono\">{{ t.slice(0, 16) }}…</a> <span class=\"jc-badge jc-health-unhealthy\">error</span></div> }\n @for (t of ev.slowestTraces; track t) { <div><a [routerLink]=\"['traces', t] | jcLink\" [queryParams]=\"ctx.keep()\" class=\"jc-mono\">{{ t.slice(0, 16) }}…</a> <span class=\"jc-muted jc-small\">slow</span></div> }\n @if (!ev.errorTraces.length && !ev.slowestTraces.length) { <p class=\"jc-muted\">No calls in this window.</p> }\n <a mat-stroked-button [routerLink]=\"['traces'] | jcLink\" [queryParams]=\"ctx.keep({ dependency: e.id })\">All traces through this edge</a>\n }\n <p><a [routerLink]=\"link(e.source)\" [queryParams]=\"ctx.keep()\">Open {{ name(e.source) }}</a> ·\n <a [routerLink]=\"link(e.target)\" [queryParams]=\"ctx.keep()\">Open {{ name(e.target) }}</a></p>\n } @else if (selectedNode(); as n) {\n <h2>{{ n.displayName }}</h2>\n <p>{{ n.type }} <jc-health [state]=\"n.health\" /></p>\n <a mat-stroked-button [routerLink]=\"link(n.id)\" [queryParams]=\"ctx.keep()\">Open</a>\n } @else {\n <p class=\"jc-muted\">Select a node or an edge. Scroll to zoom, drag to pan.</p>\n }\n </aside>\n </div>`,\n})\nexport class TopologyPage implements OnDestroy {\n protected readonly ctx = inject(ContextService);\n private readonly api = inject(ApiService);\n private readonly router = inject(Router);\n private readonly links = inject(ObservabilityLinks);\n\n readonly edge = input<string>();\n readonly node = input<string>();\n\n private readonly graph = viewChild.required<ElementRef<HTMLDivElement>>('graph');\n private cy?: Core;\n private stopThemeWatch?: () => void;\n\n protected readonly topology = apiResource({ params: () => this.ctx.environment(), stream: ({ params }) => this.api.topology(params || null) });\n protected readonly error = computed(() => problemText(this.topology.error()));\n private readonly nodes = computed(() => new Map((this.topology.value()?.nodes ?? []).map(n => [n.id, n])));\n protected readonly selectedEdge = computed(() => this.topology.value()?.edges.find(e => e.id === this.edge()) ?? null);\n protected readonly selectedNode = computed(() => (this.node() ? this.nodes().get(this.node()!) : null) ?? null);\n protected readonly evidence = apiResource({\n // No edge selected: undefined params leave the resource idle.\n params: () => this.edge() ? { edge: this.edge()!, env: this.ctx.environment(), range: this.ctx.range(), abs: this.ctx.absolute() } : undefined,\n stream: ({ params }) => this.api.dependency(params.edge, { environment: params.env, ...this.ctx.window() }),\n });\n\n constructor() {\n afterNextRender(async () => {\n const cytoscape = (await import('cytoscape')).default;\n this.cy = cytoscape({\n container: this.graph().nativeElement,\n wheelSensitivity: 0.3,\n style: this.graphStyle(),\n });\n // The app switched theme (light/dark): restyle and recolour the nodes.\n this.stopThemeWatch = onThemeChange(() => {\n this.cy?.style(this.graphStyle());\n this.draw(this.topology.value());\n });\n this.cy.on('tap', 'edge', e => this.choose({ edge: e.target.id(), node: null }));\n this.cy.on('tap', 'node', e => this.choose({ node: e.target.id(), edge: null }));\n this.cy.on('tap', e => { if (e.target === this.cy) this.choose({ node: null, edge: null }); });\n this.draw(this.topology.value());\n });\n effect(() => this.draw(this.topology.value()));\n effect(() => {\n const id = this.edge() ?? this.node();\n this.cy?.elements().unselect();\n if (id) this.cy?.getElementById(id).select();\n });\n }\n\n private draw(topology: Topology | undefined) {\n if (!this.cy || !topology) return;\n this.cy.elements().remove();\n this.cy.add([\n ...topology.nodes.map(n => ({ data: {\n id: n.id, label: n.displayName, type: n.type,\n color: this.color(n.type === 'service' ? HEALTH_TOKENS[n.health ?? 'Unknown'] ?? 'none' : 'muted') } })),\n ...topology.edges.filter(e => this.nodes().has(e.source) && this.nodes().has(e.target)).map(e => ({ data: {\n id: e.id, source: e.source, target: e.target, confidence: e.confidence.toLowerCase(),\n label: e.confidence.toLowerCase() === 'inferred' ? `${e.relation} (inferred)` : e.relation } })),\n ]);\n this.cy.layout({ name: 'breadthfirst', directed: true, padding: 30, spacingFactor: 1.2 }).run();\n const id = this.edge() ?? this.node();\n if (id) this.cy.getElementById(id).select();\n }\n\n private color(token: string) { return themeColor(token, this.graph().nativeElement); }\n\n /** The graph's look, in the app's theme colours. */\n private graphStyle() {\n const [text, muted, line, surface, selected] = [this.color('text'), this.color('muted'), this.color('border'),\n this.color('surface'), this.color('accent')];\n return [\n { selector: 'node', style: {\n label: 'data(label)', 'font-size': 11, color: text, 'text-valign': 'bottom', 'text-margin-y': 4,\n 'background-color': 'data(color)', width: 26, height: 26, 'border-width': 2, 'border-color': surface } },\n { selector: 'node[type = \"database\"]', style: { shape: 'diamond' } },\n { selector: 'node[type = \"messaging-destination\"]', style: { shape: 'hexagon' } },\n { selector: 'node[type = \"service\"]', style: { shape: 'round-rectangle' } },\n { selector: 'edge', style: {\n width: 2, 'curve-style': 'bezier', 'target-arrow-shape': 'triangle', 'line-color': muted,\n 'target-arrow-color': muted, label: 'data(label)', 'font-size': 9, color: muted, 'text-rotation': 'autorotate',\n 'text-background-color': surface, 'text-background-opacity': 0.8, 'text-background-padding': '1px' } },\n { selector: 'edge[confidence = \"inferred\"]', style: { 'line-style': 'dashed', 'line-color': line, 'target-arrow-color': line } },\n { selector: ':selected', style: { 'line-color': selected, 'target-arrow-color': selected, 'border-color': selected, 'border-width': 3 } },\n ] as StylesheetJson;\n }\n\n fit() { this.cy?.fit(undefined, 30); }\n\n private choose(selection: { edge?: string | null; node?: string | null }) {\n void this.router.navigate([], { queryParams: selection, queryParamsHandling: 'merge', replaceUrl: true });\n }\n\n name(id: string) { return this.nodes().get(id)?.displayName ?? id; }\n\n link(id: string) { return this.links.to(this.nodes().get(id)?.type === 'service' ? 'services' : 'resources', id); }\n\n ngOnDestroy() {\n this.stopThemeWatch?.();\n this.cy?.destroy();\n }\n}\n"],"mappings":";;;;;;;;;;AAmBA,MAAM,gBAAwC;CAC5C,SAAS;CAAM,UAAU;CAAQ,W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,MAAE;IAAe,UAAA;IAAA,QAAA,CAAA,YAAA;GAAA;GAAA;IAAA,MAAA;IAAA,MAApH;IAAQ,MAAA;GAAA;GAAA;IAAA,MAAA;IAAA,MAChB;IAAO,MAAA;GAAA;GAAA;IAAA,MAAA;IAAA,MAAE;IAAY,MAAA;GAAA;GAAA;IAAA,MAAA;IAAA,MAAE;IAAW,MAAA;GAAA;EAAA;EAAA,iBAAA,GAAA,wBAAA;CAAA,CAAA;;AAmDzB,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAY,YAAA,CAAA;EAtDxB,MAAA;EAAU,MAAA,CAAA;GACT,iBAAiB,wBAAwB;GACzC,SAAS;IAAC;IAAU;IAAY;IAAiB;IAAe;IAAsB;IAAY;IAAa;IAC7G;IAAS;IAAc;GAAW;GACpC,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiDX,CAAA;CAUyE,CAAA;CAAA,sBAAA,CAAA;CAAA,gBAAA;EAAA,MAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,MAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,OAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,SAAO,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;CAAA;AAAA,CAAA"}
|
|
@@ -0,0 +1,518 @@
|
|
|
1
|
+
import { ApiService, ContextService, LinkPipe } from "./juice-js-observability.mjs";
|
|
2
|
+
import { a as problemText, b as preciseTime, d as KeyValueTable, h as DurationPipe, l as ContextBar, p as themeColor, t as LogTable, v as formatDuration, x as apiResource, y as plainTraceId } from "./juice-js-observability-telemetry-D9EYxkdr.mjs";
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
import { ChangeDetectionStrategy, Component, computed, inject, input, signal } from "@angular/core";
|
|
5
|
+
import { Router, RouterLink } from "@angular/router";
|
|
6
|
+
import { DatePipe } from "@angular/common";
|
|
7
|
+
import * as i1 from "@angular/material/button";
|
|
8
|
+
import { MatButtonModule } from "@angular/material/button";
|
|
9
|
+
import * as i3 from "@angular/material/progress-bar";
|
|
10
|
+
import { MatProgressBarModule } from "@angular/material/progress-bar";
|
|
11
|
+
import * as i2 from "@angular/material/icon";
|
|
12
|
+
import { MatIconModule } from "@angular/material/icon";
|
|
13
|
+
var TracePage = class TracePage {
|
|
14
|
+
ctx = inject(ContextService);
|
|
15
|
+
api = inject(ApiService);
|
|
16
|
+
router = inject(Router);
|
|
17
|
+
traceId = input.required(...ngDevMode ? [{ debugName: "traceId" }] : /* istanbul ignore next */ []);
|
|
18
|
+
span = input(...ngDevMode ? [void 0, { debugName: "span" }] : /* istanbul ignore next */ []);
|
|
19
|
+
id = computed(() => plainTraceId(this.traceId()), ...ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []);
|
|
20
|
+
trace = apiResource({
|
|
21
|
+
params: () => this.id(),
|
|
22
|
+
stream: ({ params }) => this.api.trace(params)
|
|
23
|
+
});
|
|
24
|
+
error = computed(() => problemText(this.trace.error()), ...ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []);
|
|
25
|
+
collapsed = signal(/* @__PURE__ */ new Set(), ...ngDevMode ? [{ debugName: "collapsed" }] : /* istanbul ignore next */ []);
|
|
26
|
+
showErrorsOnly = signal(false, ...ngDevMode ? [{ debugName: "showErrorsOnly" }] : /* istanbul ignore next */ []);
|
|
27
|
+
selectedId = computed(() => this.span() ?? null, ...ngDevMode ? [{ debugName: "selectedId" }] : /* istanbul ignore next */ []);
|
|
28
|
+
spans = computed(() => this.trace.value()?.spans ?? [], ...ngDevMode ? [{ debugName: "spans" }] : /* istanbul ignore next */ []);
|
|
29
|
+
start = computed(() => Math.min(...this.spans().map((s) => preciseTime(s.startedAt))), ...ngDevMode ? [{ debugName: "start" }] : /* istanbul ignore next */ []);
|
|
30
|
+
total = computed(() => Math.max(.001, Math.max(...this.spans().map((s) => preciseTime(s.startedAt) + s.durationMs)) - this.start()), ...ngDevMode ? [{ debugName: "total" }] : /* istanbul ignore next */ []);
|
|
31
|
+
root = computed(() => this.spans().find((s) => !s.parentSpanId) ?? this.spans()[0], ...ngDevMode ? [{ debugName: "root" }] : /* istanbul ignore next */ []);
|
|
32
|
+
services = computed(() => [...new Set(this.spans().map((s) => s.service))], ...ngDevMode ? [{ debugName: "services" }] : /* istanbul ignore next */ []);
|
|
33
|
+
errors = computed(() => this.spans().filter((s) => s.status === "Error").length, ...ngDevMode ? [{ debugName: "errors" }] : /* istanbul ignore next */ []);
|
|
34
|
+
selected = computed(() => this.spans().find((s) => s.spanId === this.selectedId()) ?? null, ...ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []);
|
|
35
|
+
spanLogQuery = computed(() => {
|
|
36
|
+
const s = this.selected();
|
|
37
|
+
return s ? {
|
|
38
|
+
spanId: s.spanId,
|
|
39
|
+
...this.windowAround(s)
|
|
40
|
+
} : {};
|
|
41
|
+
}, ...ngDevMode ? [{ debugName: "spanLogQuery" }] : /* istanbul ignore next */ []);
|
|
42
|
+
rows = computed(() => {
|
|
43
|
+
const spans = this.spans();
|
|
44
|
+
const ids = new Set(spans.map((s) => s.spanId));
|
|
45
|
+
const byParent = /* @__PURE__ */ new Map();
|
|
46
|
+
for (const s of spans) {
|
|
47
|
+
const parent = s.parentSpanId && ids.has(s.parentSpanId) ? s.parentSpanId : null;
|
|
48
|
+
byParent.set(parent, [...byParent.get(parent) ?? [], s]);
|
|
49
|
+
}
|
|
50
|
+
const slowest = new Set([...spans].sort((a, b) => b.durationMs - a.durationMs).slice(0, Math.max(1, Math.ceil(spans.length * .05))).map((s) => s.spanId));
|
|
51
|
+
const rows = [];
|
|
52
|
+
const walk = (parent, depth) => {
|
|
53
|
+
for (const s of (byParent.get(parent) ?? []).sort((a, b) => a.startedAt.localeCompare(b.startedAt))) {
|
|
54
|
+
rows.push({
|
|
55
|
+
span: s,
|
|
56
|
+
depth,
|
|
57
|
+
children: byParent.get(s.spanId)?.length ?? 0,
|
|
58
|
+
offset: 100 * (preciseTime(s.startedAt) - this.start()) / this.total(),
|
|
59
|
+
selfError: s.status === "Error",
|
|
60
|
+
slowest: slowest.has(s.spanId) && spans.length > 3
|
|
61
|
+
});
|
|
62
|
+
walk(s.spanId, depth + 1);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
walk(null, 0);
|
|
66
|
+
return rows;
|
|
67
|
+
}, ...ngDevMode ? [{ debugName: "rows" }] : /* istanbul ignore next */ []);
|
|
68
|
+
visible = computed(() => {
|
|
69
|
+
const rows = this.rows();
|
|
70
|
+
const parentOf = new Map(this.spans().map((s) => [s.spanId, s.parentSpanId]));
|
|
71
|
+
let keep = null;
|
|
72
|
+
if (this.showErrorsOnly()) {
|
|
73
|
+
keep = /* @__PURE__ */ new Set();
|
|
74
|
+
for (const r of rows.filter((r) => r.selfError)) for (let id = r.span.spanId; id; id = parentOf.get(id)) keep.add(id);
|
|
75
|
+
}
|
|
76
|
+
const out = [];
|
|
77
|
+
let hiddenBelow = null;
|
|
78
|
+
for (const r of rows) {
|
|
79
|
+
if (hiddenBelow !== null && r.depth > hiddenBelow) continue;
|
|
80
|
+
hiddenBelow = null;
|
|
81
|
+
if (keep && !keep.has(r.span.spanId)) continue;
|
|
82
|
+
out.push(r);
|
|
83
|
+
if (this.collapsed().has(r.span.spanId)) hiddenBelow = r.depth;
|
|
84
|
+
}
|
|
85
|
+
return out;
|
|
86
|
+
}, ...ngDevMode ? [{ debugName: "visible" }] : /* istanbul ignore next */ []);
|
|
87
|
+
ticks = computed(() => [
|
|
88
|
+
0,
|
|
89
|
+
25,
|
|
90
|
+
50,
|
|
91
|
+
75
|
|
92
|
+
].map((at) => ({
|
|
93
|
+
at,
|
|
94
|
+
label: formatDuration(this.total() * at / 100)
|
|
95
|
+
})), ...ngDevMode ? [{ debugName: "ticks" }] : /* istanbul ignore next */ []);
|
|
96
|
+
seriesCount = Math.max(1, Number(themeColor("series-count")) || 1);
|
|
97
|
+
color(service) {
|
|
98
|
+
return `var(--jc-series-${this.services().indexOf(service) % this.seriesCount + 1})`;
|
|
99
|
+
}
|
|
100
|
+
width(span) {
|
|
101
|
+
return Math.max(.3, 100 * span.durationMs / this.total());
|
|
102
|
+
}
|
|
103
|
+
offsetMs(span) {
|
|
104
|
+
return preciseTime(span.startedAt) - this.start();
|
|
105
|
+
}
|
|
106
|
+
eventOffset(span, at) {
|
|
107
|
+
return preciseTime(at) - preciseTime(span.startedAt);
|
|
108
|
+
}
|
|
109
|
+
toggle(spanId, event) {
|
|
110
|
+
event.stopPropagation();
|
|
111
|
+
const next = new Set(this.collapsed());
|
|
112
|
+
if (!next.delete(spanId)) next.add(spanId);
|
|
113
|
+
this.collapsed.set(next);
|
|
114
|
+
}
|
|
115
|
+
select(spanId) {
|
|
116
|
+
this.router.navigate([], {
|
|
117
|
+
queryParams: { span: spanId },
|
|
118
|
+
queryParamsHandling: "merge",
|
|
119
|
+
replaceUrl: true
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
windowAround(span) {
|
|
123
|
+
const start = new Date(span.startedAt).getTime();
|
|
124
|
+
return {
|
|
125
|
+
from: (/* @__PURE__ */ new Date(start - 6e4)).toISOString(),
|
|
126
|
+
to: new Date(start + span.durationMs + 6e4).toISOString()
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
aroundSpan(span, extra) {
|
|
130
|
+
return {
|
|
131
|
+
...this.ctx.around(span.startedAt, span.durationMs),
|
|
132
|
+
...extra
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
136
|
+
minVersion: "12.0.0",
|
|
137
|
+
version: "22.2.4",
|
|
138
|
+
ngImport: i0,
|
|
139
|
+
type: TracePage,
|
|
140
|
+
deps: [],
|
|
141
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
142
|
+
});
|
|
143
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
144
|
+
minVersion: "17.0.0",
|
|
145
|
+
version: "22.2.4",
|
|
146
|
+
type: TracePage,
|
|
147
|
+
isStandalone: true,
|
|
148
|
+
selector: "ng-component",
|
|
149
|
+
inputs: {
|
|
150
|
+
traceId: {
|
|
151
|
+
classPropertyName: "traceId",
|
|
152
|
+
publicName: "traceId",
|
|
153
|
+
isSignal: true,
|
|
154
|
+
isRequired: true,
|
|
155
|
+
transformFunction: null
|
|
156
|
+
},
|
|
157
|
+
span: {
|
|
158
|
+
classPropertyName: "span",
|
|
159
|
+
publicName: "span",
|
|
160
|
+
isSignal: true,
|
|
161
|
+
isRequired: false,
|
|
162
|
+
transformFunction: null
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
host: { classAttribute: "jc-fill-page" },
|
|
166
|
+
ngImport: i0,
|
|
167
|
+
template: `
|
|
168
|
+
<jc-context-bar>
|
|
169
|
+
<a [routerLink]="['traces'] | jcLink" [queryParams]="ctx.keep()" class="jc-crumb">Traces</a>
|
|
170
|
+
<span class="jc-crumb-sep">›</span>
|
|
171
|
+
<h1 class="jc-mono">{{ id() }}</h1>
|
|
172
|
+
</jc-context-bar>
|
|
173
|
+
@if (trace.isLoading()) { <mat-progress-bar mode="indeterminate" /> }
|
|
174
|
+
@if (trace.error()) { <p class="jc-error">{{ error() }}</p> }
|
|
175
|
+
|
|
176
|
+
@if (trace.value(); as t) {
|
|
177
|
+
<div class="jc-summary">
|
|
178
|
+
<span><strong>{{ root()?.service }}</strong> · {{ root()?.name }}</span>
|
|
179
|
+
<span>{{ start() | date: 'MMM d, HH:mm:ss.SSS' }}</span>
|
|
180
|
+
<span>{{ total() | duration }}</span>
|
|
181
|
+
<span>{{ t.spans.length }} spans · {{ services().length }} services</span>
|
|
182
|
+
@if (errors() > 0) { <span class="jc-badge jc-health-unhealthy">{{ errors() }} failed</span> }
|
|
183
|
+
<button mat-button (click)="showErrorsOnly.set(!showErrorsOnly())">{{ showErrorsOnly() ? 'Show all spans' : 'Error paths only' }}</button>
|
|
184
|
+
<a mat-button [routerLink]="['logs'] | jcLink" [queryParams]="ctx.keep({ trace: id() })">Logs of this trace</a>
|
|
185
|
+
@if (t.truncated) { <span class="jc-muted">Showing the first {{ t.spans.length }} spans.</span> }
|
|
186
|
+
</div>
|
|
187
|
+
<div class="jc-legend">@for (s of services(); track s) { <span><i [style.background]="color(s)"></i>{{ s }}</span> }</div>
|
|
188
|
+
|
|
189
|
+
<div class="jc-trace" [class.jc-with-detail]="selected()">
|
|
190
|
+
<div class="jc-waterfall" role="tree">
|
|
191
|
+
<div class="jc-wf-head"><span>Span</span><span class="jc-wf-scale">
|
|
192
|
+
@for (tick of ticks(); track tick.at) { <span [style.left.%]="tick.at">{{ tick.label }}</span> }</span></div>
|
|
193
|
+
@for (r of visible(); track r.span.spanId) {
|
|
194
|
+
<div class="jc-wf-row" role="treeitem" [class.jc-selected]="r.span.spanId === selectedId()"
|
|
195
|
+
[class.jc-wf-error]="r.selfError" (click)="select(r.span.spanId)" tabindex="0" (keydown.enter)="select(r.span.spanId)">
|
|
196
|
+
<span class="jc-wf-name" [style.padding-left.px]="r.depth * 14">
|
|
197
|
+
@if (r.children > 0) {
|
|
198
|
+
<button class="jc-wf-toggle" (click)="toggle(r.span.spanId, $event)" [attr.aria-label]="collapsed().has(r.span.spanId) ? 'Expand' : 'Collapse'">
|
|
199
|
+
{{ collapsed().has(r.span.spanId) ? '▸' : '▾' }}</button>
|
|
200
|
+
} @else { <span class="jc-wf-toggle"></span> }
|
|
201
|
+
<i class="jc-dot" [style.background]="color(r.span.service)"></i>
|
|
202
|
+
<span class="jc-wf-service">{{ r.span.service }}</span> <span>{{ r.span.name }}</span>
|
|
203
|
+
@if (r.selfError) { <mat-icon class="jc-wf-icon jc-bad" title="Failed">error</mat-icon> }
|
|
204
|
+
@if (r.slowest) { <mat-icon class="jc-wf-icon" title="Among the slowest spans">schedule</mat-icon> }
|
|
205
|
+
@if (collapsed().has(r.span.spanId)) { <span class="jc-muted jc-small">+{{ r.children }}</span> }
|
|
206
|
+
</span>
|
|
207
|
+
<span class="jc-wf-track">
|
|
208
|
+
<span class="jc-wf-bar" [style.left.%]="r.offset" [style.width.%]="width(r.span)" [style.background]="color(r.span.service)"></span>
|
|
209
|
+
<span class="jc-wf-time" [style.left.%]="r.offset">{{ r.span.durationMs | duration }}</span>
|
|
210
|
+
</span>
|
|
211
|
+
</div>
|
|
212
|
+
}
|
|
213
|
+
</div>
|
|
214
|
+
|
|
215
|
+
@if (selected(); as s) {
|
|
216
|
+
<aside class="jc-card jc-span-detail">
|
|
217
|
+
<div class="jc-row"><h2>{{ s.name }}</h2><button mat-icon-button (click)="select(null)" aria-label="Close"><mat-icon>close</mat-icon></button></div>
|
|
218
|
+
<div class="jc-span-facts">
|
|
219
|
+
<span class="jc-badge" [class.jc-health-unhealthy]="s.status === 'Error'" [class.jc-health-healthy]="s.status === 'Ok'">{{ s.status }}</span>
|
|
220
|
+
<span>{{ s.kind }}</span><span>{{ s.durationMs | duration }}</span>
|
|
221
|
+
<span>at +{{ offsetMs(s) | duration }}</span>
|
|
222
|
+
</div>
|
|
223
|
+
@if (s.statusMessage) { <p class="jc-error">{{ s.statusMessage }}</p> }
|
|
224
|
+
|
|
225
|
+
<nav class="jc-actions">
|
|
226
|
+
@if (s.serviceId) { <a mat-stroked-button [routerLink]="['services', s.serviceId] | jcLink" [queryParams]="ctx.keep()">Service {{ s.service }}</a> }
|
|
227
|
+
@if (s.target; as target) {
|
|
228
|
+
<a mat-stroked-button [routerLink]="(target.kind === 'service' ? ['services', target.id] : ['resources', target.id]) | jcLink" [queryParams]="ctx.keep()">
|
|
229
|
+
{{ target.kind === 'service' ? 'Calls' : 'Uses' }} {{ target.name }}</a>
|
|
230
|
+
}
|
|
231
|
+
@if (s.serviceId) {
|
|
232
|
+
<a mat-stroked-button [routerLink]="['services', s.serviceId] | jcLink" [queryParams]="aroundSpan(s, { tab: 'metrics' })">Metrics around</a>
|
|
233
|
+
<a mat-stroked-button [routerLink]="['services', s.serviceId] | jcLink" [queryParams]="aroundSpan(s, { tab: 'logs' })">Service logs around</a>
|
|
234
|
+
<a mat-stroked-button [routerLink]="['services', s.serviceId] | jcLink" [queryParams]="ctx.keep({ tab: 'traces', op: s.name })">Other traces of {{ s.name }}</a>
|
|
235
|
+
}
|
|
236
|
+
</nav>
|
|
237
|
+
|
|
238
|
+
<h3>Logs of this span</h3>
|
|
239
|
+
<jc-log-table [query]="spanLogQuery()" [compact]="true" />
|
|
240
|
+
|
|
241
|
+
<h3>Span</h3>
|
|
242
|
+
<jc-kv [values]="{ 'service': s.service, 'environment': s.environment, 'instance': s.instance, 'host': s.host,
|
|
243
|
+
'trace id': id(), 'span id': s.spanId, 'parent span id': s.parentSpanId, 'started': s.startedAt,
|
|
244
|
+
'instrumentation scope': s.scope ? s.scope + (s.scopeVersion ? ' ' + s.scopeVersion : '') : null }" />
|
|
245
|
+
<h3>Attributes</h3>
|
|
246
|
+
<jc-kv [values]="s.attributes" empty="No attributes." />
|
|
247
|
+
@if (s.events.length) {
|
|
248
|
+
<h3>Events</h3>
|
|
249
|
+
@for (e of s.events; track $index) {
|
|
250
|
+
<div class="jc-event" [class.jc-wf-error]="e.name === 'exception'">
|
|
251
|
+
<strong>{{ e.name }}</strong> <span class="jc-muted">+{{ eventOffset(s, e.at) | duration }}</span>
|
|
252
|
+
<jc-kv [values]="e.attributes" empty="" />
|
|
253
|
+
</div>
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
@if (s.links.length) {
|
|
257
|
+
<h3>Links</h3>
|
|
258
|
+
@for (l of s.links; track l.spanId) {
|
|
259
|
+
<a [routerLink]="['traces', l.traceId] | jcLink" [queryParams]="ctx.keep({ span: l.spanId })" class="jc-mono">{{ l.traceId }} / {{ l.spanId }}</a>
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
</aside>
|
|
263
|
+
}
|
|
264
|
+
</div>
|
|
265
|
+
}`,
|
|
266
|
+
isInline: true,
|
|
267
|
+
dependencies: [
|
|
268
|
+
{
|
|
269
|
+
kind: "directive",
|
|
270
|
+
type: RouterLink,
|
|
271
|
+
selector: "[routerLink]",
|
|
272
|
+
inputs: [
|
|
273
|
+
"target",
|
|
274
|
+
"queryParams",
|
|
275
|
+
"fragment",
|
|
276
|
+
"queryParamsHandling",
|
|
277
|
+
"state",
|
|
278
|
+
"info",
|
|
279
|
+
"relativeTo",
|
|
280
|
+
"preserveFragment",
|
|
281
|
+
"skipLocationChange",
|
|
282
|
+
"replaceUrl",
|
|
283
|
+
"browserUrl",
|
|
284
|
+
"routerLink"
|
|
285
|
+
]
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
kind: "ngmodule",
|
|
289
|
+
type: MatButtonModule
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
kind: "component",
|
|
293
|
+
type: i1.MatButton,
|
|
294
|
+
selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ",
|
|
295
|
+
inputs: ["matButton"],
|
|
296
|
+
exportAs: ["matButton", "matAnchor"]
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
kind: "component",
|
|
300
|
+
type: i1.MatIconButton,
|
|
301
|
+
selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]",
|
|
302
|
+
exportAs: ["matButton", "matAnchor"]
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
kind: "ngmodule",
|
|
306
|
+
type: MatIconModule
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
kind: "component",
|
|
310
|
+
type: i2.MatIcon,
|
|
311
|
+
selector: "mat-icon",
|
|
312
|
+
inputs: [
|
|
313
|
+
"color",
|
|
314
|
+
"inline",
|
|
315
|
+
"svgIcon",
|
|
316
|
+
"fontSet",
|
|
317
|
+
"fontIcon"
|
|
318
|
+
],
|
|
319
|
+
exportAs: ["matIcon"]
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
kind: "ngmodule",
|
|
323
|
+
type: MatProgressBarModule
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
kind: "component",
|
|
327
|
+
type: i3.MatProgressBar,
|
|
328
|
+
selector: "mat-progress-bar",
|
|
329
|
+
inputs: [
|
|
330
|
+
"color",
|
|
331
|
+
"value",
|
|
332
|
+
"bufferValue",
|
|
333
|
+
"mode"
|
|
334
|
+
],
|
|
335
|
+
outputs: ["animationEnd"],
|
|
336
|
+
exportAs: ["matProgressBar"]
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
kind: "component",
|
|
340
|
+
type: ContextBar,
|
|
341
|
+
selector: "jc-context-bar"
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
kind: "component",
|
|
345
|
+
type: KeyValueTable,
|
|
346
|
+
selector: "jc-kv",
|
|
347
|
+
inputs: ["values", "empty"]
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
kind: "component",
|
|
351
|
+
type: LogTable,
|
|
352
|
+
selector: "jc-log-table",
|
|
353
|
+
inputs: ["query", "compact"]
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
kind: "pipe",
|
|
357
|
+
type: LinkPipe,
|
|
358
|
+
name: "jcLink"
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
kind: "pipe",
|
|
362
|
+
type: DatePipe,
|
|
363
|
+
name: "date"
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
kind: "pipe",
|
|
367
|
+
type: DurationPipe,
|
|
368
|
+
name: "duration"
|
|
369
|
+
}
|
|
370
|
+
],
|
|
371
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
372
|
+
});
|
|
373
|
+
};
|
|
374
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
375
|
+
minVersion: "12.0.0",
|
|
376
|
+
version: "22.2.4",
|
|
377
|
+
ngImport: i0,
|
|
378
|
+
type: TracePage,
|
|
379
|
+
decorators: [{
|
|
380
|
+
type: Component,
|
|
381
|
+
args: [{
|
|
382
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
383
|
+
host: { class: "jc-fill-page" },
|
|
384
|
+
imports: [
|
|
385
|
+
LinkPipe,
|
|
386
|
+
RouterLink,
|
|
387
|
+
DatePipe,
|
|
388
|
+
MatButtonModule,
|
|
389
|
+
MatIconModule,
|
|
390
|
+
MatProgressBarModule,
|
|
391
|
+
ContextBar,
|
|
392
|
+
KeyValueTable,
|
|
393
|
+
LogTable,
|
|
394
|
+
DurationPipe
|
|
395
|
+
],
|
|
396
|
+
template: `
|
|
397
|
+
<jc-context-bar>
|
|
398
|
+
<a [routerLink]="['traces'] | jcLink" [queryParams]="ctx.keep()" class="jc-crumb">Traces</a>
|
|
399
|
+
<span class="jc-crumb-sep">›</span>
|
|
400
|
+
<h1 class="jc-mono">{{ id() }}</h1>
|
|
401
|
+
</jc-context-bar>
|
|
402
|
+
@if (trace.isLoading()) { <mat-progress-bar mode="indeterminate" /> }
|
|
403
|
+
@if (trace.error()) { <p class="jc-error">{{ error() }}</p> }
|
|
404
|
+
|
|
405
|
+
@if (trace.value(); as t) {
|
|
406
|
+
<div class="jc-summary">
|
|
407
|
+
<span><strong>{{ root()?.service }}</strong> · {{ root()?.name }}</span>
|
|
408
|
+
<span>{{ start() | date: 'MMM d, HH:mm:ss.SSS' }}</span>
|
|
409
|
+
<span>{{ total() | duration }}</span>
|
|
410
|
+
<span>{{ t.spans.length }} spans · {{ services().length }} services</span>
|
|
411
|
+
@if (errors() > 0) { <span class="jc-badge jc-health-unhealthy">{{ errors() }} failed</span> }
|
|
412
|
+
<button mat-button (click)="showErrorsOnly.set(!showErrorsOnly())">{{ showErrorsOnly() ? 'Show all spans' : 'Error paths only' }}</button>
|
|
413
|
+
<a mat-button [routerLink]="['logs'] | jcLink" [queryParams]="ctx.keep({ trace: id() })">Logs of this trace</a>
|
|
414
|
+
@if (t.truncated) { <span class="jc-muted">Showing the first {{ t.spans.length }} spans.</span> }
|
|
415
|
+
</div>
|
|
416
|
+
<div class="jc-legend">@for (s of services(); track s) { <span><i [style.background]="color(s)"></i>{{ s }}</span> }</div>
|
|
417
|
+
|
|
418
|
+
<div class="jc-trace" [class.jc-with-detail]="selected()">
|
|
419
|
+
<div class="jc-waterfall" role="tree">
|
|
420
|
+
<div class="jc-wf-head"><span>Span</span><span class="jc-wf-scale">
|
|
421
|
+
@for (tick of ticks(); track tick.at) { <span [style.left.%]="tick.at">{{ tick.label }}</span> }</span></div>
|
|
422
|
+
@for (r of visible(); track r.span.spanId) {
|
|
423
|
+
<div class="jc-wf-row" role="treeitem" [class.jc-selected]="r.span.spanId === selectedId()"
|
|
424
|
+
[class.jc-wf-error]="r.selfError" (click)="select(r.span.spanId)" tabindex="0" (keydown.enter)="select(r.span.spanId)">
|
|
425
|
+
<span class="jc-wf-name" [style.padding-left.px]="r.depth * 14">
|
|
426
|
+
@if (r.children > 0) {
|
|
427
|
+
<button class="jc-wf-toggle" (click)="toggle(r.span.spanId, $event)" [attr.aria-label]="collapsed().has(r.span.spanId) ? 'Expand' : 'Collapse'">
|
|
428
|
+
{{ collapsed().has(r.span.spanId) ? '▸' : '▾' }}</button>
|
|
429
|
+
} @else { <span class="jc-wf-toggle"></span> }
|
|
430
|
+
<i class="jc-dot" [style.background]="color(r.span.service)"></i>
|
|
431
|
+
<span class="jc-wf-service">{{ r.span.service }}</span> <span>{{ r.span.name }}</span>
|
|
432
|
+
@if (r.selfError) { <mat-icon class="jc-wf-icon jc-bad" title="Failed">error</mat-icon> }
|
|
433
|
+
@if (r.slowest) { <mat-icon class="jc-wf-icon" title="Among the slowest spans">schedule</mat-icon> }
|
|
434
|
+
@if (collapsed().has(r.span.spanId)) { <span class="jc-muted jc-small">+{{ r.children }}</span> }
|
|
435
|
+
</span>
|
|
436
|
+
<span class="jc-wf-track">
|
|
437
|
+
<span class="jc-wf-bar" [style.left.%]="r.offset" [style.width.%]="width(r.span)" [style.background]="color(r.span.service)"></span>
|
|
438
|
+
<span class="jc-wf-time" [style.left.%]="r.offset">{{ r.span.durationMs | duration }}</span>
|
|
439
|
+
</span>
|
|
440
|
+
</div>
|
|
441
|
+
}
|
|
442
|
+
</div>
|
|
443
|
+
|
|
444
|
+
@if (selected(); as s) {
|
|
445
|
+
<aside class="jc-card jc-span-detail">
|
|
446
|
+
<div class="jc-row"><h2>{{ s.name }}</h2><button mat-icon-button (click)="select(null)" aria-label="Close"><mat-icon>close</mat-icon></button></div>
|
|
447
|
+
<div class="jc-span-facts">
|
|
448
|
+
<span class="jc-badge" [class.jc-health-unhealthy]="s.status === 'Error'" [class.jc-health-healthy]="s.status === 'Ok'">{{ s.status }}</span>
|
|
449
|
+
<span>{{ s.kind }}</span><span>{{ s.durationMs | duration }}</span>
|
|
450
|
+
<span>at +{{ offsetMs(s) | duration }}</span>
|
|
451
|
+
</div>
|
|
452
|
+
@if (s.statusMessage) { <p class="jc-error">{{ s.statusMessage }}</p> }
|
|
453
|
+
|
|
454
|
+
<nav class="jc-actions">
|
|
455
|
+
@if (s.serviceId) { <a mat-stroked-button [routerLink]="['services', s.serviceId] | jcLink" [queryParams]="ctx.keep()">Service {{ s.service }}</a> }
|
|
456
|
+
@if (s.target; as target) {
|
|
457
|
+
<a mat-stroked-button [routerLink]="(target.kind === 'service' ? ['services', target.id] : ['resources', target.id]) | jcLink" [queryParams]="ctx.keep()">
|
|
458
|
+
{{ target.kind === 'service' ? 'Calls' : 'Uses' }} {{ target.name }}</a>
|
|
459
|
+
}
|
|
460
|
+
@if (s.serviceId) {
|
|
461
|
+
<a mat-stroked-button [routerLink]="['services', s.serviceId] | jcLink" [queryParams]="aroundSpan(s, { tab: 'metrics' })">Metrics around</a>
|
|
462
|
+
<a mat-stroked-button [routerLink]="['services', s.serviceId] | jcLink" [queryParams]="aroundSpan(s, { tab: 'logs' })">Service logs around</a>
|
|
463
|
+
<a mat-stroked-button [routerLink]="['services', s.serviceId] | jcLink" [queryParams]="ctx.keep({ tab: 'traces', op: s.name })">Other traces of {{ s.name }}</a>
|
|
464
|
+
}
|
|
465
|
+
</nav>
|
|
466
|
+
|
|
467
|
+
<h3>Logs of this span</h3>
|
|
468
|
+
<jc-log-table [query]="spanLogQuery()" [compact]="true" />
|
|
469
|
+
|
|
470
|
+
<h3>Span</h3>
|
|
471
|
+
<jc-kv [values]="{ 'service': s.service, 'environment': s.environment, 'instance': s.instance, 'host': s.host,
|
|
472
|
+
'trace id': id(), 'span id': s.spanId, 'parent span id': s.parentSpanId, 'started': s.startedAt,
|
|
473
|
+
'instrumentation scope': s.scope ? s.scope + (s.scopeVersion ? ' ' + s.scopeVersion : '') : null }" />
|
|
474
|
+
<h3>Attributes</h3>
|
|
475
|
+
<jc-kv [values]="s.attributes" empty="No attributes." />
|
|
476
|
+
@if (s.events.length) {
|
|
477
|
+
<h3>Events</h3>
|
|
478
|
+
@for (e of s.events; track $index) {
|
|
479
|
+
<div class="jc-event" [class.jc-wf-error]="e.name === 'exception'">
|
|
480
|
+
<strong>{{ e.name }}</strong> <span class="jc-muted">+{{ eventOffset(s, e.at) | duration }}</span>
|
|
481
|
+
<jc-kv [values]="e.attributes" empty="" />
|
|
482
|
+
</div>
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
@if (s.links.length) {
|
|
486
|
+
<h3>Links</h3>
|
|
487
|
+
@for (l of s.links; track l.spanId) {
|
|
488
|
+
<a [routerLink]="['traces', l.traceId] | jcLink" [queryParams]="ctx.keep({ span: l.spanId })" class="jc-mono">{{ l.traceId }} / {{ l.spanId }}</a>
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
</aside>
|
|
492
|
+
}
|
|
493
|
+
</div>
|
|
494
|
+
}`
|
|
495
|
+
}]
|
|
496
|
+
}],
|
|
497
|
+
propDecorators: {
|
|
498
|
+
traceId: [{
|
|
499
|
+
type: i0.Input,
|
|
500
|
+
args: [{
|
|
501
|
+
isSignal: true,
|
|
502
|
+
alias: "traceId",
|
|
503
|
+
required: true
|
|
504
|
+
}]
|
|
505
|
+
}],
|
|
506
|
+
span: [{
|
|
507
|
+
type: i0.Input,
|
|
508
|
+
args: [{
|
|
509
|
+
isSignal: true,
|
|
510
|
+
alias: "span",
|
|
511
|
+
required: false
|
|
512
|
+
}]
|
|
513
|
+
}]
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
export { TracePage };
|
|
517
|
+
|
|
518
|
+
//# sourceMappingURL=juice-js-observability-trace.page-DccvH1SV.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"juice-js-observability-trace.page-DccvH1SV.mjs","names":[],"sources":["../../../../projects/juice-js/observability/src/lib/pages/trace.page.ts"],"sourcesContent":["import { LinkPipe } from '../core/options';\nimport { ChangeDetectionStrategy, Component, computed, inject, input, signal } from '@angular/core';\nimport { apiResource } from '../shared/resource';\nimport { DatePipe } from '@angular/common';\nimport { MatButtonModule } from '@angular/material/button';\nimport { MatIconModule } from '@angular/material/icon';\nimport { MatProgressBarModule } from '@angular/material/progress-bar';\nimport { Router, RouterLink } from '@angular/router';\nimport { ApiService } from '../core/api.service';\nimport { ContextService } from '../core/context.service';\nimport { Span } from '../core/models';\nimport { DurationPipe, formatDuration, plainTraceId, preciseTime } from '../shared/format';\nimport { ContextBar, KeyValueTable } from '../shared/ui';\nimport { LogTable, problemText } from '../shared/telemetry';\nimport { themeColor } from '../shared/theme';\n\ninterface Row { span: Span; depth: number; children: number; offset: number; selfError: boolean; slowest: boolean; }\n\n/** A stable colour per service, from a small palette that reads in both themes. */\n\n/**\n * A trace as a waterfall (Console requirements §6): the span hierarchy with timing relative to the trace start, so\n * parallel calls show side by side; errors and the slowest spans marked; subtrees collapsible. The selected span is\n * in the URL (`span`), with its details, its logs, and links to its service, its dependency, and the metrics and logs\n * around it (§7).\n */\n@Component({\n changeDetection: ChangeDetectionStrategy.OnPush,\n // Fills the window; the waterfall and the span scroll on their own (styles.scss).\n host: { class: 'jc-fill-page' },\n imports: [LinkPipe, RouterLink, DatePipe, MatButtonModule, MatIconModule, MatProgressBarModule, ContextBar, KeyValueTable, LogTable, DurationPipe],\n template: `\n <jc-context-bar>\n <a [routerLink]=\"['traces'] | jcLink\" [queryParams]=\"ctx.keep()\" class=\"jc-crumb\">Traces</a>\n <span class=\"jc-crumb-sep\">›</span>\n <h1 class=\"jc-mono\">{{ id() }}</h1>\n </jc-context-bar>\n @if (trace.isLoading()) { <mat-progress-bar mode=\"indeterminate\" /> }\n @if (trace.error()) { <p class=\"jc-error\">{{ error() }}</p> }\n\n @if (trace.value(); as t) {\n <div class=\"jc-summary\">\n <span><strong>{{ root()?.service }}</strong> · {{ root()?.name }}</span>\n <span>{{ start() | date: 'MMM d, HH:mm:ss.SSS' }}</span>\n <span>{{ total() | duration }}</span>\n <span>{{ t.spans.length }} spans · {{ services().length }} services</span>\n @if (errors() > 0) { <span class=\"jc-badge jc-health-unhealthy\">{{ errors() }} failed</span> }\n <button mat-button (click)=\"showErrorsOnly.set(!showErrorsOnly())\">{{ showErrorsOnly() ? 'Show all spans' : 'Error paths only' }}</button>\n <a mat-button [routerLink]=\"['logs'] | jcLink\" [queryParams]=\"ctx.keep({ trace: id() })\">Logs of this trace</a>\n @if (t.truncated) { <span class=\"jc-muted\">Showing the first {{ t.spans.length }} spans.</span> }\n </div>\n <div class=\"jc-legend\">@for (s of services(); track s) { <span><i [style.background]=\"color(s)\"></i>{{ s }}</span> }</div>\n\n <div class=\"jc-trace\" [class.jc-with-detail]=\"selected()\">\n <div class=\"jc-waterfall\" role=\"tree\">\n <div class=\"jc-wf-head\"><span>Span</span><span class=\"jc-wf-scale\">\n @for (tick of ticks(); track tick.at) { <span [style.left.%]=\"tick.at\">{{ tick.label }}</span> }</span></div>\n @for (r of visible(); track r.span.spanId) {\n <div class=\"jc-wf-row\" role=\"treeitem\" [class.jc-selected]=\"r.span.spanId === selectedId()\"\n [class.jc-wf-error]=\"r.selfError\" (click)=\"select(r.span.spanId)\" tabindex=\"0\" (keydown.enter)=\"select(r.span.spanId)\">\n <span class=\"jc-wf-name\" [style.padding-left.px]=\"r.depth * 14\">\n @if (r.children > 0) {\n <button class=\"jc-wf-toggle\" (click)=\"toggle(r.span.spanId, $event)\" [attr.aria-label]=\"collapsed().has(r.span.spanId) ? 'Expand' : 'Collapse'\">\n {{ collapsed().has(r.span.spanId) ? '▸' : '▾' }}</button>\n } @else { <span class=\"jc-wf-toggle\"></span> }\n <i class=\"jc-dot\" [style.background]=\"color(r.span.service)\"></i>\n <span class=\"jc-wf-service\">{{ r.span.service }}</span> <span>{{ r.span.name }}</span>\n @if (r.selfError) { <mat-icon class=\"jc-wf-icon jc-bad\" title=\"Failed\">error</mat-icon> }\n @if (r.slowest) { <mat-icon class=\"jc-wf-icon\" title=\"Among the slowest spans\">schedule</mat-icon> }\n @if (collapsed().has(r.span.spanId)) { <span class=\"jc-muted jc-small\">+{{ r.children }}</span> }\n </span>\n <span class=\"jc-wf-track\">\n <span class=\"jc-wf-bar\" [style.left.%]=\"r.offset\" [style.width.%]=\"width(r.span)\" [style.background]=\"color(r.span.service)\"></span>\n <span class=\"jc-wf-time\" [style.left.%]=\"r.offset\">{{ r.span.durationMs | duration }}</span>\n </span>\n </div>\n }\n </div>\n\n @if (selected(); as s) {\n <aside class=\"jc-card jc-span-detail\">\n <div class=\"jc-row\"><h2>{{ s.name }}</h2><button mat-icon-button (click)=\"select(null)\" aria-label=\"Close\"><mat-icon>close</mat-icon></button></div>\n <div class=\"jc-span-facts\">\n <span class=\"jc-badge\" [class.jc-health-unhealthy]=\"s.status === 'Error'\" [class.jc-health-healthy]=\"s.status === 'Ok'\">{{ s.status }}</span>\n <span>{{ s.kind }}</span><span>{{ s.durationMs | duration }}</span>\n <span>at +{{ offsetMs(s) | duration }}</span>\n </div>\n @if (s.statusMessage) { <p class=\"jc-error\">{{ s.statusMessage }}</p> }\n\n <nav class=\"jc-actions\">\n @if (s.serviceId) { <a mat-stroked-button [routerLink]=\"['services', s.serviceId] | jcLink\" [queryParams]=\"ctx.keep()\">Service {{ s.service }}</a> }\n @if (s.target; as target) {\n <a mat-stroked-button [routerLink]=\"(target.kind === 'service' ? ['services', target.id] : ['resources', target.id]) | jcLink\" [queryParams]=\"ctx.keep()\">\n {{ target.kind === 'service' ? 'Calls' : 'Uses' }} {{ target.name }}</a>\n }\n @if (s.serviceId) {\n <a mat-stroked-button [routerLink]=\"['services', s.serviceId] | jcLink\" [queryParams]=\"aroundSpan(s, { tab: 'metrics' })\">Metrics around</a>\n <a mat-stroked-button [routerLink]=\"['services', s.serviceId] | jcLink\" [queryParams]=\"aroundSpan(s, { tab: 'logs' })\">Service logs around</a>\n <a mat-stroked-button [routerLink]=\"['services', s.serviceId] | jcLink\" [queryParams]=\"ctx.keep({ tab: 'traces', op: s.name })\">Other traces of {{ s.name }}</a>\n }\n </nav>\n\n <h3>Logs of this span</h3>\n <jc-log-table [query]=\"spanLogQuery()\" [compact]=\"true\" />\n\n <h3>Span</h3>\n <jc-kv [values]=\"{ 'service': s.service, 'environment': s.environment, 'instance': s.instance, 'host': s.host,\n 'trace id': id(), 'span id': s.spanId, 'parent span id': s.parentSpanId, 'started': s.startedAt,\n 'instrumentation scope': s.scope ? s.scope + (s.scopeVersion ? ' ' + s.scopeVersion : '') : null }\" />\n <h3>Attributes</h3>\n <jc-kv [values]=\"s.attributes\" empty=\"No attributes.\" />\n @if (s.events.length) {\n <h3>Events</h3>\n @for (e of s.events; track $index) {\n <div class=\"jc-event\" [class.jc-wf-error]=\"e.name === 'exception'\">\n <strong>{{ e.name }}</strong> <span class=\"jc-muted\">+{{ eventOffset(s, e.at) | duration }}</span>\n <jc-kv [values]=\"e.attributes\" empty=\"\" />\n </div>\n }\n }\n @if (s.links.length) {\n <h3>Links</h3>\n @for (l of s.links; track l.spanId) {\n <a [routerLink]=\"['traces', l.traceId] | jcLink\" [queryParams]=\"ctx.keep({ span: l.spanId })\" class=\"jc-mono\">{{ l.traceId }} / {{ l.spanId }}</a>\n }\n }\n </aside>\n }\n </div>\n }`,\n})\nexport class TracePage {\n protected readonly ctx = inject(ContextService);\n private readonly api = inject(ApiService);\n private readonly router = inject(Router);\n\n /** A trace id, or a W3C traceparent such as a Juice.Audit record before 10.4 holds; links from either open the trace. */\n readonly traceId = input.required<string>();\n readonly span = input<string>();\n\n protected readonly id = computed(() => plainTraceId(this.traceId()));\n protected readonly trace = apiResource({ params: () => this.id(), stream: ({ params }) => this.api.trace(params) });\n protected readonly error = computed(() => problemText(this.trace.error()));\n protected readonly collapsed = signal(new Set<string>());\n protected readonly showErrorsOnly = signal(false);\n protected readonly selectedId = computed(() => this.span() ?? null);\n\n private readonly spans = computed(() => this.trace.value()?.spans ?? []);\n // Sub-millisecond precision: spans of a fast in-process flow start microseconds apart.\n protected readonly start = computed(() => Math.min(...this.spans().map(s => preciseTime(s.startedAt))));\n protected readonly total = computed(() =>\n Math.max(0.001, Math.max(...this.spans().map(s => preciseTime(s.startedAt) + s.durationMs)) - this.start()));\n protected readonly root = computed(() => this.spans().find(s => !s.parentSpanId) ?? this.spans()[0]);\n protected readonly services = computed(() => [...new Set(this.spans().map(s => s.service))]);\n protected readonly errors = computed(() => this.spans().filter(s => s.status === 'Error').length);\n protected readonly selected = computed(() => this.spans().find(s => s.spanId === this.selectedId()) ?? null);\n protected readonly spanLogQuery = computed(() => {\n const s = this.selected();\n return s ? { spanId: s.spanId, ...this.windowAround(s) } : {};\n });\n\n /** Depth-first order with depth; spans whose parent is missing are roots. Children start-ordered. */\n private readonly rows = computed<Row[]>(() => {\n const spans = this.spans();\n const ids = new Set(spans.map(s => s.spanId));\n const byParent = new Map<string | null, Span[]>();\n for (const s of spans) {\n const parent = s.parentSpanId && ids.has(s.parentSpanId) ? s.parentSpanId : null;\n byParent.set(parent, [...(byParent.get(parent) ?? []), s]);\n }\n const slowest = new Set([...spans].sort((a, b) => b.durationMs - a.durationMs).slice(0, Math.max(1, Math.ceil(spans.length * 0.05))).map(s => s.spanId));\n const rows: Row[] = [];\n const walk = (parent: string | null, depth: number) => {\n for (const s of (byParent.get(parent) ?? []).sort((a, b) => a.startedAt.localeCompare(b.startedAt))) {\n rows.push({\n span: s, depth, children: byParent.get(s.spanId)?.length ?? 0,\n offset: 100 * (preciseTime(s.startedAt) - this.start()) / this.total(),\n selfError: s.status === 'Error', slowest: slowest.has(s.spanId) && spans.length > 3,\n });\n walk(s.spanId, depth + 1);\n }\n };\n walk(null, 0);\n return rows;\n });\n\n /** Hides collapsed subtrees; \"error paths only\" keeps failed spans and their ancestors. */\n protected readonly visible = computed(() => {\n const rows = this.rows();\n const parentOf = new Map(this.spans().map(s => [s.spanId, s.parentSpanId]));\n let keep: Set<string> | null = null;\n if (this.showErrorsOnly()) {\n keep = new Set<string>();\n for (const r of rows.filter(r => r.selfError)) {\n for (let id: string | null | undefined = r.span.spanId; id; id = parentOf.get(id)) keep.add(id);\n }\n }\n const out: Row[] = [];\n let hiddenBelow: number | null = null;\n for (const r of rows) {\n if (hiddenBelow !== null && r.depth > hiddenBelow) continue;\n hiddenBelow = null;\n if (keep && !keep.has(r.span.spanId)) continue;\n out.push(r);\n if (this.collapsed().has(r.span.spanId)) hiddenBelow = r.depth;\n }\n return out;\n });\n\n protected readonly ticks = computed(() => [0, 25, 50, 75].map(at => ({ at, label: formatDuration(this.total() * at / 100) })));\n\n /** The app's categorical colours (observability.colors $series), as CSS variables: a theme switch repaints them. */\n private readonly seriesCount = Math.max(1, Number(themeColor('series-count')) || 1);\n\n color(service: string) {\n return `var(--jc-series-${this.services().indexOf(service) % this.seriesCount + 1})`;\n }\n\n width(span: Span) {\n return Math.max(0.3, 100 * span.durationMs / this.total());\n }\n\n offsetMs(span: Span) {\n return preciseTime(span.startedAt) - this.start();\n }\n\n eventOffset(span: Span, at: string) {\n return preciseTime(at) - preciseTime(span.startedAt);\n }\n\n toggle(spanId: string, event: Event) {\n event.stopPropagation();\n const next = new Set(this.collapsed());\n if (!next.delete(spanId)) next.add(spanId);\n this.collapsed.set(next);\n }\n\n select(spanId: string | null) {\n void this.router.navigate([], { queryParams: { span: spanId }, queryParamsHandling: 'merge', replaceUrl: true });\n }\n\n private windowAround(span: Span) {\n const start = new Date(span.startedAt).getTime();\n return { from: new Date(start - 60_000).toISOString(), to: new Date(start + span.durationMs + 60_000).toISOString() };\n }\n\n /** The service page over a window around this span, so its metrics and logs line up with it. */\n aroundSpan(span: Span, extra: Record<string, string>) {\n return { ...this.ctx.around(span.startedAt, span.durationMs), ...extra };\n }\n}\n"],"mappings":";;;;;;;;;;;;AAmIA,IAAa,YAAb,MAAa,UAAS;CACD,MAAM,OAAO,cAAc;CAC7B,MAAM,OAAO,UAAU;CACvB,SAAS,OAAO,MAAM;CAG9B,UAAU,MAAM,SAAkB,GAAA,YAAA,CAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;CAClC,OAAO,MAAe,GAAA,YAAA,CAAA,QAAA,EAAA,WAAA,OAAA,CAAA,+BAAA,CAAA,CAAA;CAEZ,KAAK,eAAe,aAAa,KAAK,QAAO,CAAE,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,KAAA,CAAA,+BAAA,CAAA,CAAA;CACjD,QAAQ,YAAY;EAAE,cAAc,KAAK,GAAE;EAAI,SAAS,EAAE,aAAa,KAAK,IAAI,MAAM,MAAM;CAAC,CAAE;CAC/F,QAAQ,eAAe,YAAY,KAAK,MAAM,MAAK,CAAE,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;CACvD,YAAY,uBAAO,IAAI,IAAG,GAAW,GAAA,YAAA,CAAA,EAAA,WAAA,YAAA,CAAA,+BAAA,CAAA,CAAA;CACrC,iBAAiB,OAAO,OAAM,GAAA,YAAA,CAAA,EAAA,WAAA,iBAAA,CAAA,+B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