Skip to content

Commit 42c71c9

Browse files
committed
Allow fetch to be used with NodeJS native fetch
1 parent 28bb908 commit 42c71c9

File tree

2 files changed

+6
-3
lines changed
  • experimental/packages/opentelemetry-instrumentation-fetch/src
  • packages/opentelemetry-sdk-trace-web/src

2 files changed

+6
-3
lines changed

experimental/packages/opentelemetry-instrumentation-fetch/src/fetch.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,10 @@ export class FetchInstrumentation extends InstrumentationBase<
133133
parsedUrl.protocol.replace(':', '')
134134
);
135135
if (typeof navigator !== 'undefined') {
136-
span.setAttribute(SemanticAttributes.HTTP_USER_AGENT, navigator.userAgent);
136+
span.setAttribute(
137+
SemanticAttributes.HTTP_USER_AGENT,
138+
navigator.userAgent
139+
);
137140
}
138141
}
139142

packages/opentelemetry-sdk-trace-web/src/utils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ export function sortResources(
131131
});
132132
}
133133

134-
/** Returns the origin if present (if in browser context) */
135-
function getOrigin(): string | undefined{
134+
/** Returns the origin if present (if in browser context). */
135+
function getOrigin(): string | undefined {
136136
return typeof location !== 'undefined' ? location.origin : undefined;
137137
}
138138

0 commit comments

Comments
 (0)