Skip to content

Add otel tracing around handler#216

Open
Uttkarsh-Srivastava wants to merge 5 commits into
feature/handler-observability-v2from
feature/handler-observability-v3
Open

Add otel tracing around handler#216
Uttkarsh-Srivastava wants to merge 5 commits into
feature/handler-observability-v2from
feature/handler-observability-v3

Conversation

@Uttkarsh-Srivastava
Copy link
Copy Markdown
Collaborator

No description provided.

@deputydev-agent
Copy link
Copy Markdown

DeputyDev will no longer review pull requests automatically.To request a review, simply comment #review on your pull request—this will trigger an on-demand review whenever you need it.

D-Agam and others added 2 commits April 10, 2026 17:02
"Google Agent" - user agent added in list of allowed bots
Copy link
Copy Markdown

@Mrsandeep27 Mrsandeep27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean approach to threading tracing through the hook lifecycle. A few notes:

1. tracedResWriteFirstFoldCss / tracedResWriteFirstFoldJS — both are just thin wrappers around res.write(chunk) with the same signature. Consider a single tracedResWrite factory (or pass the span name as an argument) so you don't duplicate the closure for each chunk type. Current setup will also double-count if you ever add a third chunk.

2. traceHandlerHook gates on typeof fn === "function". If a template exports onRouteMatch as undefined (common when a project only opts into some hooks), the fallthrough returns fn unchanged. Good. But you then pass that undefined into safeCall(onRouteMatch, ...) — confirm safeCall handles undefined fn without emitting a misleading "Invalid lifecycle method" line for hooks that are legitimately optional.

3. _handler is now internal-only but it's still async. withObservability must preserve the promise chain for the rejection path (throw (error) => Promise.reject(error) at the bottom). Worth confirming the wrapper awaits or forwards the rejection — otherwise you'll see tracing spans without error status even when the real handler rejected.

4. Unrelated changes"Google Agent":"Google-Agent" addition in userAgentUtil.js and the indentation touch on line 239 ( const isBot const isBot) look like drive-by edits. Splitting them into their own commits would make this PR cleaner and easier to revert if tracing needs a rollback later.

5. Nit: Span names like res.write.firstFoldCss use dot notation, but the existing spans in this file use camelCase (getMetaData, renderMarkUp, onRouteMatch). Picking one style keeps trace dashboards scannable.

Direction looks right; mostly cleanup suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants