Skip to content

ref(node-core): Vendor OTel rpc-metadata and drop @opentelemetry/core dependency#22274

Closed
msonnb wants to merge 1 commit into
developfrom
ms/node-core-vendor-rpc-metadata
Closed

ref(node-core): Vendor OTel rpc-metadata and drop @opentelemetry/core dependency#22274
msonnb wants to merge 1 commit into
developfrom
ms/node-core-vendor-rpc-metadata

Conversation

@msonnb

@msonnb msonnb commented Jul 15, 2026

Copy link
Copy Markdown
Member

@sentry/node-core only depended on @opentelemetry/core for the RPC metadata helpers (getRPCMetadata/setRPCMetadata/RPCType) used by the HTTP server spans integration. This vendors that single small module and drops the dependency entirely.

The vendored file is colocated with its sole consumer under integrations/http/vendored/rpcMetadata.ts, matching the pattern already used for the vendored undici instrumentation (colocated with consumer) rather than a top-level vendored/ directory, since it has exactly one caller.

With the import switched to the vendored copy, @opentelemetry/core is no longer referenced anywhere in src, so it was removed from peerDependencies, peerDependenciesMeta, devDependencies, and the README's dependency list and install commands.

ref #21674
closes #22280

@msonnb

msonnb commented Jul 15, 2026

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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c56eb18. Configure here.

/** Set the current RPC metadata on the given context. */
export function setRPCMetadata(context: Context, meta: RPCMetadata): Context {
return context.setValue(RPC_METADATA_KEY, meta);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Vendored RPC key breaks interop

High Severity

createContextKey returns a unique symbol on every call, so this vendored RPC_METADATA_KEY is not the same key as @opentelemetry/core's. Framework instrumentations (Express, Fastify, Koa, etc.) call getRPCMetadata from @opentelemetry/core and will no longer find the metadata httpServerSpansIntegration stores, so rpcMetadata.route stays unset and http.route / transaction-name updates from that path are lost for @sentry/node-core bring-your-own-OTel setups.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit c56eb18. Configure here.

@msonnb msonnb Jul 16, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this shouldn't be a problem since createContextKey calls Symbol.for under the hood. So if we keep the string exactly the same, this resolves to the same key. See https://github.com/open-telemetry/opentelemetry-js/blob/d8894cf99074d487203e1b814d9c3679019b63d3/api/src/context/context.ts#L13

@mydea

mydea commented Jul 15, 2026

Copy link
Copy Markdown
Member

I wonder if we need this at all? SInce we now control all of this, could we not get rid of this totally, and instead just directly set the things we need (http.route attribute I guess) directly?

@msonnb

msonnb commented Jul 15, 2026

Copy link
Copy Markdown
Member Author

I wonder if we need this at all? SInce we now control all of this, could we not get rid of this totally, and instead just directly set the things we need (http.route attribute I guess) directly?

mhm so if i understand this correctly we can actually drop all the rpcMetadata paths (like here) since we set http.route directly in the framework integrations with setHttpServerSpanRouteAttribute, and never through this RPCMetadata context, right?

@mydea

mydea commented Jul 15, 2026

Copy link
Copy Markdown
Member

I wonder if we need this at all? SInce we now control all of this, could we not get rid of this totally, and instead just directly set the things we need (http.route attribute I guess) directly?

mhm so if i understand this correctly we can actually drop all the rpcMetadata paths (like here) since we set http.route directly in the framework integrations with setHttpServerSpanRouteAttribute, and never through this RPCMetadata context, right?

jup, but only in v11! for now we need to still set this as in theory external instrumentation could use this. I have slightly adjusted this here: #22292

… dependency

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@msonnb
msonnb force-pushed the ms/node-core-vendor-rpc-metadata branch from c56eb18 to 3cb97a6 Compare July 15, 2026 15:04
@msonnb

msonnb commented Jul 16, 2026

Copy link
Copy Markdown
Member Author

closing as we will just remove this in v11

@msonnb msonnb closed this Jul 16, 2026
@msonnb
msonnb deleted the ms/node-core-vendor-rpc-metadata branch July 16, 2026 08:11
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.

Remove @opentelemetry/core RPC metadata APIs

2 participants