[local-explorer-ui] Improve observability logs, id search, and event-to-trace navigation - #14941
[local-explorer-ui] Improve observability logs, id search, and event-to-trace navigation#14941nickpatt wants to merge 9 commits into
Conversation
…to-trace navigation
🦋 Changeset detectedLatest commit: 73b824f The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Codeowners approval required for this PR:
Show detailed file reviewers
|
@cloudflare/autoconfig
@cloudflare/build-output-utils
@cloudflare/config
create-cloudflare
@cloudflare/deploy-helpers
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-functions
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-auth
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
… label the View trace button
…d add a changeset The Events "View trace" button now carries the event's span_id, and the Traces view resolves it to the invocation row whose spans actually contain that span (findInvocationRoot), instead of always landing on the first row sharing the trace_id. Row element ids are keyed by (trace_id, root_span_id) so they stay unique across a multi-invocation trace.
| </span> | ||
| <span className="font-mono text-xs break-all text-kumo-default"> | ||
| {previewMessage(log.message)} | ||
| {formatLogMessage(log.message ?? undefined)} |
There was a problem hiding this comment.
Nit pick: Would it not be better to have a placeholder "No logs" message? That way there is less layout shift from no text being rendered.
There was a problem hiding this comment.
Added a (no message) placeholder!
| <Button | ||
| size="sm" | ||
| variant="secondary" | ||
| icon={TreeStructureIcon} | ||
| title="Open this event's trace in the Traces view" | ||
| onClick={(e) => { | ||
| e.stopPropagation(); | ||
| goToTrace(); | ||
| }} | ||
| > | ||
| View trace | ||
| </Button> |
There was a problem hiding this comment.
Is there a reason we couldn't just use a LinkButton for this? Instead of needing client-side JS for navigation.
There was a problem hiding this comment.
Good call I just switched it to a LinkButton wired through TanStack's createlink, done!
| test("trace: and span: are parsed as id lookups, not clauses", ({ | ||
| expect, | ||
| }) => { | ||
| const parsed = parseTraceQuery("trace:abc123 span:def456"); | ||
| expect(parsed.traceId).toBe("abc123"); | ||
| expect(parsed.spanId).toBe("def456"); | ||
| expect(parsed.clauses).toEqual([]); | ||
| }); |
There was a problem hiding this comment.
Can we add one or two more small edge cases handling for these. EG: What happens if we get trace: span:?
| } | ||
| }, [traces, expanded, loadSpans]); | ||
|
|
||
| useEffect(() => { |
There was a problem hiding this comment.
Can we add a small comment here outlining what this effect does at a glance, rather than having to analyse the whole block to work it out.
…, parser edge-case tests - Changeset is a minor (adds id search + View trace), not a patch; backtick console.log. - Render a muted "(no message)" placeholder for empty logs to avoid layout shift (Events + InvocationLogs). - Add trace:/span: parser edge cases: valueless tokens fall back to free text, id aliases, and id-lookup alongside a clause. - Summarise the deep-link effect with a one-line comment.
…search params Switch the Events "View trace" button to a router-aware link (createLink around Kumo's LinkButton) so it supports open-in-new-tab / copy-link, while the router keeps typed search params. Added a validateSearch to the /observability route (worker/trace/span) so the link and deep-link reads are typed (drops the casts). The link passes an explicit search object (worker + trace + span) instead of spreading the Events view's params, and the onClick now only stopPropagation on the clickable row.
The reveal effect only worked if the trace was already in the default trace-list window (100 rows, no id filter), but events go 200 deep, so a deep-linked trace could sit permanently outside that window and the View trace button would silently do nothing. Seed the search with `trace:<id>` when the deep link is present so the specific row is fetched via the traceId filter; if it still doesn't come back the trace is gone and the existing empty state (with the visible trace: filter) explains that.
…search Free-text search matched trace/span ids with %q% (substring anywhere), so on hex ids any short term like "de" matched almost every record and effectively disabled filtering. Match ids by prefix (q%), consistent with the trace:/span: filters, while keeping substring matching for names, messages, service, and attributes.
… from the URL The ?trace=&span= params were consumed but left in the URL. Because the view switcher preserves search params and the Traces route remounts on each visit (resetting the applied/seeded refs), the stale trace param re-seeded the trace:<id> query and re-expanded the row on every return, hiding other traces even after the user cleared the search. Capture the deep link once at mount and strip trace/span from the URL (replace navigation, keeping worker), so it only applies once.
…ability page titles The sidebar already switches between the Traces and Events views, so the duplicate dropdown in each page title added no value. Replace it with a plain title and remove the now-unused ObservabilityViewSwitcher component.
eb93628 to
73b824f
Compare
Four fixes to the Local Explorer Observability views (Traces / Events).
1. Readable log messages
console.logis captured as a JSON-encoded array of its arguments, so multi-arg logs rendered as a raw array, e.g.["request failed:","D1_ERROR: …"].formatLogMessagenow renders the array the way the console would — strings verbatim, everything else as JSON, space-joined (request failed: D1_ERROR: …). Both log renderers (the Events list and the inline invocation logs) now share this one function.2. Search by id
The Traces and Events search bars couldn't look up a span/trace id. Added
trace:<id>/span:<id>query terms (withtraceid/trace_idaliases), and free-text search now also matches trace/span ids — so pasting a bare id just finds it. Prefix matching means the truncated ids shown in the list work too. Documented in the query-syntax popover.3. "View trace" from an event
Each event row with a
span_idnow has a button that jumps to the Traces view, auto-expands that event's trace waterfall, and scrolls it into view (via a?trace=<id>deep link).4. Drop the redundant page-title view switcher
The sidebar already switches between the Traces and Events views, so the extra dropdown in each page title was duplicative. Replaced it with a plain title and removed the now-unused
ObservabilityViewSwitchercomponent.