-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[local-explorer-ui] Improve observability logs, id search, and event-to-trace navigation #14941
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nickpatt
wants to merge
9
commits into
cloudflare:main
Choose a base branch
from
nickpatt:local-explorer-observability-ui-fixes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5ef51de
[local-explorer-ui] improve observability logs, id search, and event-…
nickpatt dafaf4d
[local-explorer-ui] wire trace:/span: search into the Traces view and…
nickpatt ca16d4e
[local-explorer-ui] deep-link events to the exact trace invocation an…
nickpatt c33c67c
[local-explorer-ui] address review: minor bump, empty-log placeholder…
nickpatt c09c00f
[local-explorer-ui] make View trace a real router link and scope its …
nickpatt 7db34cc
[local-explorer-ui] seed the Traces query from the ?trace= deep link
nickpatt af35657
[local-explorer-ui] match ids by prefix (not substring) in free-text …
nickpatt bbdcf04
[local-explorer-ui] make the trace deep link one-shot by stripping it…
nickpatt 73b824f
[local-explorer-ui] Drop redundant view-switcher dropdown from Observ…
nickpatt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| "@cloudflare/vite-plugin": minor | ||
| "wrangler": minor | ||
| --- | ||
|
|
||
| Improve the Local Explorer's Observability views | ||
|
|
||
| `console.log` messages now render the way the console would (JSON-encoded strings are unwrapped and multi-argument logs are joined), traces and events can be looked up by trace or span id from the search bar, and an event's "View trace" button jumps to the exact invocation that emitted it — even when a trace_id spans several invocations (e.g. a subrequest or self fetch). |
76 changes: 76 additions & 0 deletions
76
packages/local-explorer-ui/src/__tests__/observability/id-search.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| import { beforeEach, describe, test, vi } from "vitest"; | ||
|
|
||
| // Capture the SQL/params sent to the read-only query endpoint so we can assert | ||
| // that the id-search filters produce the expected predicates. | ||
| const { post } = vi.hoisted(() => ({ post: vi.fn() })); | ||
|
|
||
| vi.mock("../../api", () => ({ | ||
| observabilityQuery: (opts: { body: { sql: string; params: unknown[] } }) => { | ||
| post(opts.body); | ||
| return Promise.resolve({ data: { result: { columns: [], rows: [] } } }); | ||
| }, | ||
| observabilityClear: () => Promise.resolve({}), | ||
| })); | ||
|
|
||
| const { listEvents, listTraces } = await import("../../utils/observability"); | ||
|
|
||
| function lastQuery(): { sql: string; params: unknown[] } { | ||
| return post.mock.calls.at(-1)?.[0] as { sql: string; params: unknown[] }; | ||
| } | ||
|
|
||
| beforeEach(() => post.mockClear()); | ||
|
|
||
| describe("listTraces id search", () => { | ||
| test("traceId matches the trace by id prefix", async ({ expect }) => { | ||
| await listTraces({ traceId: "abc123" }); | ||
| const { sql, params } = lastQuery(); | ||
| expect(sql).toContain("s.trace_id LIKE ?"); | ||
| expect(params).toContain("abc123%"); | ||
| }); | ||
|
|
||
| test("spanId matches traces containing the span", async ({ expect }) => { | ||
| await listTraces({ spanId: "def456" }); | ||
| const { sql, params } = lastQuery(); | ||
| expect(sql).toContain("SELECT trace_id FROM spans WHERE span_id LIKE ?"); | ||
| expect(params).toContain("def456%"); | ||
| }); | ||
|
|
||
| test("free-text matches ids by prefix, names/attrs by substring", async ({ | ||
| expect, | ||
| }) => { | ||
| await listTraces({ search: "de" }); | ||
| const { params } = lastQuery(); | ||
| // ids: prefix only (no leading %), so a short hex term doesn't match all. | ||
| expect(params).toContain("de%"); | ||
| expect(params).not.toContain("%de%de%"); | ||
| // names/attributes: substring. | ||
| expect(params).toContain("%de%"); | ||
| }); | ||
| }); | ||
|
|
||
| describe("listEvents id search", () => { | ||
| test("traceId matches the event's trace by id prefix", async ({ expect }) => { | ||
| await listEvents({ traceId: "abc123" }); | ||
| const { sql, params } = lastQuery(); | ||
| expect(sql).toContain("l.trace_id LIKE ?"); | ||
| expect(params).toContain("abc123%"); | ||
| }); | ||
|
|
||
| test("spanId matches the emitting span by id prefix", async ({ expect }) => { | ||
| await listEvents({ spanId: "def456" }); | ||
| const { sql, params } = lastQuery(); | ||
| expect(sql).toContain("l.span_id LIKE ?"); | ||
| expect(params).toContain("def456%"); | ||
| }); | ||
|
|
||
| test("free-text matches ids by prefix, message/service by substring", async ({ | ||
| expect, | ||
| }) => { | ||
| await listEvents({ search: "de" }); | ||
| const { params } = lastQuery(); | ||
| // ids: prefix only. | ||
| expect(params).toContain("de%"); | ||
| // message/operation/service: substring. | ||
| expect(params).toContain("%de%"); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 0 additions & 61 deletions
61
packages/local-explorer-ui/src/components/observability/ObservabilityViewSwitcher.tsx
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.