Skip to content

Commit

Permalink
chore: use performance directly in xhr plugin (#1651)
Browse files Browse the repository at this point in the history
  • Loading branch information
dyladan committed Nov 10, 2020
1 parent 25a2f65 commit 894c8d8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,9 @@ export class XMLHttpRequestInstrumentation extends InstrumentationBase<
// fallback - either Observer is not available or it took longer
// then OBSERVER_WAIT_TIME_MS and observer didn't collect enough
// information
resources = otperformance.getEntriesByType(
// ts thinks this is the perf_hooks module, but it is the browser performance api
// eslint-disable-next-line @typescript-eslint/no-explicit-any
'resource' as any
// ts thinks this is the perf_hooks module, but it is the browser performance api
resources = ((otperformance as unknown) as Performance).getEntriesByType(
'resource'
) as PerformanceResourceTiming[];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,10 @@ describe('xhr', () => {
})
);

spyEntries = sandbox.stub(performance, 'getEntriesByType');
spyEntries = sandbox.stub(
(performance as unknown) as Performance,
'getEntriesByType'
);
spyEntries.withArgs('resource').returns(resources);
xmlHttpRequestInstrumentation = new XMLHttpRequestInstrumentation(
config
Expand Down Expand Up @@ -709,7 +712,10 @@ describe('xhr', () => {
})
);

spyEntries = sandbox.stub(performance, 'getEntriesByType');
spyEntries = sandbox.stub(
(performance as unknown) as Performance,
'getEntriesByType'
);
spyEntries.withArgs('resource').returns(resources);

webTracerWithZoneProvider = new WebTracerProvider({
Expand Down

0 comments on commit 894c8d8

Please sign in to comment.