【问题标题】:Elastic apm - Disable transaction/span programatically for specific endpointElastic apm - 以编程方式为特定端点禁用事务/跨度
【发布时间】:2020-12-24 16:51:41
【问题描述】:

我在 spring 应用程序中使用 elastic-apm 来监控 API 请求并跟踪为给定端点执行的所有 SQL。问题是流量弹性搜索正在收集大量数据,我希望仅针对特定端点启用捕获跨度。 我尝试使用 elastic-apm https://www.elastic.co/guide/en/apm/agent/java/current/public-api.html 的公共 api 我可以自定义事务和跨度,但找不到启用/禁用特定端点的方法。 我已经尝试过了,但没有运气 -

ElasticApm.currentSpan().startSpan();
ElasticApm.currentSpan().end();

【问题讨论】:

    标签: java apm elastic-apm


    【解决方案1】:

    看起来可以使用 api-server.yml 中的 drop_event 处理器来完成。

    processors:
     - drop_event:
         when:
           equals:
             transaction.custom.transactions_sampled: false
    

    在代码集自定义上下文中:

    Transaction elasticTransaction = ElasticApm.currentTransaction();
    elasticTransaction.addCustomContext("transactions.sampled", false);
    

    【讨论】:

      猜你喜欢
      • 2020-10-21
      • 1970-01-01
      • 1970-01-01
      • 2017-02-19
      • 2023-04-06
      • 1970-01-01
      • 2019-05-25
      • 2019-03-29
      相关资源
      最近更新 更多