Skip to content

feat(server-utils): Rewrite @opentelemetry/instrumentation-hapi to orchestrion#21866

Open
chargome wants to merge 5 commits into
developfrom
charlygomez/js-2404-rewrite-opentelemetryinstrumentation-hapi-to-orchestrion
Open

feat(server-utils): Rewrite @opentelemetry/instrumentation-hapi to orchestrion#21866
chargome wants to merge 5 commits into
developfrom
charlygomez/js-2404-rewrite-opentelemetryinstrumentation-hapi-to-orchestrion

Conversation

@chargome

@chargome chargome commented Jun 30, 2026

Copy link
Copy Markdown
Member
  • Adds hapiChannelIntegration in @sentry/server-utils for injecting orchestrion channels
  • A start-only subscriber swaps route handlers / ext methods
  • Span-building helpers are ported OTel-free into hapi-utils.ts / hapi-types.ts (structural types, no @hapi/* runtime dep), HTTP attribute keys come from @sentry/conventions/attributes.

closes #20753

@chargome chargome self-assigned this Jun 30, 2026
@linear-code

linear-code Bot commented Jun 30, 2026

Copy link
Copy Markdown

JS-2404

@chargome chargome changed the title feat(server-utils): Rewrite @opentelemetry/instrumentation-hapi to orchestrion feat(server-utils): Rewrite @opentelemetry/instrumentation-hapi to orchestrion Jun 30, 2026
@chargome

Copy link
Copy Markdown
Member Author

bugbot run

@chargome

Copy link
Copy Markdown
Member Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 993f38b. Configure here.

@chargome chargome force-pushed the charlygomez/js-2404-rewrite-opentelemetryinstrumentation-hapi-to-orchestrion branch from 993f38b to fadc582 Compare July 1, 2026 10:30
@chargome chargome marked this pull request as ready for review July 1, 2026 12:20
@chargome chargome requested a review from a team as a code owner July 1, 2026 12:20
@chargome chargome requested review from JPeer264, andreiborza and mydea and removed request for a team July 1, 2026 12:20
@nicohrubec nicohrubec self-requested a review July 1, 2026 12:24
chargome and others added 5 commits July 2, 2026 14:56
Rely on `createEsmAndCjsTests` auto-running the suite with orchestrion on
CI (#21911) instead of a manual instrument matrix: drop
`instrument-orchestrion.mjs` and branch the expected span origin on
`isOrchestrionEnabled()`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@chargome chargome force-pushed the charlygomez/js-2404-rewrite-opentelemetryinstrumentation-hapi-to-orchestrion branch from 93210f8 to 3a69ceb Compare July 2, 2026 13:05
Comment on lines +196 to +199
if (Array.isArray(method)) {
for (let i = 0; i < method.length; i++) {
method[i] = wrapExtMethods(method[i]!, extPoint);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bug: The wrapExtMethods function recursively calls itself for array methods but omits the pluginName, losing plugin attribution for Hapi extensions that use method arrays.
Severity: MEDIUM

Suggested Fix

In wrapExtMethods, when handling the array case, the recursive call should be updated to pass along the pluginName. Change method[i] = wrapExtMethods(method[i]!, extPoint); to method[i] = wrapExtMethods(method[i]!, extPoint, pluginName);. This will ensure the plugin name is preserved for all methods in the array.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: packages/server-utils/src/integrations/tracing-channel/hapi-utils.ts#L196-L199

Potential issue: When a Hapi plugin registers an extension point using an object where
the `method` property is an array of functions (e.g., `server.ext({ type:
'onPreHandler', method: [handler1, handler2] })`), the `wrapExtMethods` function is
invoked. This function correctly identifies the array but fails to pass the `pluginName`
in its recursive calls for each method in the array. As a result, the spans created for
these methods will lack the `hapi.plugin.name` attribute and the plugin name prefix in
the span description, leading to a loss of plugin attribution in tracing data.

Did we get this right? 👍 / 👎 to inform future reviews.

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.

Rewrite @opentelemetry/instrumentation-hapi to orchestrion

1 participant