You could do this by adding a custom HttpRequestInterceptor:
HttpClients.custom()
.addInterceptorFirst(new HttpRequestInterceptor() {
@Override
public void process(HttpRequest request, HttpContext context) throws HttpException, IOException {
if (request instanceof HttpEntityEnclosingRequest) {
Span span = ElasticApm.currentSpan();
HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
if (entity.isRepeatable()) {
span.addLabel("body", new String(entity.getContent().readAllBytes()));
}
}
}
}).build();
Note that tags are limited to 1024 characters and are indexed by default. The Transaction interface has a addCustom(String, String) method which has a higher limit. Adding custom data for spans sounds like a good addition though.
Sorry for the late reply. Could you send me a screenshot of such a span in the APM UI? By clicking on it, you should be able to see it's metadata, including labels.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.