This repository was archived by the owner on Oct 23, 2026. It is now read-only.
Repository navigation
fix(local): Handle standalone span items, Cloudflare SDK source, and warn level - #1276
Merged
Merged
Conversation
…warn level Three fixes for `sentry local serve` discovered during Hono + Cloudflare Workers stress testing: 1. Add formatter for standalone `span` envelope items (v2 span streaming). The Cloudflare SDK emits gen_ai/mcp spans as standalone span items, not embedded in transactions. Without this, AI spans render as a bare `• span` fallback line and `--filter ai` misses them entirely. Now they get full semantic rendering (gen_ai labels, duration, trace ID) and are properly matched by the ai/transaction filters. 2. Add `cloudflare` to SERVER_JS_MARKERS so `sentry.javascript.cloudflare` SDK events are labeled `[SERVER]` instead of `[BROWSER]`. 3. Add `warn` key to LEVEL_COLORS (alongside existing `warning`) since the Sentry SDK emits log level `warn`, not `warning`.
Contributor
|
Contributor
Codecov Results 📊✅ Patch coverage is 87.50%. Project has 5486 uncovered lines. Files with missing lines (1)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 81.68% 81.69% +0.01%
==========================================
Files 426 426 —
Lines 29909 29969 +60
Branches 19433 19496 +63
==========================================
+ Hits 24431 24483 +52
- Misses 5478 5486 +8
- Partials 2035 2045 +10Generated by Codecov Action |
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
Three fixes for
sentry local servediscovered during Hono + Cloudflare Workers stress testing:spanitem formatter — The Cloudflare (and other modern) SDKs emit gen_ai/mcp spans as standalonespanenvelope items (v2 span streaming), not embedded in transactions. These were rendering as a useless• spanfallback. Now they get full semantic rendering with gen_ai labels, model names, token usage, duration, trace IDs — and--filter aicorrectly matches them.[SERVER]— AddedcloudflaretoSERVER_JS_MARKERSsosentry.javascript.cloudflareevents show[SERVER]instead of[BROWSER].warnlevel colored — Addedwarnkey toLEVEL_COLORSsince the Sentry SDK emits level"warn"(not"warning").Context
These gaps were found by creating a real Hono +
@sentry/cloudflareWorkers app, running it undersentry local serveviawrangler dev --local, and hitting routes that generate errors, transactions, structured logs, and gen_ai/mcp AI spans.Changes
src/lib/formatters/local.ts:formatSingleSpan,formatSpanItem,formatSpanJsonfunctions for thespanitem typeflattenSpanAttributesto convert typed{ key: { type, value } }to plainRecord<string, unknown>spanItemHasAiActivityfor--filter aimatching on standalone spansitemTypeToFilterCategorymaps"span"to"transaction"categoryisItemIncludedchecks standalone spans for AI attributesformatItem,formatItemJsonroute"span"type to the new formattersSERVER_JS_MARKERS+="cloudflare"LEVEL_COLORS+=warn: yellowtest/lib/formatters/local.test.ts: 16 new tests covering all three fixesAll 937 existing formatter tests + 16 new tests pass. Property tests pass.