Skip to content

Enhance instrumentation API #1541

@LikeTheSalad

Description

@LikeTheSalad

Introduction

After going stable with our andrid-agent module, we've discussed plans to stabilize other modules as well, in a recent Android SIG meeting.

One of the modules that could be ideal as a next candidate to become stable is android-instrumentation, where the base abstraction for all of OTel Android instrumentations is defined (AndroidInstrumentation), which would open the possibilities of marking specific instrumentations as stable right after.

The problem

However, before we stabilize the instrumentation API, I think we should make sure that it's flexible enough so that it can be extended in the future without having to introduce breaking changes or having to resort to workarounds, as we currently do with our CrashReporterInstrumentation, where we cast an OpenTelemetry instance to OpenTelemetrySdk for it to work properly:

// TODO avoid using OpenTelemetrySdk methods, only use the ones from OpenTelemetry api.
crashReporter.install(ctx.openTelemetry as OpenTelemetrySdk)

Proposals

I've put together a couple of proposals to make the instrumentation API more flexible, hoping it can be extended as needed in the future:

  • Option 1 - Ensures that our OpenTelemetryRum abstraction can support common use cases, such as flushing log records (needed for our crash instrumentation).
  • Option 2 - Creates separate/optional APIs that implementations of OpenTelemetryRum would have to opt-in to enable some use cases, such as flushing log records (needed for our crash instrumentation).

Both options extend our OpenTelemetryRum abstraction to make it provide common tools, such as the Clock instance used in our OpenTelemetry instance, needed by our ActivityLifecycleInstrumentation, and a SessionProvider instance, used by our SessionInstrumentation, as well as being a common RUM concept, so it sounds reasonable to make it available in our RUM abstraction.

I'm looking for some feedback on those, to see which one suits us all better, or to see extra alternatives that we can choose from as well.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions