-
Notifications
You must be signed in to change notification settings - Fork 93
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(clock-drift): Apply clock drift normalization only if sent_at
is defined
#3405
feat(clock-drift): Apply clock drift normalization only if sent_at
is defined
#3405
Conversation
@@ -308,30 +314,30 @@ fn normalize_timestamps( | |||
) { | |||
let received_at = received_at.unwrap_or_else(Utc::now); | |||
|
|||
let mut sent_at = None; | |||
let mut event_timestamp = None; |
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.
Renamed because I didn't want confusion with the new has_sent_at
property.
cd61803
to
4ec8bdc
Compare
sent_at
is defined
What are the SDK versions where this is fixed? Do we have a big event influx from these outdated versions? Bonus points if this is documented in develop docs! |
// TODO: Temporary workaround before processing. Experimental SDKs relied on a buggy
// clock drift correction that assumes the event timestamp is the sent_at time. This
// should be removed as soon as legacy ingestion has been removed. Curious what this has to do with the legacy ingestion (I assume directly to Sentry). |
@jan-auer mentioned this in one of our private discussions. From what I understood, the |
CHANGELOG.md
Outdated
- Allow spans with no `exclusive_time`. ([#3385](https://github.com/getsentry/relay/pull/3385)) | ||
- Perform clock drift normalization only when `sent_at` is set in the `Envelope` headers. ([#3405](https://github.com/getsentry/relay/pull/3405)) |
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 move Bug Fixes to above Features, it's the first thing people should read IMO.
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.
Yep, will do.
timeout=1 | ||
).get_transaction_event() | ||
error_name, error_metadata = transaction_event["_meta"]["timestamp"][""]["err"][0] | ||
assert error_name == "clock_drift" |
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.
Should we also assert on the actual timestamps in the event? (Same for tests below).
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.
I was considering it, my only problem was that received_at
seems to be inferred by Relay on receive time, so I might have to either mock things or freeze time but it seems like this is not possible in an integration test.
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.
What I know is that sdk_time
will be one_month_ago
and server_time
will be received_at
and the new timestamp is + the difference of the above.
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.
I opted for a middle ground, I do test for >
in the timestamps which should be normalized, and =
when the timestamps must remain the same.
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.
The assert could be a much smaller window though, right? transaction_event["timestamp"] > now.timestamp()
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.
If there was a way to freeze or hardcode the received_at
time, I could compute the exact test expectations.
If we can't, to make the test more precise, we could assert transaction_event["timestamp"] == now
within some bounds but I am not super confident to define them since they are dependent on the time it takes for the integration test to run and I would not want to introduce a flaky test.
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.
I wouldn't exactly assert, but if you compare to the now
value taken at the beginning of the test, that should be good, additionally you could also take another "now" value at the end and check whether the expected value is between those. I wouldn't try to freeze time etc. that will just break at some point. Being within a few seconds should be good enough.
@iambriccardo in the PR description, could you elaborate a bit more on why this is now OK? (Transactions no longer sent to |
Re store endpoint, but these old (broken?) SDKs are still sending data, why can we change it now? |
This was used just for beta SDKs while Performance monitoring was experimental. As we launched the first stable version of Performance Monitoring to general availability, we required an SDK upgrade. Hence this is safe to remove. |
Nice, thanks! |
timeout=1 | ||
).get_transaction_event() | ||
error_name, error_metadata = transaction_event["_meta"]["timestamp"][""]["err"][0] | ||
assert error_name == "clock_drift" |
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.
The assert could be a much smaller window though, right? transaction_event["timestamp"] > now.timestamp()
This PR applies clock drift normalization only when
sent_at
is defined in the envelope headers.The previous implementation was falling back to
event.timestamp
if the incoming event was a transaction. That was expected behavior for old SDKs which didn't sendsent_at
however we do not have anymore SDKs using the/store
endpoint, which means that we can assume thatsent_at
is sent for each envelope. If not sent, we won't perform clock drift normalization instead of usingevent.timestamp
like before.Closes: #1625