-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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?
feat(replay): Add traces_by_timestamp to replay event
#18048
Conversation
In order to support moving our custom rrweb events to EAP, we need to send timestamps w/ trace ids so that we can identify which trace the event belongs to. In order to avoid breaking changes, we should not change the current type of trace_ids field in the replay event, instead we add a new field traces_by_timestamp
size-limit report 📦
|
node-overhead report 🧳Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.
|
|
@sentry review |
packages/replay-internal/src/coreHandlers/handleAfterSendEvent.ts
Outdated
Show resolved
Hide resolved
packages/replay-internal/test/integration/coreHandlers/handleAfterSendEvent.test.ts
Show resolved
Hide resolved
|
@sentry review |
…-timestamps-w-trace-ids
| trace_ids: uniqueTraceIds, | ||
| traces_by_timestamp: traceIds | ||
| .filter(([_ts, traceId]) => uniqueTraceIds.includes(traceId)) | ||
| .map(([ts, traceId]) => [ts, traceId]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Redundant Filter Causes Unnecessary Performance Overhead
The filter for traces_by_timestamp is redundant. Since uniqueTraceIds is derived directly from traceIds, every trace ID in traceIds will always be present in uniqueTraceIds. This makes the filter a no-op, always returning true, and introduces unnecessary O(n²) performance overhead.
| if (event.contexts?.trace?.trace_id && replayContext.traceIds.size < 100) { | ||
| replayContext.traceIds.add(event.contexts.trace.trace_id); | ||
| if (event.contexts?.trace?.trace_id && event.start_timestamp && replayContext.traceIds.length < 100) { | ||
| replayContext.traceIds.push([event.start_timestamp, event.contexts.trace.trace_id]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to support moving our custom rrweb events to EAP, we need to send timestamps w/ trace ids so that we can identify which trace the event belongs to.
In order to avoid breaking changes, we should not change the current type of
trace_idsfield in the replay event, instead we add a new fieldtraces_by_timestampw/ type[transaction.start_timestamp, traceId][].Previously, we would clear all trace ids after each replay segment. so if there is not a new transaction, segments would not have a trace id associated at all. I've changed this so that we always keep the most recent trace id in between segments.
Also previously, in order to associate a replay with a trace, we wait until after a
type: transactionevent is sent successfully. it's possible that the replay integration is loaded after this event is sent and never gets associated with any trace ids. in this case, I've changed it so that we take the trace id from current scope and propagation context, and I use -1 for the timestamp here, but could also change to use current ts.