-
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
bug(replays): Add default user object and fill its ip-address #1805
Conversation
I decided to make the ip-address normalization function generic and implement it for event and replay. |
relay-general/src/store/normalize.rs
Outdated
pub fn normalize_ip_addresses_generic( | ||
request: &mut Annotated<Request>, | ||
user: &mut Annotated<User>, | ||
platform: &Annotated<String>, | ||
client_ip: Option<&IpAddr>, | ||
) { |
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.
Thinking out loud, instead of a function with a large signature like this, we could decompose it into smaller functions. For instance, I'm noticing that we don't have to pass the user
in. Instead, this function could return an Option<IpAddr>
and then the caller runs get_or_insert_with(|| infer_ip_address(/* ... */))
.
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.
@jan-auer I did break out some of the functionality into different units but I kept this function with the large signature. I didn't want to duplicate implementation details across two modules. If there's a better way to do this let me know. I'd also like to expedite this particular pull if possible. Its preventing ip-address ingest in prod currently.
@@ -624,22 +638,21 @@ fn normalize_ip_addresses(event: &mut Event, client_ip: Option<&IpAddr>) { | |||
} | |||
|
|||
// Copy IPs from request interface to user, and resolve platform-specific backfilling | |||
let http_ip = event | |||
.request | |||
let http_ip = request |
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.
Similarly, here we could have two separate functions. One that resolves {{auto}}, and another one that copies IP addresses over.
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.
@cmanallen I found it hard to judge by the diff whether your refactor had any functional changes that could negatively impact event processing, so I reverted parts of the refactor to make it easier to understand what actually changes. Let me know if I missed something.
If the User object is null we currently skip the ip normalization step. Now (if we have an ip-address) we will add a default User if one does not exist and add the ip-address to that User. This fixes a bug where a large number of replays were being ingested without an ip-address.
Edit: out of date. Left for historical purposes.
I also observed this functionality:
relay/relay-general/src/store/normalize.rs
Lines 593 to 650 in 0151447
Obviously my additions are much less than what this function encompasses. Some of this seems related to back-end SDKs which may be outside of scope. I did notice lines 617-620 seem to handle the case where the user's ip was submitted as
auto
. Is this something the JS SDKs do?