Enhancing instrumentation manual install#1632
Enhancing instrumentation manual install#1632LikeTheSalad wants to merge 4 commits intoopen-telemetry:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1632 +/- ##
==========================================
+ Coverage 61.67% 61.80% +0.12%
==========================================
Files 159 159
Lines 3418 3427 +9
Branches 348 349 +1
==========================================
+ Hits 2108 2118 +10
Misses 1215 1215
+ Partials 95 94 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
fractalwrench
left a comment
There was a problem hiding this comment.
Thanks for looking at this. I left a few comments inline but would be broadly happy with this sort of approach.
| * | ||
| * @param instrumentation The instrumentation to install. | ||
| */ | ||
| fun install(instrumentation: AndroidInstrumentation) |
There was a problem hiding this comment.
Did we want to consider marking this as an incubating/beta API in some way?
| override fun install(instrumentation: AndroidInstrumentation) { | ||
| val ctx = InstallationContext(context, openTelemetrySdk, sessionProvider, clock) | ||
| instrumentation.install(ctx) | ||
| manuallyInstalledInstrumentations.add(instrumentation) |
There was a problem hiding this comment.
Is it worth guarding against misuse by checking whether the reference is already in the collection?
|
|
||
| override fun install(instrumentation: AndroidInstrumentation) { | ||
| val ctx = InstallationContext(context, openTelemetrySdk, sessionProvider, clock) | ||
| instrumentation.install(ctx) |
There was a problem hiding this comment.
Worth a try-catch for the install/uninstall functions, given that it's user-submitted code that probably shouldn't terminate the entire process?
breedx-splk
left a comment
There was a problem hiding this comment.
I'm failing to understand how adding the install(instrumentation) method on our public/stable OpenTelemetryRum interface is making things better or what problem we're solving. A couple of problems I see with this approach:
- I think this change makes things somewhat MORE confusing for users -- who now have to decide if their instrumentation should be added via
OpenTelemetryRumBuilder.addInstrumentation(instrumentation)or if they should wait until after they build theOpenTelemetryRuminstance in order to callinstall(instrumentation)on that. - You've introduced mutable state to the
OpenTelemetryRumImplinstance. Before this change, basically all the instrumentation state was configured and established at "build time". Once the rum instance was created, things didn't change...and there are numerous benefits to this. Along these same lines, I think it's confusing that a user can now just choose at any old random time to install an instrumentation. I think it's easier to reason about the code when all setup/installation is done at creation time.
I've read through the related issues and comments a couple times, but I still can't make sense of what this helps.
There's some suggestion that the InstallationContext is more accurate or something with this approach, but I think it's just passing along the same instances as before.
|
Thanks for the detailed feedback, @breedx-splk It's been a while since I explained the issues in this comment, and I wasn't aware of your opinion on it until now, which is why I proceeded to write the changes. Still, I'm glad that we can discuss it further, because it'd certainly be a big change if this gets through, so it's better to align on the details beforehand. The problemThe current instrumentation API looks like this:
It's all public, which means nothing stops any user from using it. For example, they can implement their own instrumentation and manually call However, if they choose to do so, they'd need to construct an Here's what we provide our users when initializing the agent:
Which means that, out of all the dependencies from
Potential solutionsYou can find more details in this issue. But essentially the options discussed there were 2:
Based on your comments, it sounds like you're only taking into account the ability to install instrumentations at the time of initializing |
|
Thanks @LikeTheSalad for the reply and discussion.
Sure, but I actually don't want users to call
Right, and if you recall, we used to not have an
So that's the thing: I don't want users to ever have to create instances of this! It's not a user's responsibility. I wish I could hide it or make it internal or something. If they have some custom If we want to relax this and allow users to install Another idea: I think if we put |
I think we all agree on this. The changes proposed in this PR are an option to prevent users from having to manually instantiate
I think it's the other way around. Users have always had the option to install instrumentations willy-nilly whenever they choose. We could instead do what I mentioned earlier, of at least documenting that there's only a "supported way" of doing so, and that we wouldn't provide support for issues that may arise from installing instrumentations in a "non-supported" way. Though it would probably cause issues, as it would be a virtual constraint.
This sounds like the first option I mentioned earlier, where we'd get rid of |


Related to: #1541
These changes are intended to address "challenge 1", as explained in this comment. By making the
OpenTelemetryRumimplementation take care of the creation of anInstallationContextobject, which contains the proper contextual dependencies that were used to create theOpenTelemetryinstance.