Skip to content
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

feat(Session Replay): ReplayEvent, ReplayRecording and Envelope handling #3638

Merged
merged 24 commits into from
Feb 29, 2024

Conversation

brustolin
Copy link
Contributor

@brustolin brustolin commented Feb 14, 2024

Added SentryReplayEven, SentryReplayRecording and Envelope handling for this new types.

#skip-changelog

Relates to:

Copy link

github-actions bot commented Feb 14, 2024

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 53b3089

@brustolin brustolin changed the title Feat(sr)/replay event feat(Session Replay): ReplayEvent, ReplayRecording and Envelope handling Feb 14, 2024
Copy link

github-actions bot commented Feb 14, 2024

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1203.16 ms 1216.26 ms 13.09 ms
Size 21.58 KiB 429.58 KiB 408.00 KiB

Previous results on branch: feat(SR)/ReplayEvent

Startup times

Revision Plain With Sentry Diff
6381b5a 1239.04 ms 1243.80 ms 4.76 ms
20a0fe7 1204.59 ms 1211.98 ms 7.39 ms
91877f9 1196.71 ms 1212.69 ms 15.98 ms
90ce64a 1204.37 ms 1212.98 ms 8.61 ms
39743bf 1234.49 ms 1258.06 ms 23.57 ms

App size

Revision Plain With Sentry Diff
6381b5a 21.58 KiB 423.65 KiB 402.06 KiB
20a0fe7 21.58 KiB 429.51 KiB 407.92 KiB
91877f9 21.58 KiB 422.76 KiB 401.17 KiB
90ce64a 21.58 KiB 424.51 KiB 402.93 KiB
39743bf 21.58 KiB 429.46 KiB 407.88 KiB

Sources/Sentry/SentryClient.m Show resolved Hide resolved
Sources/Sentry/SentryDateUtil.m Outdated Show resolved Hide resolved
Sources/Sentry/SentryReplayEvent.m Outdated Show resolved Hide resolved
Sources/Sentry/SentryReplayRecording.m Outdated Show resolved Hide resolved
@brustolin brustolin requested a review from vaind February 15, 2024 08:30
Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

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

That looks great. I'm excited to see session reply land on Cocoa soonish 😃. A few points to consider:

  1. Some new classes miss NS_ASSUME_NONNULL_BEGIN and NS_ASSUME_NONNULL_END. Please add them. I think we should write a linter for that.
  2. You could consider writing classes without dependencies in Swift.
  3. I think you could set the base of this PR to main, so we include it sooner in the code base. Less potential for merge conflicts. I'm OK with the tradeoff that there is a bit of code that isn't used yet in there.

Sources/Sentry/include/SentrySerialization.h Show resolved Hide resolved
Sources/Sentry/SentryReplayEvent.m Outdated Show resolved Hide resolved
Sources/Sentry/SentryEnvelope.m Show resolved Hide resolved
Sources/Sentry/SentryClient.m Outdated Show resolved Hide resolved
Sources/Sentry/SentryClient.m Outdated Show resolved Hide resolved
Sources/Sentry/SentryReplayRecording.m Show resolved Hide resolved
Sources/Sentry/SentryReplayRecording.m Outdated Show resolved Hide resolved
Copy link
Collaborator

@vaind vaind left a comment

Choose a reason for hiding this comment

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

LGTM so far

Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

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

A few comments

Sources/Sentry/include/SentryDataCategory.h Outdated Show resolved Hide resolved
Sources/Sentry/SentryDataCategoryMapper.m Show resolved Hide resolved
Sources/Sentry/include/SentryMsgPackSerializer.h Outdated Show resolved Hide resolved

@end

@implementation SentryMsgPackSerializerTests
Copy link
Member

Choose a reason for hiding this comment

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

m: I think it would make sense to add some sample files in the message pack format and use them for extra tests to ensure our serialization works properly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We do have tests with files

Copy link
Member

Choose a reason for hiding this comment

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

No, I mean using some predefined dictionary with a couple of different values, serializing it with another message pack library, store the output to a file, add this file to our tests, and then comparing the results of the predefined dictionary with the stored file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Although the reading works in another message pack library (I tested it). The writing is different since I didn't optimise as explained in the SentryMsgPackSerializer.m line 35

        // We will always use the 4 bytes data length for simplicity.
        // Worst case we're losing 3 bytes.

As long we dont change the tests in this file that check for format, there is nothing to worry about.

Copy link
Member

@philipphofmann philipphofmann Feb 22, 2024

Choose a reason for hiding this comment

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

Then maybe add a snapshot. Take some sample data, serialize it with SentryMsgPackSerializer, validate the output against another message pack library, store the contents to a file, and use the file in the tests.

Sources/Sentry/SentryMsgPackSerializer.m Outdated Show resolved Hide resolved
Sources/Sentry/SentryMsgPackSerializer.m Outdated Show resolved Hide resolved
Sources/Sentry/SentryEnvelope.m Outdated Show resolved Hide resolved
Sources/Sentry/SentryClient.m Outdated Show resolved Hide resolved
Sources/Sentry/SentryMsgPackSerializer.m Outdated Show resolved Hide resolved
Sources/Sentry/SentryMsgPackSerializer.m Show resolved Hide resolved

@end

@implementation SentryMsgPackSerializerTests
Copy link
Member

Choose a reason for hiding this comment

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

No, I mean using some predefined dictionary with a couple of different values, serializing it with another message pack library, store the output to a file, add this file to our tests, and then comparing the results of the predefined dictionary with the stored file.

Sources/Sentry/include/SentryDataCategory.h Outdated Show resolved Hide resolved
}

// breadcrumbs for replay will be send with ReplayRecording
replayEvent.breadcrumbs = nil;
Copy link
Member

Choose a reason for hiding this comment

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

we probably also got to nullify other stuff that replays do not support currently:

replayEvent.extra = nil;
replayEvent.threads = nil;
replayEvent.debugMeta = nil;

Copy link
Member

Choose a reason for hiding this comment

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

and also this part which will be executed for the replay event I believe, but it shouldn't:

// Transactions have their own sampleRate
if (eventIsNotATransaction && [self isSampled:self.options.sampleRate]) {
SENTRY_LOG_DEBUG(@"Event got sampled, will not send the event");
[self recordLostEvent:kSentryDataCategoryError reason:kSentryDiscardReasonSampleRate];
return nil;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. I will fix this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe it's best to open a new PR to address prepareEvent rather than further inflating this PR

Copy link
Member

Choose a reason for hiding this comment

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

sure! just pointed it out so we don't miss that

Copy link
Member

@romtsn romtsn left a comment

Choose a reason for hiding this comment

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

LGTM 🎉

Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

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

LGTM

@brustolin brustolin merged commit 88c7547 into feat/session-replay Feb 29, 2024
@brustolin brustolin deleted the feat(SR)/ReplayEvent branch February 29, 2024 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants