-
-
Notifications
You must be signed in to change notification settings - Fork 341
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
Add sent_at
to envelope header
#2859
Conversation
|
Performance metrics 🚀
|
Revision | Plain | With Sentry | Diff |
---|---|---|---|
4d68229 | 1233.50 ms | 1262.92 ms | 29.42 ms |
8f397a7 | 1230.10 ms | 1253.88 ms | 23.77 ms |
371db89 | 1226.40 ms | 1251.54 ms | 25.14 ms |
fd6a31c | 1204.73 ms | 1222.34 ms | 17.61 ms |
d60f70a | 1219.63 ms | 1228.54 ms | 8.91 ms |
630ddf4 | 1216.50 ms | 1235.94 ms | 19.44 ms |
25737cb | 1235.02 ms | 1250.06 ms | 15.04 ms |
06548c0 | 1226.71 ms | 1252.37 ms | 25.66 ms |
c021422 | 1199.15 ms | 1222.20 ms | 23.05 ms |
b2f82fa | 1237.78 ms | 1256.02 ms | 18.24 ms |
App size
Revision | Plain | With Sentry | Diff |
---|---|---|---|
4d68229 | 20.76 KiB | 432.34 KiB | 411.58 KiB |
8f397a7 | 20.76 KiB | 420.55 KiB | 399.79 KiB |
371db89 | 20.76 KiB | 427.31 KiB | 406.55 KiB |
fd6a31c | 20.76 KiB | 436.50 KiB | 415.74 KiB |
d60f70a | 20.76 KiB | 430.97 KiB | 410.21 KiB |
630ddf4 | 20.76 KiB | 432.37 KiB | 411.61 KiB |
25737cb | 20.76 KiB | 436.29 KiB | 415.53 KiB |
06548c0 | 20.76 KiB | 427.36 KiB | 406.59 KiB |
c021422 | 20.76 KiB | 435.64 KiB | 414.88 KiB |
b2f82fa | 20.76 KiB | 419.62 KiB | 398.86 KiB |
Previous results on branch: feat/envelope-header-sent-at
Startup times
Revision | Plain | With Sentry | Diff |
---|---|---|---|
30236ed | 1239.67 ms | 1252.84 ms | 13.17 ms |
3031b91 | 1235.29 ms | 1246.32 ms | 11.03 ms |
6789a10 | 1209.59 ms | 1232.30 ms | 22.71 ms |
7044a83 | 1242.82 ms | 1264.12 ms | 21.30 ms |
f50cd0f | 1218.71 ms | 1225.84 ms | 7.12 ms |
1fe5466 | 1196.30 ms | 1232.38 ms | 36.08 ms |
5d48ce8 | 1220.37 ms | 1240.67 ms | 20.30 ms |
7078353 | 1217.05 ms | 1243.16 ms | 26.12 ms |
8ef64f7 | 1236.76 ms | 1263.14 ms | 26.38 ms |
App size
Revision | Plain | With Sentry | Diff |
---|---|---|---|
30236ed | 20.76 KiB | 432.67 KiB | 411.91 KiB |
3031b91 | 20.76 KiB | 434.72 KiB | 413.96 KiB |
6789a10 | 20.76 KiB | 432.41 KiB | 411.65 KiB |
7044a83 | 20.76 KiB | 433.29 KiB | 412.53 KiB |
f50cd0f | 20.76 KiB | 432.59 KiB | 411.83 KiB |
1fe5466 | 20.76 KiB | 431.64 KiB | 410.88 KiB |
5d48ce8 | 20.76 KiB | 435.04 KiB | 414.28 KiB |
7078353 | 20.76 KiB | 432.67 KiB | 411.91 KiB |
8ef64f7 | 20.76 KiB | 431.64 KiB | 410.88 KiB |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #2859 +/- ##
=============================================
+ Coverage 88.802% 88.827% +0.025%
=============================================
Files 492 492
Lines 52878 52900 +22
Branches 18955 18966 +11
=============================================
+ Hits 46957 46990 +33
+ Misses 4954 4946 -8
+ Partials 967 964 -3
... and 15 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
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.
LGTM
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.
Thanks for doing this, @denrase. We have to change two important pieces. See one h
comment and we also have to remove the sentry_timestamp
sentry-cocoa/Sources/Sentry/SentryNSURLRequest.m
Lines 106 to 108 in 2cf1b84
[string | |
appendFormat:@"%@,", | |
newHeaderPart(@"sentry_timestamp", @((NSInteger)[[NSDate date] timeIntervalSince1970]))]; |
See docs:
Also note that the sent_at header replaces the sentry_timestamp key previously set in authorization headers, which has now been fully deprecated. You should only send sent_at, and not sentry_timestamp.
@@ -94,6 +95,7 @@ - (void)sendUserFeedback:(SentryUserFeedback *)userFeedback | |||
|
|||
- (void)sendEnvelope:(SentryEnvelope *)envelope | |||
{ | |||
envelope.header.sentAt = SentryCurrentDate.date; |
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.
h
: This sets the sentAt timestamp to when we are caching to disk, which we must not do according to the docs:
For example, SDKs that implement caching features should avoid writing the sent_at header when caching to disk. Only write it when actually sending the event to Sentry.
Instead, we have to set sentAt
directly before we send it:
sentry-cocoa/Sources/Sentry/SentryHttpTransport.m
Lines 281 to 283 in 2cf1b84
NSURLRequest *request = [self.requestBuilder createEnvelopeRequest:rateLimitedEnvelope | |
dsn:self.options.parsedDsn | |
didFailWithError:&requestError]; |
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.
You are right, sry about that. Moved this to SentryHttpTransport.m
# Conflicts: # Sources/Sentry/SentrySerialization.m
…entry-cocoa into feat/envelope-header-sent-at
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.
Almost LGTM, thanks @denrase.
@@ -52,14 +52,17 @@ class SentryHttpTransportTests: XCTestCase { | |||
attachmentEnvelopeItem = SentryEnvelopeItem(attachment: TestData.dataAttachment, maxAttachmentSize: 5 * 1_024 * 1_024)! | |||
|
|||
eventEnvelope = SentryEnvelope(id: event.eventId, items: [SentryEnvelopeItem(event: event), attachmentEnvelopeItem]) | |||
eventEnvelope.header.sentAt = CurrentDate.date() |
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.
m
: Thanks for adapting the tests. It would be great if the tests fail, when setting the sentAt
before creating the request, for example, in SentryHttpTransport.sendEnvelope
. If it's too complicated to achieve, please don't do it. Adding a comment as explained in #2859 (comment) could also be sufficient.
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.
Please check if the comment i added is sufficient.
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.
LGTM, but the Changelog needs some fixes.
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.
Again LGTM, @denrase. What's stopping you from merging this PR?
Hello everyone, Could we get this merged soon? There are RN customers waiting for this as it will fix issues with clock drift in transactions. |
@krystofwoldrich, @denrase is not working full-time for Sentry. I can take it and finish the PR if he doesn't get to it by Tuesday. |
@philipphofmann Okay, thanks for the info, that would be awesome. What is missing, I thought it was done? |
@philipphofmann @denrase Thank you. |
📜 Description
sent_at
to envelope header💡 Motivation and Context
Relates to getsentry/sentry-dart#1337
Documentation https://develop.sentry.dev/sdk/envelopes/
💚 How did you test it?
Added tests
📝 Checklist
You have to check all boxes before merging:
sendDefaultPII
is enabled.🔮 Next steps
Test if this works correctly wit hybrid (dart) sdks.