I am making some tests using Java APM agent and Spring Boot. I used @CaptureTransaction in a Rest Controller method to get information about my RestAPI. My code does another Rest API call to a external service and I noticed that a span was created automatically by APM as image below:
You mean you want to add labels to the GET pokeapi.co span? One way would be to use the global_labels config option. If you want to add dynamic labels, you can do so by adding an interceptor to your HTTP client where you can get the automatically created span via ElasticApm.currentSpan().
I am using feign client and I tried to use an interceptor as you suggested but the ElasticApm.currentSpan().addLabel writes label in the transaction and not in the generated span.
Any hint about what could be happening?
@Component
public class FeignClientInterceptor implements RequestInterceptor {
@Override
public void apply(RequestTemplate requestTemplate) {
ElasticApm.currentSpan().addLabel("requestBody-feign-interceptor", requestTemplate.requestBody().asString());
}
}
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.