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

Đang mở
#9,062 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 3 ngày

@Eliot5566 đang làm issue này rồi.

Từ ngày 26/11/2026.

  • #2 của @Eliot5566 — đang mở

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java
Lĩnh vực
backend, observability

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Java
Star
2.5k
Fork
1.1k
Merge trung bình
5 ngày 11 giờ
Pull request đã merge (30 ngày)
41

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của open-telemetry/opentelemetry-java

Tất cả issue của open-telemetry/opentelemetry-java

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.