Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Exemplar keeps stale span context when a reservoir cell is overwritten outside a span

已关闭 适合新手
#8,869 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
88/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
java
领域
observability

调研方向

从 sdk/metrics/.../internal/exemplar/ReservoirCell.java 中的 offerMeasurement() 开始,重点查看第 73-76 行。通过在一个经过采样的 span 内记录,然后在同一 bucket 中离开该 span 后记录,再进行 collect,使用始终启用的 exemplars 复现。完成条件是:被覆盖 exemplar 的 span context 属于新的 measurement,并且对于 span 外的记录无效。

由索引模型根据 Issue 内容生成。

描述

Describe the bug
When an exemplar reservoir cell is overwritten within one collection cycle by a measurement recorded outside a span, the exported exemplar has the new value, time and attributes but keeps the trace/span id of the previous measurement.

Steps to reproduce

  1. Build an SdkMeterProvider with setExemplarFilter(ExemplarFilter.alwaysOn()) (or otel.metrics.exemplar.filter=always_on).
  2. On a histogram with default buckets, call record(1.0) inside a sampled span, then record(2.0) with no active span (same bucket).
  3. Collect.

What did you expect to see?
An exemplar with value=2.0 and an invalid span context. The spec defines an exemplar as one recorded measurement, with the trace/span id of the span active when it was recorded.

What did you see instead?
value=2.0 with the span id of the first measurement. ReservoirCell.offerMeasurement() (sdk/metrics/.../internal/exemplar/ReservoirCell.java lines 73-76) always overwrites value, time and attributes, but updates spanContext only when the new span context is valid.

What version and what artifacts are you using?
Artifacts: opentelemetry-sdk-metrics
Version: main @ ce32c1205
How did you reference these artifacts? Local build

Environment
Compiler: Temurin 21
OS: N/A

Additional context
Not visible with the default trace_based filter, since every measurement it lets through has a sampled span.

Spec: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#exemplar

主要语言
Java
星标
2.5k
派生
1k
平均合并
2 天 21 小时
30 天内合并 PR
75

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

open-telemetry/opentelemetry-java 的其他 Issue

查看 open-telemetry/opentelemetry-java 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。