Skip to content

Warn when two @opentelemetry/api copies load - #1504

Draft
unflxw wants to merge 1 commit into
otel-duplicate-checkfrom
otel-api-runtime-warning
Draft

Warn when two @opentelemetry/api copies load#1504
unflxw wants to merge 1 commit into
otel-duplicate-checkfrom
otel-api-runtime-warning

Conversation

@unflxw

@unflxw unflxw commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Stacked on #1503.

Warn when two @opentelemetry/api copies load

An application loading two incompatible copies reports only some of its
spans, because the API hands a tracer that drops every span to whichever
copy loses the version comparison, which looks the same as an
application that produces none. The check reads the module cache rather
than walking node_modules, since a copy nothing loaded cannot cause
this, and says it once per process because which copies are loaded does
not change while one is running.

@backlog-helper

Copy link
Copy Markdown

Hi @unflxw,

We've found some issues with your Pull Request.

  • This Pull Request is missing labels. Please add labels to help identify types of Pull Requests. - (More info)

New issue guide | Backlog management | Rules | Feedback

Copilot AI 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.

Pull request overview

Adds a runtime check to detect when multiple incompatible copies of @opentelemetry/api are loaded in the current process, and emits a warning so span loss due to OpenTelemetry API version arbitration is visible to the application operator.

Changes:

  • Introduce loadedOpenTelemetryApiCopies + duplicateOpenTelemetryApiWarning to detect loaded @opentelemetry/api copies via require.cache and generate a human-readable warning.
  • Call the new warning logic during Client startup when the OpenTelemetry SDK is initialized, logging to both console.warn and the internal logger.
  • Add Jest coverage for the new helper module and a changeset entry documenting the new warning.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/otel_api_copies.ts New helpers to detect loaded @opentelemetry/api copies and produce an incompatibility warning message.
src/client.ts Invoke the duplicate-API warning during OpenTelemetry initialization and log it.
src/__tests__/otel_api_copies.test.ts Unit tests for the new helper module (copy detection + warning generation behavior).
.changesets/warn-about-duplicate-opentelemetry-api-copies.md Changeset entry describing the new runtime warning behavior.

馃挕 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/otel_api_copies.ts Outdated
Comment thread src/client.ts
Comment thread src/client.ts

Copilot AI 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.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comment thread src/client.ts
@unflxw
unflxw force-pushed the otel-api-runtime-warning branch from 6f043b6 to 5194ff6 Compare August 25, 2026 10:45
@unflxw
unflxw force-pushed the otel-api-runtime-warning branch from 5194ff6 to eae13bc Compare August 25, 2026 14:24
@unflxw
unflxw requested a lite review from Copilot August 25, 2026 14:25

Copilot AI 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.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comment thread src/__tests__/client.test.ts
@unflxw
unflxw force-pushed the otel-api-runtime-warning branch from eae13bc to 59b931e Compare August 25, 2026 14:40
@unflxw
unflxw requested a lite review from Copilot August 25, 2026 14:40

Copilot AI 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.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@unflxw
unflxw force-pushed the otel-api-runtime-warning branch from 59b931e to d221474 Compare August 25, 2026 14:59
@unflxw
unflxw requested a lite review from Copilot August 25, 2026 15:00

Copilot AI 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.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@unflxw
unflxw force-pushed the otel-api-runtime-warning branch from d221474 to 508986a Compare August 25, 2026 15:06

Copilot AI 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.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Comment thread src/client.ts Outdated
Comment thread src/otel_api_copies.ts Outdated
@unflxw
unflxw force-pushed the otel-api-runtime-warning branch from 508986a to 9282cf0 Compare August 25, 2026 15:14
@unflxw
unflxw force-pushed the otel-api-runtime-warning branch from 9282cf0 to ff5e410 Compare August 25, 2026 15:15
@unflxw
unflxw requested a lite review from Copilot August 25, 2026 15:16

Copilot AI 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.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@unflxw
unflxw force-pushed the otel-api-runtime-warning branch from ff5e410 to de22309 Compare August 25, 2026 15:22
@unflxw
unflxw requested a lite review from Copilot August 25, 2026 15:22

Copilot AI 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.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

An application loading two incompatible copies reports only some of its
spans, because the API hands a tracer that drops every span to whichever
copy loses the version comparison, which looks the same as an
application that produces none. The check reads the module cache rather
than walking `node_modules`, since a copy nothing loaded cannot cause
this, and says it once per process because which copies are loaded does
not change while one is running.
@unflxw
unflxw force-pushed the otel-api-runtime-warning branch from de22309 to bad32ba Compare August 25, 2026 15:44
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.

2 participants