-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
Description
I’m using the Elastic APM Android SDK (auto-instrumentation) to capture HTTP calls in my Android application. According to the [official documentation](https://www.elastic.co/guide/en/apm/guide/current/), I can implement a custom HttpAttributesVisitor and add it to the HttpTraceConfiguration to modify or add attributes (e.g., rename spans to include the endpoint path). However, my custom visitor is never invoked during runtime, and no logs appear to show that it’s being accessed.
Steps to Reproduce
- Initialize the agent in
Application.onCreate()(or a similar place) withenableHttpTracing(true):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 network calls using OkHttp or another supported library.
- Observe that the HTTP spans appear in APM (named
HTTP GETorHTTP POST), but the custom visitor’s code never runs (no log statements, no custom attributes visible).
Expected Behavior
- The
HttpAttributesVisitorshould be called for every auto-instrumented HTTP request. - My custom log (
Log.d("MyTest", ...)) should appear in Logcat. - Additional attributes (e.g.,
"http.route") or custom data should be visible in the APM UI.
Actual Behavior
- HTTP requests are auto-instrumented and show up in APM as
HTTP GETorHTTP POST, but the custom visitor code is never triggered. - No logs from
HttpAttributesVisitor. - No additional attributes in APM.
Workarounds Tried
- Verified that the agent initializes before any network calls.
- Attempted
HttpFilteror different approaches to confirm instrumentation. Only the defaultBasicHttpAttributesVisitoroutput is visible. - Tried using various attributes (
http.route,http.target) to see if any rename logic might appear. - Disabled auto-instrumentation and used manual instrumentation, which works but defeats the purpose of a
HttpAttributesVisitor.
Request
- Please confirm if
HttpTraceConfigurationwith a customHttpAttributesVisitoris fully supported in this SDK version for auto-instrumented OkHttp calls. - If it is supported, is there additional configuration needed (e.g., a separate artifact or version mismatch)?
- Any guidance on why the visitor might never be invoked would be very helpful.
Thanks in advance!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Type
Fields
Give feedbackNo fields configured for issues without a type.