Describe the bug
When using a custom HttpAttributesVisitor with the Elastic APM Android SDK, it never gets invoked for auto-instrumented HTTP requests. The default spans (HTTP GET, HTTP POST) appear in APM, but the custom visitor code (including any log statements) is never executed.
To Reproduce
-
Use this configuration (simplified example):
class ApmAttributesVisitor : HttpAttributesVisitor {
override fun visit(builder: AttributesBuilder, request: HttpRequest) {
Log.d("ApmAgentLogs", "Enter Visitor fun")
val uri = Uri.parse(request.url.toString())
val rawPath = uri.path ?: "/"
builder.put("http.route", rawPath)
}
}
val httpTraceConfig = HttpTraceConfiguration.builder()
.addHttpAttributesVisitor(ApmAttributesVisitor())
.build()
val instrumentationsConfig = InstrumentationConfiguration.builder()
.enableHttpTracing(true)
.build()
val elasticConfig = ElasticApmConfiguration.builder()
.setHttpTraceConfiguration(httpTraceConfig)
.setInstrumentationConfiguration(instrumentationsConfig)
.setServiceName("MyServiceName")
.build()
ElasticApmAgent.initialize(application, elasticConfig)
-
Make an OkHttp-based network call.
-
Observe that the APM UI captures spans named HTTP GET or HTTP POST, but your custom visitor’s logic is never called (no logs, no custom attributes).
Expected behavior
- The
HttpAttributesVisitor should be invoked for each auto-instrumented HTTP request.
- Logs in
visit(...) should appear in Logcat.
- Any custom attributes (e.g.,
http.route) should appear in the APM UI.
Debug logs
I enabled debug logging for the agent but found no references to the custom visitor being invoked.
Describe the bug
When using a custom
HttpAttributesVisitorwith the Elastic APM Android SDK, it never gets invoked for auto-instrumented HTTP requests. The default spans (HTTP GET,HTTP POST) appear in APM, but the custom visitor code (including any log statements) is never executed.To Reproduce
Use this configuration (simplified example):
Make an OkHttp-based network call.
Observe that the APM UI captures spans named
HTTP GETorHTTP POST, but your custom visitor’s logic is never called (no logs, no custom attributes).Expected behavior
HttpAttributesVisitorshould be invoked for each auto-instrumented HTTP request.visit(...)should appear in Logcat.http.route) should appear in the APM UI.Debug logs
I enabled debug logging for the agent but found no references to the custom visitor being invoked.