SdkSpanBuilder drops invalid parent TraceState when IdGenerator.generatesRandomTraceIds() is true

オープン
#9,062 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

@Eliot5566 がすでに取り組んでいます。

2026年11月26日 から。

  • #2 @Eliot5566 による — オープン

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
java

調査の方向性

Read SdkSpanBuilder.startSpan() around lines 201–215 and 258, then inspect CompositeSampler.shouldSample() around lines 50 and 95. Trace how an invalid parent SpanContext with a TraceState reaches the sampler when random trace IDs are enabled; the issue is done when the initial state remains observable to the sampler and is preserved in the resulting span. The issue cites related specification discussions in open-telemetry/opentelemetry-specification#5471 and #5472.

索引モデルが issue の本文から書いたものです。

説明

Bug SDK
Problem

In SdkSpanBuilder.startSpan(), when creating a root span (!parentSpanContext.isValid()) with a random IdGenerator (idGenerator.generatesRandomTraceIds() == true), parentContextForSampler replaces the Span in parentContext with RANDOM_TRACE_ID_PRIMORDIAL_SPAN, whose TraceState is TraceState.getDefault().

If a caller attaches an invalid SpanContext carrying initial TraceState (for example, ot=rv:... per Do not overwrite explicit randomness) to parentContext:

  • Sampler.shouldSample() cannot observe parentSpanContext.getTraceState() through parentContextForSampler (even though SdkSpanBuilder.java:258 passes parentSpanContext.getTraceState() to samplingResult.getUpdatedTraceState(...)).
  • CompositeSampler.shouldSample() reads traceState from parentContext (now empty) and reuses it in getUpdatedTraceState() (line 95), losing the caller's initial TraceState.

When idGenerator.generatesRandomTraceIds() is false, parentContextForSampler is left unchanged and the caller's TraceState is preserved.

Note: Upstream spec clarification on ShouldSample root TraceFlags and root-span TraceState is also tracked in open-telemetry/opentelemetry-specification#5471 and open-telemetry/opentelemetry-specification#5472.

主要言語
Java
スター
2.5k
フォーク
1.1k
平均マージ
5日 11時間
マージ済み PR(30日)
41

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

open-telemetry/opentelemetry-java のほかの issue

open-telemetry/opentelemetry-java の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。