-
Notifications
You must be signed in to change notification settings - Fork 550
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
[WIP] feat(user-interaction): create one span per interaction #980
[WIP] feat(user-interaction): create one span per interaction #980
Conversation
This refactors the user interaction instrumentation to create a single span per event target. Previously it was creating one span per listener function. This resulted in difficulties when analyzing these spans, as they appeared idential. This changes makes the instrumentation much more in line with the upcoming Responsiveness metric: https://web.dev/better-responsiveness-metric/ In order to accomplish this, all patching of the Zone APIs have been removed. Instead, it uses the addEventListener/removeEventListener patches just like the non-Zone implementation. Instead, it leverages a new ZoneSpec definition to manage interaction state.
8d9714e
to
51cae2e
Compare
// current === target is true only when intercepting "root" UserInteractionZone | ||
if (current === target) { | ||
try { | ||
// this.printDebugInfo('root::onInvoke'); |
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.
snip? Or useful to keep in for debugging?
plugins/web/opentelemetry-instrumentation-user-interaction/src/enums/AttributeNames.ts
Outdated
Show resolved
Hide resolved
…/enums/AttributeNames.ts
constructor(config?: UserInteractionInstrumentationConfig) { | ||
super('@opentelemetry/instrumentation-user-interaction', VERSION, config); | ||
this._eventNames = new Set(config?.eventNames ?? DEFAULT_EVENT_NAMES); | ||
this._shouldPreventSpanCreation = |
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.
❓
why did we get rid of the shouldPreventSpanCreation
?
new UserInteractionZoneSpec( | ||
span, | ||
function onComplete(attributes, events) { | ||
console.log('onComplete', event); |
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.
When using this w/ react, I'm noticing that this onComplete function is executed right away and isn't being delayed until the async activity is completed.
I updated your initial stack blitz with an example here if you'd like to take a look.
This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days. |
This PR was closed because it has been stale for 14 days with no activity. |
Hey @bradfrosty, thanks for sharing this work! I just recently started looking into this package and bumped into similar issues. Have you wholly switched to maintaining your forked internal version of user-interactions instrumentation? Let me know if I can help with anything here. I'd like to see this merged. |
Has this fix/change been abandoned? |
@Josh-a-e this component was maintained by a contributor who is no longer with the project, but if you're interested in this I would suggest you join the RUM SIG. We're holding off on many browser things while we wait for them to make some fundamental decisions about how they should work, including things like this. |
Which problem is this PR solving?
Fixes #548
This a WIP solution that replaces #548, and should account for some of the debate around the approach in that PR regarding heuristics. However, this solution is a much larger diff (albeit less code/simpler than existing solution by avoiding Zone patches).
See StackBlitz for example
Short description of the changes
event.timeStamp
, and ends after all async tasks have been performed within all listener callbacks. Starting fromevent.timeStamp
improves the recording accuracy as it now accounts for the input delay (aka First Input Delay but for all interactions)processingStart
(when the browser is able to start executing),processingEnd
(when all synchronous work is complete),listenerCount
(total count of listeners that executed for the interaction), and detailed task counts (number of async tasks executed). TheprocessingStart
andprocessingEnd
metrics are the same values found on the spec'd PerformanceEventTiming interface.Checklist
npm run test-all-versions
for the edited package(s) on the latest commit if applicable.up
anddown
metrics (e.g.mousedown
+mouseup
,keydown
+keyup
) to further align with Responsiveness metric, since both events are guaranteed to occur and count as a single "interaction"