Skip to content

Support multiple versions in same browser #6136

@Ankoul

Description

@Ankoul

Is your feature request related to a problem? Please describe.

My product is an API that provides web components to be consumed by other products.
When a client consuming my API has opentelemetry, my traces are sent to their collectors (or their traces are sent to mine).

Describe the solution you'd like

I would like to have my traces sent to my collector independent if my client is using opentelemetry or not.

Additional context

This is happening because Opentelemetry has a global Symbol where it keeps and share its state between its own packages.

Image Image

This symbol is created by Symbol.for(...) in your global-utils.ts
https://github.com/open-telemetry/opentelemetry-js/blob/main/api/src/internal/global-utils.ts

Since Symbol.for(...) returns same Symbol for given string, different opentelemetry instances/versions are sharing same state, mixing traces and sending to wrong collector.
Switching it to Symbol(...) might fix this issue.

Image

Besides this shared state, opentelemetry-instrumentation-fetch is also not built to work with multiple instances.
opentelemetry-instrumentation-fetch is unwrapping fetch if it is already wrapped
https://github.com/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-instrumentation-fetch/src/fetch.ts#L662
Basically if my client uses opentelemetry-instrumentation-fetch my API is going to unwrap their version to add mine, or their implementation is going unwrap mine to add theirs.

Tip: React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions