Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

- "You miss 100 percent of the chances you don't take. — Wayne Gretzky" — Michael Scott

- [apm] ref: Use `onresourcetimingbufferfull` and don't delete measurements

## 5.14.0

- [apm] feat: Add a simple heartbeat check, if activities don't change in 3 beats, finish the transaction (#2478)
Expand Down
22 changes: 14 additions & 8 deletions packages/apm/src/integrations/tracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,20 @@ export class Tracing implements Integration {
public setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void {
Tracing._getCurrentHub = getCurrentHub;

if (global.performance) {
// The Performance object has a limited buffer size, often 150 entries. At some point the buffer may overflow, in
// which case we would not be able to use it to create/update spans.
// https://developer.mozilla.org/en-US/docs/Web/API/Performance
const oldCallback = performance.onresourcetimingbufferfull;
performance.onresourcetimingbufferfull = function(_event: unknown): void {
logger.warn('[Tracing]: Resource Timing Buffer is FULL! Increasing it to 300');
performance.setResourceTimingBufferSize(300);
if (oldCallback) {
oldCallback.apply(this, arguments);
}
};
}

if (this._emitOptionsWarning) {
logger.warn(
'[Tracing] You need to define `tracingOrigins` in the options. Set an array of urls or patterns to trace.',
Expand Down Expand Up @@ -603,14 +617,6 @@ export class Tracing implements Integration {
addSpan(evaluation);
}

// The Performance object has a limited buffer size, often 150 entries. At some point the buffer may overflow, in
// which case we would not be able to use it to create/update spans. Therefore, after we have processed entries to
// report to Sentry, we clear the buffer in an attempt to allow for more entries to be added in the future.
// https://developer.mozilla.org/en-US/docs/Web/API/Performance
logger.log('[Tracing] Clearing most performance marks');
performance.clearMarks();
performance.clearMeasures();
performance.clearResourceTimings();
Comment on lines -606 to -613
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Tracing._performanceCursor = Math.max(performance.getEntries().length - 1, 0);

// tslint:enable: no-unsafe-any
Expand Down