-
Notifications
You must be signed in to change notification settings - Fork 142
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
⚡️ [RUMF-1113] Notify performance entries by batch #1255
⚡️ [RUMF-1113] Notify performance entries by batch #1255
Conversation
331fa54
to
a95a3b9
Compare
Codecov Report
@@ Coverage Diff @@
## main #1255 +/- ##
==========================================
+ Coverage 89.93% 89.98% +0.05%
==========================================
Files 105 105
Lines 4370 4385 +15
Branches 989 991 +2
==========================================
+ Hits 3930 3946 +16
+ Misses 440 439 -1
Continue to review full report at Codecov.
|
a95a3b9
to
dce37e5
Compare
dce37e5
to
361a562
Compare
|
||
lifeCycle.notify(LifeCycleEventType.PERFORMANCE_ENTRY_COLLECTED, entry) | ||
function filterRumPerformanceEntries(entries: PerformanceEntry[]) { |
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.
💬 suggestion: I find it a bit confusing to have different levels of filtering. Maybe this function could be used similarly to isIncompleteNavigation
and isForbiddenResource
? Or maybe we could simply remove it and let subscribers do the check themselves...
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.
filterRumPerformanceEntries
filters first because it garantes that the rest of the code deals only with RumPerformanceEntry. Maybe a different naming would be better?
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 find it a bit confusing to have different levels of filtering.
+1
we could also have a filterRumAllowedPerformanceEntries
that do all filtering operations
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.
💬 suggestion: Also you could use a isRumPerformanceEntry(entry: PerformanceEntry): entry is RumPerformanceEntry
to have a nice typeguard without needing to cast as unknown as RumPerformanceEntry
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 type guard does not work because there is no type relation between PerformanceEntry and RumPerformanceEntry. Also having a single filterRumAllowedPerformanceEntries where there is every check is weird since we can have PerformanceEntry[]
or RumPerformanceEntry[]
as input.
I identified two possible options:
- The PerformanceEntry[] as to go through the first filter to be checked and cast to RumPerformanceEntry[].
- The filter function as to be defined something like
filterRumAllowedPerformanceEntries(entries: Array<PerformanceEntry | RumPerformanceEntry>)
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 changed the implementation according to what we said during the daily. Let me know what you think.
packages/rum-core/src/domain/rumEventsCollection/view/trackInitialViewTimings.ts
Outdated
Show resolved
Hide resolved
packages/rum-core/src/domain/rumEventsCollection/view/trackInitialViewTimings.ts
Outdated
Show resolved
Hide resolved
💭 thought: It's not directly related to this PR but by looking at the code all performance subscribers need only one entryType at a time.
Of course, it could be done later in a different PR. |
packages/rum-core/src/domain/rumEventsCollection/view/trackInitialViewTimings.ts
Outdated
Show resolved
Hide resolved
|
||
lifeCycle.notify(LifeCycleEventType.PERFORMANCE_ENTRY_COLLECTED, entry) | ||
function filterRumPerformanceEntries(entries: PerformanceEntry[]) { |
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.
💬 suggestion: Also you could use a isRumPerformanceEntry(entry: PerformanceEntry): entry is RumPerformanceEntry
to have a nice typeguard without needing to cast as unknown as RumPerformanceEntry
Motivation
Notifying performance entries by batch instead of one by one could be a nice quick win to avoid repeating the same actions too many times, notably when computing the loading time. Since most of the time, performance entries are already provided as a list by the browser APIs, we could simply notify once for each list.
Changes
Testing
I have gone over the contributing documentation.