-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(replay): Add traces_by_timestamp to replay event
#18048
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
803b175
17cb7b4
483def2
10c2825
6ffdce0
5a8c6b3
f50a1cb
31a8e9a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,13 @@ | ||
| /* eslint-disable max-lines */ // TODO: We might want to split this file up | ||
| import type { ReplayRecordingMode, Span } from '@sentry/core'; | ||
| import { getActiveSpan, getClient, getRootSpan, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, spanToJSON } from '@sentry/core'; | ||
| import { | ||
| getActiveSpan, | ||
| getClient, | ||
| getCurrentScope, | ||
| getRootSpan, | ||
| SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, | ||
| spanToJSON, | ||
| } from '@sentry/core'; | ||
| import { EventType, record } from '@sentry-internal/rrweb'; | ||
| import { | ||
| BUFFER_CHECKOUT_TIME, | ||
|
|
@@ -192,7 +199,7 @@ export class ReplayContainer implements ReplayContainerInterface { | |
| this._hasInitializedCoreListeners = false; | ||
| this._context = { | ||
| errorIds: new Set(), | ||
| traceIds: new Set(), | ||
| traceIds: [], | ||
| urls: [], | ||
| initialTimestamp: Date.now(), | ||
| initialUrl: '', | ||
|
|
@@ -1098,7 +1105,11 @@ export class ReplayContainer implements ReplayContainerInterface { | |
| private _clearContext(): void { | ||
| // XXX: `initialTimestamp` and `initialUrl` do not get cleared | ||
| this._context.errorIds.clear(); | ||
| this._context.traceIds.clear(); | ||
| // We want to preserve the most recent trace id for the next replay segment. | ||
| // This is so that we can associate replay events w/ the trace. | ||
| if (this._context.traceIds.length > 1) { | ||
| this._context.traceIds = this._context.traceIds.slice(-1); | ||
| } | ||
| this._context.urls = []; | ||
| } | ||
|
|
||
|
|
@@ -1126,11 +1137,26 @@ export class ReplayContainer implements ReplayContainerInterface { | |
| * Return and clear _context | ||
| */ | ||
| private _popEventContext(): PopEventContext { | ||
| if (this._context.traceIds.length === 0) { | ||
| const currentTraceId = getCurrentScope().getPropagationContext().traceId; | ||
| if (currentTraceId) { | ||
| // Previously, in order to associate a replay with a trace, sdk waits | ||
| // until after a `type: transaction` event is sent successfully. it's | ||
| // possible that the replay integration is loaded after this event is | ||
| // sent and never gets associated with any trace. in this case, use the | ||
| // trace from current scope and propagation context. We associate the | ||
| // current trace w/ the earliest timestamp in event buffer. | ||
| // | ||
| // This is in seconds to be consistent with how we normally collect | ||
| // trace ids from the SDK hook event | ||
| this._context.traceIds.push([this._context.initialTimestamp / 1000, currentTraceId]); | ||
| } | ||
| } | ||
| const _context = { | ||
| initialTimestamp: this._context.initialTimestamp, | ||
| initialUrl: this._context.initialUrl, | ||
| errorIds: Array.from(this._context.errorIds), | ||
| traceIds: Array.from(this._context.traceIds), | ||
| traceIds: this._context.traceIds, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Shared array reference corrupts replay contextIn |
||
| urls: this._context.urls, | ||
| }; | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.