Skip to content

instrumentation-fetch loses Response.url and Response.type properties of original response. #6243

@dreid

Description

@dreid

What happened?

Steps to Reproduce

https://codepen.io/dareid/pen/ogxKOwx

Expected Result

Console should contain:
"uninstrumented type=cors, url=https://httpbin.org/status/200"
"instrumented type=cors, url=https://httpbin.org/status/200"

Actual Result

Console contains:
"uninstrumented type=cors, url=https://httpbin.org/status/200"
"instrumented type=default, url="

Additional Details

This is caused by the wrapping of the original response object here:

https://github.com/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-instrumentation-fetch/src/fetch.ts#L518-L522

Since url and type are read-only properties that can not be passed to the response constructor you have to wrap the original response in a proxy object with url/type getters that can forward to the original response.

OpenTelemetry Setup Code

package.json

Relevant log output

Operating System and Version

No response

Runtime and Version

No response

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

    Labels

    bugSomething isn't workingpkg:instrumentation-fetchpriority:p1Bugs which cause problems in end-user applications such as crashes, data inconsistencies, etc

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions