|
1 | 1 | import { describe, expect, it } from "vitest"; |
2 | 2 |
|
3 | 3 | import { |
4 | | - RELAY_AXIOM_DATASETS, |
5 | | - makeRelayDashboardCharts, |
6 | | - makeRelayDashboardLayout, |
| 4 | + RELAY_AXIOM_TRACE_DATASET, |
7 | 5 | relayAxiomIngestDatasetCapabilities, |
8 | 6 | relayAxiomQueryDatasetCapabilities, |
| 7 | + relayTraceQuery, |
9 | 8 | } from "./RelayObservability.ts"; |
10 | 9 |
|
11 | 10 | describe("RelayObservability", () => { |
12 | | - it("scopes the ingest token to create-only ingest across relay datasets", () => { |
| 11 | + it("scopes the ingest token only to HTTP span ingestion", () => { |
13 | 12 | expect(relayAxiomIngestDatasetCapabilities()).toEqual({ |
14 | | - [RELAY_AXIOM_DATASETS.events]: { ingest: ["create"] }, |
15 | | - [RELAY_AXIOM_DATASETS.metrics]: { ingest: ["create"] }, |
| 13 | + [RELAY_AXIOM_TRACE_DATASET]: { ingest: ["create"] }, |
16 | 14 | }); |
17 | 15 | }); |
18 | 16 |
|
19 | | - it("scopes the diagnostics query token to read-only query across relay datasets", () => { |
| 17 | + it("scopes the diagnostics query token only to HTTP spans", () => { |
20 | 18 | expect(relayAxiomQueryDatasetCapabilities()).toEqual({ |
21 | | - [RELAY_AXIOM_DATASETS.events]: { query: ["read"] }, |
22 | | - [RELAY_AXIOM_DATASETS.metrics]: { query: ["read"] }, |
| 19 | + [RELAY_AXIOM_TRACE_DATASET]: { query: ["read"] }, |
23 | 20 | }); |
24 | 21 | }); |
25 | 22 |
|
26 | | - it("keeps dashboard layout cells in sync with declared charts", () => { |
27 | | - const charts = makeRelayDashboardCharts(); |
28 | | - const chartIds = new Set(charts.map((chart) => chart.id)); |
29 | | - const layout = makeRelayDashboardLayout(charts); |
30 | | - |
31 | | - expect(layout).toHaveLength(charts.length); |
32 | | - for (const cell of layout) { |
33 | | - expect(chartIds.has(cell.i)).toBe(true); |
34 | | - } |
35 | | - }); |
36 | | - |
37 | | - it("builds log APL and metrics MPL dashboard queries", () => { |
38 | | - const charts = makeRelayDashboardCharts({ |
39 | | - events: "relay-events-test", |
40 | | - metrics: "relay-metrics-test", |
41 | | - }); |
42 | | - const recentFailures = charts.find((chart) => chart.id === "recent-failures"); |
43 | | - const activeTunnels = charts.find((chart) => chart.id === "active-managed-tunnels"); |
44 | | - if ( |
45 | | - !recentFailures || |
46 | | - !("query" in recentFailures) || |
47 | | - !activeTunnels || |
48 | | - !("query" in activeTunnels) |
49 | | - ) { |
50 | | - throw new Error("Expected query-backed relay charts."); |
51 | | - } |
52 | | - |
53 | | - expect(recentFailures.query.apl).toContain("['relay-events-test']"); |
54 | | - expect(recentFailures.query.apl).toContain("column_ifexists('severityText', '')"); |
55 | | - expect(recentFailures.query.apl).not.toContain("severity_text"); |
56 | | - expect(activeTunnels.query.apl).toContain( |
57 | | - "`relay-metrics-test`:`relay_managed_tunnels_active`", |
| 23 | + it("builds APL queries for the trace dataset", () => { |
| 24 | + expect(relayTraceQuery("| where name == 'GET /health'", "relay-traces-test")).toBe( |
| 25 | + "['relay-traces-test']\n| where name == 'GET /health'", |
58 | 26 | ); |
59 | | - expect(activeTunnels.query.apl).toContain("| group using sum"); |
60 | | - expect(activeTunnels.query.apl).not.toContain("['relay-metrics-test']"); |
61 | 27 | }); |
62 | 28 | }); |
0 commit comments