Skip to content

Instrumentation api change - option 1#1539

Draft
LikeTheSalad wants to merge 3 commits intoopen-telemetry:mainfrom
LikeTheSalad:inst-api-change-option1
Draft

Instrumentation api change - option 1#1539
LikeTheSalad wants to merge 3 commits intoopen-telemetry:mainfrom
LikeTheSalad:inst-api-change-option1

Conversation

@LikeTheSalad
Copy link
Contributor

@LikeTheSalad LikeTheSalad commented Jan 26, 2026

DO NOT MERGE

This is a proposal for this issue: #1541 - It's meant to highlight the key changes, without addressing potential compilation errors, if any. If chosen as the approach we'd like to go with, then I'll add the rest of the changes needed for the build to pass.

@LikeTheSalad LikeTheSalad force-pushed the inst-api-change-option1 branch from c92693c to 4d21ac7 Compare January 26, 2026 15:38
@@ -27,7 +26,7 @@ class CrashReporterInstrumentation : AndroidInstrumentation {
val crashReporter = CrashReporter(additionalExtractors)

// TODO avoid using OpenTelemetrySdk methods, only use the ones from OpenTelemetry api.
Copy link
Contributor

@breedx-splk breedx-splk Jan 27, 2026

Choose a reason for hiding this comment

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

todo can go away if we do this

val openTelemetry: OpenTelemetry,
val sessionProvider: SessionProvider,
val clock: Clock,
val openTelemetry: OpenTelemetryRum,
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: I don't love this name now -- because it suggests something from the upstream api and not a rum class. I might call it rum or openTelemetryRum.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. I'm up for renaming it to rum.

attributes: Attributes = Attributes.empty(),
)

fun flushLogRecords(): CompletableResultCode
Copy link
Member

Choose a reason for hiding this comment

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

IMO either shutdown() should achieve this functionality or we can expose forceFlush(). It feels like flushLogRecords() is probably exposed to make one particular feature work, but IMO it'd be preferable just to have one API that flushes all telemetry, if we even want to expose that at all..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It feels like flushLogRecords() is probably exposed to make one particular feature work

That's true, it'd only be useful for crash reporting, at least for now.

shutdown() should achieve this functionality

I'm open to that option, though I would have some questions. For example, is it ok to shut down RUM from an instrumentation? Or maybe it won't be needed to do so because shutdown() should be called on a crash automatically anyway (via our shutdownHook)? - If we decide on the latter, can we ensure that the app will have enough time to get to the SDK shutdown function before the OS kills the app?

or we can expose forceFlush()

I'm open to going with a "one method to flush all signals" approach. I'd still be a bit wary about the time it'd need to take to finish executing it all before the OS kills the app on a crash, though. But it sounds better than relying on the shutdown function, because forceFlush would be called directly from the instrumentation.

Copy link
Member

Choose a reason for hiding this comment

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

After thinking about this some more on the other PR, I would lean towards just not exposing this as a public API for now (and perhaps forever). It could be an implementation detail of the SDK: #1540 (review)


val clock: Clock

val sessionProvider: SessionProvider
Copy link
Member

Choose a reason for hiding this comment

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

Happy with this but might be worth thinking about whether SessionProvider.noop() should still be exposed. Will end-users actually invoke that function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. I guess it might be needed in case they wanted to create their own implementation of OpenTelemetryRum without sessions? It sounds like an edge case, though, so maybe it's still fine to remove it.

import io.opentelemetry.sdk.common.Clock
import io.opentelemetry.android.OpenTelemetryRum

class InstallationContext(
Copy link
Member

Choose a reason for hiding this comment

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

We could perhaps consider whether InstallationContext is required anymore given that Context and OpenTelemetryRum could plausibly be passed into the install/uninstall functions instead.

If we do keep it, perhaps it's worth renaming to something like InstallationParams given that Context has a special meaning on Android already, and that OTel already has a separate concept of context.

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 don't have a strong opinion on this, so I'm ok with either removing it or renaming it 👍

import io.opentelemetry.android.OpenTelemetryRum

class InstallationContext(
val context: Context,
Copy link
Member

Choose a reason for hiding this comment

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

I definitely like the fact that there are only 2 params left over here now.

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