open-telemetry / opentelemetry-js-contrib

OpenTelemetry instrumentation for JavaScript modules
https://opentelemetry.io
Apache License 2.0
663 stars 488 forks source link

"Session" support for web tracing #952

Open austinlparker opened 2 years ago

austinlparker commented 2 years ago

Is your instrumentation request related to a problem? Please describe

A front-end application often has many hundreds or thousands of individual requests or transactions as part of a greater 'user session' that can take place over minutes or hours. A single trace that attempted to capture all events as part of this session would be unmanageable for analysis, and would appear 'broken' until the session completed even as back-end work was performed. Web instrumentation should be able to correlate logical interactions occurring within a single session to each other using links.

Is it applicable for Node or Browser or both?

Browser

Do you expect this instrumentation to be commonly used?

Yes. :)

What version of instrumentation are you interested in using?

n/a

Additional context

My gut feeling is that this is somewhat of a large problem to solve as session management isn't something we can infer. What I believe this instrumentation should be is a "helper" that can manage starting/ending sessions, along with keeping track of trace context state, in order to aid developers in linking traces that are part of a single session together. Once this exists, there would be a lot of potential applications -- my immediate thought is that this could be connected with user analytic tools such as Segment in order to attach trace context to segment events, allowing devs + product managers to create SLO's that can see individual user behavior and link it to back-end signals.

I'm opening this issue because I think this would be something that'd be keen to provide and really help with the 'RUM' component of otel-web, and would like to get it on maintainer's radar.

austinlparker commented 2 years ago

I've also been informed that there's an OTEP baking that includes this type of work so it can probably be considered with that when it lands.

vmarchaud commented 2 years ago

Linking both RUM SIG notes (https://docs.google.com/document/d/16Vsdh-DM72AfMg_FIt9yT9ExEWF4A_vRbQ3jRNBe09w/edit) and the OTEP in question (https://docs.google.com/document/d/1bVCOYVgfbfF3Etdj4Y9x3dV2RdA-K_pKRREEKbVyfnY/edit#heading=h.v1yewp2yhfs) for others

austinlparker commented 2 years ago

Thanks!

padzikm commented 1 year ago

Hi, I implemented session tracing by using links - you can see example here https://github.com/padzikm/TiltSample/blob/master/frontend/src/app/app.component.ts Each request to backend is separate trace as normal, but with link to originated frontend trace and frontend trace also has link to each newly created backend trace. Let me know what do you think of that

robchronosphere commented 3 months ago

Thanks for sharing, Padzikm!

Do you have any updates on when a fully integrated version of RUM session support might be available? It’s definitely the most requested feature I've been hearing about.