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

Abierto
#9,062 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 3 días

@Eliot5566 ya está trabajando en esto.

Desde el 26/11/2026.

  • #2 de @Eliot5566 — abierto

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
48/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
java

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Java
Estrellas
2.5k
Forks
1.1k
Merge medio
5 d 11 h
PR fusionados (30 d)
41

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de open-telemetry/opentelemetry-java

Todos los issues de open-telemetry/opentelemetry-java

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.