You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何基于根Span实现Trace级处理器过滤,清除NodeJS健康探测Trace噪声?

基于根Span实现Trace级过滤的解决方案

你当前的过滤器配置仅针对单个Span做过滤,所以只移除了根Span,关联的子Span因未匹配过滤条件被保留。要实现整个Trace的过滤,需要调整配置层级,针对整个Trace设置规则,检查根Span的属性。

直接修改filter处理器的配置,把过滤层级从span改为trace,并通过root_span访问根Span的属性:

processors:
  filter/health_probes:
    error_mode: ignore
    traces:
      trace:
        - 'root_span.attributes["http.user_agent"] == "Edge Health Probe"'

这个配置会检查每个Trace的根Span,只要根Span的http.user_agent匹配"Edge Health Probe",整个Trace(包括所有子Span)都会被过滤掉,不会上传到Logz.io。

如果需要更精准的过滤,可以结合根Span的其他属性(比如请求方法和路径)缩小范围:

processors:
  filter/health_probes:
    error_mode: ignore
    traces:
      trace:
        - 'root_span.attributes["http.user_agent"] == "Edge Health Probe" && root_span.attributes["http.method"] == "HEAD" && root_span.attributes["http.path"] == "/"'

注意:确保你的OpenTelemetry Collector版本支持root_span访问路径,主流新版本均兼容该语法。

内容的提问来源于stack exchange,提问作者Machi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.07 18:42:16