-
Notifications
You must be signed in to change notification settings - Fork 42
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 page.on('metric') #1456
Add page.on('metric') #1456
Conversation
3c8aa19
to
ea8df64
Compare
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.
Nicely tackled with this complex issue 🙇! TBH, I should also admit that I'm not sure I understand this PR's code fully 😄 (my bad) So, I have some comments to discuss. None of them are strong opinions. Some suggestions are to hopefully make this change more descriptive, extendable, and maintainable.
Idea: If the generics solution doesn't turn out OK, we can also invent a new type, |
Nice alternative! I've linked this comment to a comment in the generalize We can tackle the generalization after merging in this PR 👍 |
94f2063
to
ef24fb2
Compare
Thanks for the review 🙏 I agree that this is a bit confusing. I will create a diagram to make things a bit clearer. |
f53dfa5
to
66e3bce
Compare
@inancgumus i created the diagram and placed it in the description of the issue. Let me know if it helps or not 🙂 |
84fb60f
to
31050eb
Compare
page.on only worked with console message, but we will need it to work for metric messages too. This change allows us to send any type and perform the type check in the handler.
It will need to be used in the page mapping.
Using switch to allow for multiple events.
This is what the user will receive in the page.on callback for the metric event. It's just a skeleton for now.
We can now map and return the metric back to the user so that they can work with it in the handle.
We want to use the regex engine in the sobek runtime which should be the same or similar to other JS regex engines. This function will be used to work with the user defined regex to group metrics with url tags.
The callback is what will be used to work with the sobek runtime. We want to avoid using sobek outside the mapping layer.
The name needs to be sent back to the caller that needs it. It is done via a channel. When running things on the taskqueue, they are done async. We need to make this process synchronous. We're relying on the nameCh (the same channel that the name is sent to the caller on) to notify the called when the handler has complete.
This function will call the handlers one by one, allowing each handler to check the url matches and return the name. Each handler will overwrite the name if multiple handlers match with the given url. This function needs to wait for the handler to complete before proceeding to the next handler.
This better represents what is happening. When a match is found, the metric is tagged. It is not grouping anything, the grouping is a wanted side effect.
We're now only creating a single MetricEvent for all handlers.
760a380
to
45b6cd5
Compare
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.
Awesome work 🎉 I've also added some suggestions for you to consider before merging it in. These suggestions are highly likely due to my lack of understanding of this change enough and are not related to the code itself 😅
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.
One last note.
Leaving the names as in the go code.
What?
This adds the functionality to group url tags by intercepting all metrics that the browser module emits, compare and match with the supplied regex(s), and then set the
name
andurl
tags with the new name supplied by the user in the script.Why?
A lot of websites will perform requests that contain dynamic parts in the request url, which could be ids that are generated on every new session, account ids, or for cache busting purposes.
This will help in two ways:
How
The user first needs to register an event handler:
This is a high level overview of what happens when a http request is started and a metric is about to be emitted:
The same happens when we're about to emit response and web vital metrics.
Checklist
Related PR(s)/Issue(s)
Updates: #371