-
Notifications
You must be signed in to change notification settings - Fork 99
Instrumentation api change - option 1 #1539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ package io.opentelemetry.android | |
|
|
||
| import io.opentelemetry.api.OpenTelemetry | ||
| import io.opentelemetry.api.common.Attributes | ||
| import io.opentelemetry.sdk.common.CompletableResultCode | ||
|
|
||
| /** | ||
| * Entrypoint for the OpenTelemetry Real User Monitoring library for Android. | ||
|
|
@@ -18,6 +19,10 @@ interface OpenTelemetryRum { | |
| */ | ||
| val openTelemetry: OpenTelemetry | ||
|
|
||
| val clock: Clock | ||
|
|
||
| val sessionProvider: SessionProvider | ||
|
|
||
| /** | ||
| * Get the client session ID associated with this instance of the RUM instrumentation library. | ||
| * Note: this value will change throughout the lifetime of an application instance, so it is | ||
|
|
@@ -40,6 +45,8 @@ interface OpenTelemetryRum { | |
| attributes: Attributes = Attributes.empty(), | ||
| ) | ||
|
|
||
| fun flushLogRecords(): CompletableResultCode | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO either
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That's true, it'd only be useful for crash reporting, at least for now.
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
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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) |
||
|
|
||
| /** | ||
| * Initiates orderly shutdown of this OpenTelemetryRum instance. After this method completes, | ||
| * the instance should be considered invalid and no longer used. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,15 +7,11 @@ package io.opentelemetry.android.instrumentation | |
|
|
||
| import android.app.Application | ||
| import android.content.Context | ||
| import io.opentelemetry.android.session.SessionProvider | ||
| import io.opentelemetry.api.OpenTelemetry | ||
| import io.opentelemetry.sdk.common.Clock | ||
| import io.opentelemetry.android.OpenTelemetryRum | ||
|
|
||
| class InstallationContext( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could perhaps consider whether If we do keep it, perhaps it's worth renaming to something like
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 👍 |
||
| val context: Context, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| val openTelemetry: OpenTelemetry, | ||
| val sessionProvider: SessionProvider, | ||
| val clock: Clock, | ||
| val openTelemetry: OpenTelemetryRum, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense. I'm up for renaming it to |
||
| ) { | ||
| val application: Application? = context as? Application | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,6 @@ import com.google.auto.service.AutoService | |
| import io.opentelemetry.android.instrumentation.AndroidInstrumentation | ||
| import io.opentelemetry.android.instrumentation.InstallationContext | ||
| import io.opentelemetry.android.instrumentation.common.EventAttributesExtractor | ||
| import io.opentelemetry.sdk.OpenTelemetrySdk | ||
|
|
||
| /** Entrypoint for installing the crash reporting instrumentation. */ | ||
| @AutoService(AndroidInstrumentation::class) | ||
|
|
@@ -27,7 +26,7 @@ class CrashReporterInstrumentation : AndroidInstrumentation { | |
| val crashReporter = CrashReporter(additionalExtractors) | ||
|
|
||
| // TODO avoid using OpenTelemetrySdk methods, only use the ones from OpenTelemetry api. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. todo can go away if we do this |
||
| crashReporter.install(ctx.openTelemetry as OpenTelemetrySdk) | ||
| crashReporter.install(ctx.openTelemetry) | ||
| } | ||
|
|
||
| override val name: String = "crash" | ||
|
|
||
There was a problem hiding this comment.
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?There was a problem hiding this comment.
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
OpenTelemetryRumwithout sessions? It sounds like an edge case, though, so maybe it's still fine to remove it.