open-telemetry / opentelemetry-android

OpenTelemetry Tooling for Android
Apache License 2.0
146 stars 34 forks source link

Session Id Refresh Callback #328

Open Archish27 opened 5 months ago

Archish27 commented 5 months ago

When session expires we need a callback or hook to identify that the session has ended based on that we can do clean up of cached session id. Or trigger any custom logic as when required if callback implemented.

breedx-splk commented 5 months ago

Hey @Archish27. This seems like a perfectly reasonable request to me...but can you be a little more specific about what you're trying to do when notified of a session change? There is code already in place to listen for a session id expiration and generate a notification "event" that contains the new session id and the previous session id.

If you're caching the session ID elsewhere in your app or in your custom telemetry, then this will be a larger problem for you. You should always be calling OpenTelemetryRum.getRumSessionId() any time you need to reference the session ID.

Archish27 commented 5 months ago

Hey @Archish27. This seems like a perfectly reasonable request to me...but can you be a little more specific about what you're trying to do when notified of a session change? There is code already in place to listen for a session id expiration and generate a notification "event" that contains the new session id and the previous session id.

If you're caching the session ID elsewhere in your app or in your custom telemetry, then this will be a larger problem for you. You should always be calling OpenTelemetryRum.getRumSessionId() any time you need to reference the session ID.

Use case is we do screen recording so let say if session.id is changed we need to stop recording. The other use case there are some application threads running so, in a way need a callback to cleanup resources on change session event.

MdNaushad commented 3 weeks ago

@Archish27 , @breedx-splk Is there any update on this? Anyone picked this up yet?

breedx-splk commented 1 week ago

Hey @MdNaushad. We do have the SessionObserver class in place, managed by the SessionManager that implements SessionPublisher. However, there's not currently any easy way for users to get access to the SessionManager or to add observers as part of the agent/sdk setup.

Are you interested in picking this up?

We're actively working on trying to pin down the shape of our public API, especially with regard to how users set up and configure the OpenTelemetryRum instance (via builder currently). This would need to be a consideration in that API surface for sure.