Provides OpenTelemetry instrumentation for okhttp3.
Replace OPENTELEMETRY_VERSION
with the latest
release.
Replace BYTEBUDDY_VERSION
with the latest
release.
This plugin leverages Android's Transform API to instrument bytecode at compile time. You can find more info on its repo page.
plugins {
id 'net.bytebuddy.byte-buddy-gradle-plugin' version 'BYTEBUDDY_VERSION'
}
implementation("io.opentelemetry.android:okhttp-3.0-library:OPENTELEMETRY_VERSION")
byteBuddy("io.opentelemetry.android:okhttp-3.0-agent:OPENTELEMETRY_VERSION")
After adding the plugin and the dependencies to your project, your OkHttp requests will be traced automatically.
You can configure the automatic instrumentation by using the setters from the OkHttpInstrumentation instance provided via the AndroidInstrumentationLoader as shown below:
OkHttpInstrumentation instrumentation = AndroidInstrumentationLoader.getInstrumentation(OkHttpInstrumentation.class);
// Call `instrumentation` setters.
Note
You must make sure to apply any configurations before initializing your OpenTelemetryRum instance (i.e. calling OpenTelemetryRum.builder()...build()). Otherwise your configs won't be taken into account during the RUM initialization process.