Elastic apm - 以编程方式禁用特定端点的事务/跨度

问题描述

我在 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();

解决方法

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

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

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

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

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...