Exposing SessionProvider setter#979
Conversation
| @VisibleForTesting | ||
| OpenTelemetryRumBuilder setSessionManager(SessionManager sessionManager) { | ||
| this.sessionManager = sessionManager; | ||
| public OpenTelemetryRumBuilder setSessionProvider(SessionProvider sessionProvider) { |
There was a problem hiding this comment.
This will allow users of core to set their own session provider impl.
| import kotlin.time.Duration | ||
|
|
||
| internal class SessionManagerImpl( | ||
| internal class SessionManager( |
There was a problem hiding this comment.
The SessionManager will live only in the agent, and it will be our opinionated SessionProvider implementation.
| ): OpenTelemetryRum { | ||
| // The session manager will be a SessionProvider implementation living in the agent where the agent will | ||
| // have full control of what a session is and will also make it observable and configurable. | ||
| val sessionManager = |
There was a problem hiding this comment.
The agent will initialize and set our opinionated SessionProvider impl during its initialization.
|
Extracting to its package and allowing a custom setter makes sense to me |
|
The linked PRs try to add some built-in sampling configuration, which this PR does not. |
| */ | ||
|
|
||
| package io.opentelemetry.android.session | ||
| package io.opentelemetry.android.agent.session |
There was a problem hiding this comment.
if the agent depends on https://github.com/open-telemetry/opentelemetry-android/tree/main/session
should we move this package to that module?
There was a problem hiding this comment.
That's the case right now, most of the interfaces were moved from the session module into the agent. The one interface that remains in the session module is SessionProvider. The reasoning for it is because SessionProvider is currently the only part of the API that's needed in core, and because the rest of interfaces (SessionPublisher, SessionObserver, and so on) depend on the specifics of our implementation of SessionProvider, but are otherwise not linked to SessionProvider by its contract. I guess we can just leave the interfaces in the session module, and it won't affect the goal of this PR tbh, though when it comes to API surface, I prefer to start small and expand as needed. It's also kinda strange to me that we keep implementation-specific contracts in an API package.
bidetofevil
left a comment
There was a problem hiding this comment.
LGTM.
Should we add a test that verifies that if a different sessionId is provided, the observers are sent the correct ID so that we can verify that the plumbing works as expected?
|
Given that we've got 2 approvals on this, it's looking like this is an approach we want to try/experiment with, and I'm fine with that...but I do need to point out two things that might have been overlooked:
What I do like is that it's considerably simpler, though, and has a reduced api surface. |
Users of core will need to implement their own |
Sure, I'm planning to add tests and address other housekeeping tasks before merging. |
Thanks for your feedback, @breedx-splk. Even though this PR has gotten 2 approvals, I still would like you to be on board (not necessarily approve, but at least not too concerned) with at least most of what's proposed here before merging it, given that you're a maintainer. Your feedback seems to suggest that these changes won't solve the issue that they're supposed to, and despite I believe that we should take the opportunity to make as many changes as possible while this project isn't stable, that's only valid if those changes mean an improvement over the current state, which in this case to me it would mean not only solving this issue, but other types of session related issues as well, such as the ones mentioned here and here, where some use cases demand for more user ownership about session management in general. I'll try to address your concerns below so that we can hopefully clarify how these changes can help solve those issues, and whether it makes sense to merge these changes as they are, or if we should revert some of them, as I mentioned earlier in response to one of @marandaneto's comments.
The idea of moving
One way I see that use-case achievable would be, as you suggested, by users of I admit that this approach of making I hope this provides clarifications on the concerns you mentioned above, @breedx-splk. Again, I wouldn't want to merge these changes if you don't think they provide an improvement over what we currently have, or if my interpretation of our goals with this project don't match the ones you have in mind, should that be the case then I think we need to discuss it further. |
| private final ExtendedLogger logger; | ||
|
|
||
| OpenTelemetryRumImpl(OpenTelemetrySdk openTelemetrySdk, SessionManager sessionManager) { | ||
| OpenTelemetryRumImpl(OpenTelemetrySdk openTelemetrySdk, SessionProvider sessionProvider) { |
There was a problem hiding this comment.
I actually very much like that this is loosening the type -- because SessionManager isA SessionProvider, it should have been this all along!
|
@LikeTheSalad thanks for the thorough and thought-out response. 💟 Appreciate that. I think it's fine to move the non-essential session pieces into the agent and to hide them and/or make them internal. I do appreciate that all the other pieces currently only rely on the The downside is that it leaves the I don't want to block this, and I completely see how this approach does provide a roundabout way to solve the "I can't wire up a session-id based sampler, help!"...but it is still a bummer that users will need to take on the heavy lifting of providing their own session handling in order to "just configure sampling". Because it's a step forward, let's try it out. Gotta get the build passing first, tho. 😉 |
Good point, I didn't think of it. Since it would involve removing a module I think it should probably be done in its own PR though. It also sounds like something that Hanson mentioned about moving apis too.
Btw my changes on the session APIs are based on the feedback we've gotten so far, plus an effort to keep our opinions mostly in the agent module. However, I'm open to reverting them or adding opinionated features to Also, thank you for your patience, especially for going through that quite long comment of mine. |
…onInstrumentation usage
# Conflicts: # android-agent/src/main/kotlin/io/opentelemetry/android/agent/OpenTelemetryRumInitializer.kt
|
@breedx-splk @bidetofevil @marandaneto I've just updated the code to make it compile and also fixed the unit tests. Also, I had to move back some of the session interfaces into the session module because they were being used by the |
Alternative to #974 and #971
Solves #841 and #842 (comment)
High level changes:
SessionProvideras part of the session module and moving everything else to the agent module. Reason: The core module only needs theSessionProviderto get asession.idat the moment. All the other API surface for sessions is tied to our opinionated session provider implementation (the SessionManager). By reducing the API surface insession, users of core will have less code to implement, and, should they wanted to make their ownSessionProviderimplementation "observable" for example, they can do so by creating their own contracts that are compatible with it.SessionProviderpublicly settable so that users of core can provide their implementation.NOTE: The build is broken on purpose as I didn't address unit tests and other housekeeping to keep the changes focused on the proposal. If accepted, I'll make the changes needed to make the build pass.