presets(cloudflare): bridge tracing channel events to observability custom spans#4413
presets(cloudflare): bridge tracing channel events to observability custom spans#4413RihanArfan wants to merge 8 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
commit: |
📝 WalkthroughWalkthroughAdds experimental tracing-channel support for Cloudflare presets. It extends traced-channel completion handling, installs a Cloudflare telemetry bridge, emits custom spans with attributes and exceptions, adds comprehensive unit tests, and documents the required Wrangler observability configuration. ChangesTracing channel telemetry integration
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/presets/cloudflare/runtime/telemetry/plugin.ts`:
- Around line 31-35: In the attribute loop within the telemetry plugin, handle
`attributeValue(value)` results before calling `entry.span.setAttribute`: skip
entries whose converted value is `undefined`, while preserving valid primitive
or array values.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a6b844e5-5673-4a74-a6b0-9ceb174e1d33
📒 Files selected for processing (6)
src/presets/cloudflare/runtime/telemetry/plugin.tssrc/presets/vercel/runtime/telemetry/plugin.tssrc/runtime/internal/telemetry/logger-plugin.tssrc/runtime/internal/telemetry/subscribe.tstest/unit/cloudflare-telemetry.test.tstest/unit/telemetry-subscribe.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- test/unit/cloudflare-telemetry.test.ts
| export default definePlugin(() => { | ||
| subscribeTracedChannels((info, startTimeUnixNano, error) => { | ||
| // Describer failed on the completed payload — nothing to report. | ||
| if (!info) return; |
There was a problem hiding this comment.
Looks like a bug. Why are we even calling callback in this case?
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/runtime/internal/telemetry/subscribe.ts (1)
69-75: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winLog warnings for recoverable telemetry failures.
While catching exceptions here correctly prevents telemetry sink failures from crashing the traced application, swallowing them silently prevents visibility into malformed payloads or broken span exports. Please add
console.warnto these catch blocks to provide actionable context.
src/runtime/internal/telemetry/subscribe.ts#L69-L75: Addconsole.warninside thecatchblock to logonStartor initialdescribefailures.src/runtime/internal/telemetry/subscribe.ts#L91-L93: Addconsole.warninside thecatchblock to log completiondescribefailures.src/runtime/internal/telemetry/subscribe.ts#L97-L101: Addconsole.warninside thecatchblock to logonSpansink export failures.As per coding guidelines, "Prefer explicit errors over silent failures; use warnings for recoverable situations" and "Use
consoleonly for logging insrc/runtime/code; never useconsola."🛡️ Proposed fixes for explicit error logging
@@ -69,7 +69,8 @@ try { entry.info = describe(name, message); entry.state = onStart(entry.info); - } catch { + } catch (error) { // Malformed payload, or a sink failure (e.g. the platform refused to // open a span) — no state; the completion callback still fires. + console.warn(`[nitro] Failed to start span for channel ${name}:`, error); } @@ -91,3 +92,5 @@ try { info = describe(name, message); - } catch {} + } catch (error) { + console.warn(`[nitro] Failed to describe completed span for channel ${name}:`, error); + } @@ -97,4 +100,5 @@ try { onSpan(info, entry.start, (message as { error?: unknown }).error, entry.state); - } catch { + } catch (error) { // A sink failure must never break the traced operation. + console.warn(`[nitro] Failed to export span for channel ${name}:`, error); }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/runtime/internal/telemetry/subscribe.ts` around lines 69 - 75, Make the three exception handlers in src/runtime/internal/telemetry/subscribe.ts—covering initial describe/onStart, completion describe, and onSpan export—emit console.warn with actionable failure context while preserving their existing recovery behavior; use console only and do not rethrow or replace the catches.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/runtime/internal/telemetry/subscribe.ts`:
- Around line 69-75: Make the three exception handlers in
src/runtime/internal/telemetry/subscribe.ts—covering initial describe/onStart,
completion describe, and onSpan export—emit console.warn with actionable failure
context while preserving their existing recovery behavior; use console only and
do not rethrow or replace the catches.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: b5bfa969-a7b2-4b4d-a9e9-d400195ea65c
📒 Files selected for processing (4)
src/presets/cloudflare/runtime/telemetry/plugin.tssrc/runtime/internal/telemetry/subscribe.tstest/unit/cloudflare-telemetry.test.tstest/unit/telemetry-subscribe.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- src/presets/cloudflare/runtime/telemetry/plugin.ts
- test/unit/cloudflare-telemetry.test.ts
🔗 Linked issue
#4355
❓ Type of change
📚 Description
Porting #4355 to Cloudflare to support Nitro tracing on more platforms.
Bridge tracing channel messages to Cloudflare Workers Observability as custom spans.
📝 Checklist