【问题标题】:Modifying the micronaut tracing HttpClientSender DEFAULT_PATH to allow data send to New Relic Trace API修改 micronaut 跟踪 HttpClientSender DEFAULT_PATH 以允许将数据发送到 New Relic Trace API
【发布时间】:2021-01-29 15:59:40
【问题描述】:

Micronaut 有一个 zipkin 跟踪库,您可以在其中轻松覆盖 zipkin 服务器 http 端点,如下所示:

tracing:
  zipkin:
    enabled: true
    http:
      urls: https://trace-api.eu.newrelic.com/trace/

现在默认情况下它会添加DEFAULT_PATH = "/api/v2/spans",但是对于新的遗物,整个路径应该是这样的:

https://trace-api.eu.newrelic.com/trace/v1?Api-Key={INSERT_API_KEY}&Data-Format=zipkin&Data-Format-Version=2

我尝试使用 Bean 替换和工厂,但我找不到合适的干净解决方案。

我找到的唯一解决方案是将整个 public final class HttpClientSender extends Sender 类复制为 public final class NewRelicSender extends Sender 并仅修改构造函数:

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");
    }

它确实有效,但我觉得有更好的方法来做到这一点。我正在复制将近 300 行代码来替换 1。

Micronaut 的做法是什么?

【问题讨论】:

    标签: java newrelic micronaut zipkin


    【解决方案1】:

    我为 Micronaut 做出了贡献并提交了一个 PR,现在已合并。 Pull request

    【讨论】:

      猜你喜欢
      • 2013-03-19
      • 2022-07-29
      • 1970-01-01
      • 1970-01-01
      • 2019-04-07
      • 1970-01-01
      • 1970-01-01
      • 2013-05-10
      • 1970-01-01
      相关资源
      最近更新 更多