Skip to content

Conversation

@bidetofevil
Copy link
Contributor

Move the public interface OpenTelemetryRum to a new module that all other modules can depend on, and move core as a dependency exported transitively via the android-agent module. That way, most folks won't be confused with having the choice of using OpenTelemetryRumInitializer, which is the preferred, streamlined supported option vs OpenTelemetryRumBuilder, the supposedly internal object that we don't consider part of our API.

Folks who need to figure that directly can still do so by directly including the core module, but that should not be available by default.

At the same time I changed all the module dependencies to implementation as there is no reason to export public symbols of internal modules to the consuming app. Instead, the only transitive dependency that is exported via android-agent is the new module, agent-api, so OpenTelemetryRum is still available. Internally, modules that depend on agent-api will pull it its dependencies too, which are the OTel ones.

Note: this is technically an API change in that the static functions on OpenTelemetryRum are now on a new object inside core called RumBuilder, but since this was supposed to NOT be part of the public API, this should be OK.

@bidetofevil bidetofevil requested a review from a team as a code owner November 13, 2025 16:09
@bidetofevil bidetofevil force-pushed the agent-api-refactor branch 3 times, most recently from d80e031 to f854977 Compare November 14, 2025 14:58
@codecov
Copy link

codecov bot commented Nov 14, 2025

Codecov Report

❌ Patch coverage is 40.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.17%. Comparing base (438fadc) to head (009d3bd).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...c/main/java/io/opentelemetry/android/RumBuilder.kt 25.00% 6 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1387   +/-   ##
=======================================
  Coverage   63.16%   63.17%           
=======================================
  Files         158      159    +1     
  Lines        3125     3123    -2     
  Branches      324      324           
=======================================
- Hits         1974     1973    -1     
+ Misses       1056     1055    -1     
  Partials       95       95           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

initializeOtelWithGrpc()
}

// This is not used but it's needed to verify that our consumer proguard rules cover this use case.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this still need verification?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this is a workaround for some classes that should really just have dontwarn entries in the proguard files. Regardless, it's not a problem anymore, at least in the building of the demo app, likely because core isn't exported by default and included in this app.

api(project(":instrumentation:startup"))
api(project(":instrumentation:sessions"))
api(project(":instrumentation:screen-orientation"))
implementation(project(":instrumentation:activity"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How should folks configure individual instrumentation? For example, if someone wanted to configure AnrInstrumentation what would that look like, or is that something that should be answered further down the line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If they are using the Initializer, then through the DSL via InstrumentationConfiguration.anrReporter { } 😅

All the instrumentation modules are pretty explicitly tied to the agent and the common instrumentation API, and until that changes, this will just work. To change that relationship, well, that will include changing this as well as other things.

import io.opentelemetry.android.session.SessionProvider
import io.opentelemetry.sdk.OpenTelemetrySdk

object RumBuilder {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a fan of breaking this out from the interface into a separate symbol, but preferred the name OpenTelemetryRum.builder compared to RumBuilder

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So like an extension function on the OpenTelemetryRum interface called builder() that returns an object? I kind of just stuck this here and am open to other ways of referencing this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The extension idea sounds good to me 👍

@@ -0,0 +1,8 @@
public abstract interface class io/opentelemetry/android/OpenTelemetryRum {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do folks construct instances of this interface? Ideally there should be some way of initializing from the API module IMO.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenTelemetryRumInitializer.initialize() and OpenTelemetryRumBuilder.build()

The agent-api module is basically just that - android-agent is effectively the public implementation that depends on core to do the hard work for agent-api, and it itself exposes some additional API like the OpenTelemetryRumInitializer. There could more work done in this area to consolidate the true public API to be in this module, and have android-agent just be an implementation, but that's for later.

Copy link
Contributor

@LikeTheSalad LikeTheSalad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, it looks good to me. Thanks!

Regarding the RumBuilder name, I agree we should try and keep the existing one somehow. I like the mentioned idea of using extensions.

import io.opentelemetry.android.session.SessionProvider
import io.opentelemetry.sdk.OpenTelemetrySdk

object RumBuilder {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The extension idea sounds good to me 👍

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants