Skip to content
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

User interaction instrumentation not working as expected #2262

Open
Abinet18 opened this issue Jun 6, 2024 · 3 comments
Open

User interaction instrumentation not working as expected #2262

Abinet18 opened this issue Jun 6, 2024 · 3 comments

Comments

@Abinet18
Copy link
Contributor

Abinet18 commented Jun 6, 2024

When testing user interaction instrumentation with an app, there is an issue of spans not getting created if the
app scripts execute earlier than the instrumentation. I.e if the click handlers in the app script run before the instrumentation
started, it will not be using the wrapped listener.

In apps like react where additional event listeners are added , the instrumentation may catch some of the late coming listeners and it creates a few spans per click, but still if there are fetch calls made from the click, these are not created as children of the root click span , probably because the first event handler is missed(not wrapped) by the instrumentation.

Is there a way to handle such scenario where we cannot ensure the instrumentation
load and execute before the app code. Also would it be possible to keep only the root span for the event discarding the children

related issue/pr

#1749
#1750
#548

@Abinet18
Copy link
Contributor Author

Abinet18 commented Jun 6, 2024

@t2t2 @JamieDanielson @pkanal

@t2t2
Copy link
Contributor

t2t2 commented Jun 6, 2024

Is there a way to handle such scenario where we cannot ensure the instrumentation load and execute before the app code

No

 

 

 

Ok fine I'll expand on the answer

If all you care about is tracking if user clicked, then yes adding event handlers for the events you want to track like the approach in #1749 / #1750 works. That however wouln't fix the context/parent-child relationship issue (xhr, fetch, ... spans won't be children of click span) - which you mentioned earlier in the comment so that's not suitable - and separate question of how useful is data about clicks that did nothing

There might be something into registering 2 event listeners - one with capture: true, other with false and running all code between those two in the context of click span, but then you'd open up another can of worms in case someone did $.live before instrumenting or event listener on window after instrumenting

Really it's just easiest to declare that if you don't include instrumentation as the first thing, data accuracy can't be guaranteed. And this applies to instrumenting in general, because if you do fetch() before FetchInstrumentation - you're also missing that span

I have a soft suspicion that the underlaying reason for this request is fetching bootstrap information from the server before setting up otel

 

So No

@Abinet18
Copy link
Contributor Author

Abinet18 commented Jun 7, 2024

I agree that ideally otel script should load and execute before app scripts. But even if executes later , it doesn't affect the other instrumentations as much. e.g For fetch instrumentation only the fetch calls made before fetch is patched will be missed, but such fetch calls are not that many while in the user interaction case, all click events will be missed if the listener is attached before the instrumentation started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants