Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch's propagateContext option is ignored when false #108

Open
morley92 opened this issue Jul 30, 2024 · 0 comments
Open

Fetch's propagateContext option is ignored when false #108

morley92 opened this issue Jul 30, 2024 · 0 comments

Comments

@morley92
Copy link

morley92 commented Jul 30, 2024

The docs suggest that any individual fetch request can be overwritten to start/stop propagating context

propagateContext: boolean: overrides propagateContextUrls for this call.

Example usage of this argument below -

const response = await fetch('http://some-url', {
  opentelemetry: {
    propagateContext: false // or true
  }
})

The source code, I believe incorrectly, only considers propagateContext if the value is truthy - see here

if (init?.opentelemetry?.propagateContext) {
  return init.opentelemetry.propagateContext;
}

This should be more like this -

if (typeof init?.opentelemetry?.propagateContext === 'boolean') {
  return init.opentelemetry.propagateContext;
}

This way, regardless of whether propagateContext is true or false, it will cause shouldPropagate to return early with the appropriate value, instead of only returning early when propagateContext is true.

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

No branches or pull requests

1 participant