Skip to content

Commit

Permalink
fix: typescript not liking arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
t2t2 committed Aug 12, 2021
1 parent 1109df8 commit a6250b4
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions packages/opentelemetry-instrumentation-fetch/src/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,23 +284,18 @@ export class FetchInstrumentation extends InstrumentationBase<
/**
* Patches the constructor of fetch
*/
private _patchConstructor(): (
original: (input: RequestInfo, init?: RequestInit) => Promise<Response>
) => (input: RequestInfo, init?: RequestInit) => Promise<Response> {
return (
original: (input: RequestInfo, init?: RequestInit) => Promise<Response>
): ((input: RequestInfo, init?: RequestInit) => Promise<Response>) => {
private _patchConstructor(): (original: Window['fetch']) => Window['fetch'] {
return original => {
const plugin = this;
return function patchConstructor(
this: (input: RequestInfo, init?: RequestInit) => Promise<Response>,
input: RequestInfo,
init?: RequestInit
this: Window,
...args: Parameters<Window['fetch']>
): Promise<Response> {
const url = input instanceof Request ? input.url : input;
const options = input instanceof Request ? input : init || {};
const url = args[0] instanceof Request ? args[0].url : args[0];
const options = args[0] instanceof Request ? args[0] : args[1] || {};
const createdSpan = plugin._createSpan(url, options);
if (!createdSpan) {
return original.apply(this, arguments);
return original.apply(this, args);
}
const spanData = plugin._prepareSpanData(url);

Expand Down

0 comments on commit a6250b4

Please sign in to comment.