Micronaut has a zipkin tracing library where you can easily override the zipkin server http endpoint like this:
tracing:
zipkin:
enabled: true
http:
urls: https://trace-api.eu.newrelic.com/trace/
Now by default it adds DEFAULT_PATH = "/api/v2/spans"
to it, but for new relic the entire path should be like:
https://trace-api.eu.newrelic.com/trace/v1?Api-Key={INSERT_API_KEY}&Data-Format=zipkin&Data-Format-Version=2
I tried with Bean replacement and factories, but I just cannot find a proper clean solution.
The only solution I have found is by copying the entire public final class HttpClientSender extends Sender
class as public final class NewRelicSender extends Sender
and just modifying the constructor:
public NewRelicSender(
HttpClientConfiguration clientConfiguration,
Provider<LoadBalancerResolver> loadBalancerResolver) {
this.loadBalancerResolver = loadBalancerResolver;
this.clientConfiguration = clientConfiguration;
this.encoding = Encoding.JSON;
this.messageMaxBytes = 5 * 1024;
this.compressionEnabled = true;
this.endpoint = URI.create("https://trace-api.eu.newrelic.com/trace/v1?Api-Key={INSERT_API_KEY}&Data-Format=zipkin&Data-Format-Version=2");
}
It does work, but I feel like there is a better way to do this. I am copying almost 300 lines of code to replace 1.
What would be the Micronaut way of doing this?