feat(server-utils): Rewrite @opentelemetry/instrumentation-hapi to orchestrion#21866
Conversation
@opentelemetry/instrumentation-hapi to orchestrion
|
bugbot run |
|
bugbot run |
There was a problem hiding this comment.
✅ 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.
993f38b to
fadc582
Compare
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>
93210f8 to
3a69ceb
Compare
| if (Array.isArray(method)) { | ||
| for (let i = 0; i < method.length; i++) { | ||
| method[i] = wrapExtMethods(method[i]!, extPoint); | ||
| } |
There was a problem hiding this comment.
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.
closes #20753