Skip to main content

Network Instrumentation

Generates: Spans

Automatically instruments HTTP requests via OkHttp and HttpURLConnection using bytecode instrumentation at compile time.

Setup​

Add the ByteBuddy plugin and the relevant instrumentation artifacts to your project.

Root build.gradle.kts​

plugins {
id("net.bytebuddy.byte-buddy-gradle-plugin") version "BYTEBUDDY_VERSION"
}

Replace BYTEBUDDY_VERSION with the latest release >= 1.17.x.

Jetifier + Byte Buddy

With android.enableJetifier=true, Jetifier can break builds when it touches Byte Buddy (for example Unsupported class file major version). Don't jetify Byte Buddy — add to gradle.properties:

android.jetifier.ignorelist=net.bytebuddy

App build.gradle.kts​

// OkHttp
implementation("org.dreamhorizon.instrumentation:okhttp3-library:LATEST_VERSION")
byteBuddy("org.dreamhorizon.instrumentation:okhttp3-agent:LATEST_VERSION")

// HttpURLConnection
implementation("org.dreamhorizon.instrumentation:httpurlconnection-library:LATEST_VERSION")
byteBuddy("org.dreamhorizon.instrumentation:httpurlconnection-agent:LATEST_VERSION")

Once added, HTTP requests are instrumented automatically — no code changes required.

What Gets Tracked​

Every HTTP request captures:

AttributeDescriptionAlways Present
pulse.typenetwork.<status_code> — e.g. network.200, network.404, network.0✅
http.methodHTTP method (GET, POST, etc.)✅
http.urlFull request URL✅
http.status_codeResponse status code⚠️ If response received
http.schemeURL scheme (https)⚠️ If URL parseable
http.hostHostname⚠️ If URL parseable
http.targetRequest path⚠️ If URL parseable
http.flavorProtocol version (1.1, 2.0)⚠️ If available
net.peer.nameServer hostname⚠️ If URL parseable
net.peer.portPort number⚠️ If specified
http.request.body.sizeRequest body size in bytes⚠️ When Content-Length is present in header
http.response.body.sizeResponse body size in bytes⚠️ When Content-Length is present in header

On failure​

AttributeDescription
errortrue
exception.typeException class name
exception.messageException message