MultiSpanProcessor caches method values of delegates
Los mantenedores suelen responder en 3 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- java
- Área
- observability
Línea de trabajo
Comienza con MultiSpanProcessor y la interfaz SpanProcessor; después, reproduce el comportamiento con la prueba respectNeeds mostrada en el issue. Comprueba cómo se usan isStartRequired() e isEndRequired() durante la construcción y el dispatch. Se considera terminado cuando el comportamiento documentado o acordado queda recogido en una prueba de regresión que pasa, y se han resuelto todas las implicaciones de compatibilidad para una futura versión major.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
The MultiSpanProcessor is designed to wrap a bunch of other SpanProcessors that it delegates to. SpanProcessor is an interface, and it has two methods isStartRequired() and isEndRequired(). These methods presumably tell the user of the SpanProcessor instance whether or not the corresponding onStart() or onEnd() method should be invoked.
As of this writing, there is only one caller of the isStartRequired() and isEndRequired() methods, and that is the MultiSpanProcessor. One could make the argument that simply allowing implementers to build a no-op onStart() or onEnd() would have been sufficient, but the original authors chose to guard this with another method call instead. Baffling.
In any case, the MultiSpanProcessor seems to have been crafted with premature optimization in mind. In the constructor, the delegates are grouped into two possibly overlapping sets -- those that require start and those that require end. This set creation is done in the constructor by invoking isStartRequired() and isEndRequired() at construction time, and never again. The creation of these sets effectively caches the method call return value for the life of the MultiSpanProcessor.
This might have been the original design, but it feels like a bug. There is nothing in the javadoc discouraging implementers from returning different values from is{Start/End}Required(), and forcing users to implement a method whose return value is subsequently ignored seems like bad design.
Because the SpanProcessor (and all of its friends) are "stable", this will be difficult to change. I suggest that we keep this in scope when looking at a future major version bump. There are definitely some interesting design discussions to be had around this.
Here is an example unit test that uses a SpanProcessor that only wants its onStart() and onEnd() to be called once. The MutiSpanProcessor is called 100 times, and sure enough, the delegate is also called 100 times. This could be a harsh surprise to the implementer!
This test fails today:
@Test
void respectNeeds() {
AtomicInteger startCt = new AtomicInteger();
AtomicInteger endCt = new AtomicInteger();
SpanProcessor oncePlease = new SpanProcessor() {
@Override
public void onStart(Context parentContext, ReadWriteSpan span) {
startCt.incrementAndGet();
}
@Override
public boolean isStartRequired() {
return startCt.get() == 0;
}
@Override
public void onEnd(ReadableSpan span) {
endCt.incrementAndGet();
}
@Override
public boolean isEndRequired() {
return endCt.get() == 0;
}
};
SpanProcessor multi = MultiSpanProcessor.create(singletonList(oncePlease));
for(int i=0; i < 100; i++){
multi.onStart(null, null);
multi.onEnd(null);
}
assertThat(startCt.get()).isEqualTo(1);
assertThat(endCt.get()).isEqualTo(1);
}
- Lenguaje dominante
- Java
- Estrellas
- 2.5k
- Forks
- 1.1k
- Merge medio
- 5 d 11 h
- PR fusionados (30 d)
- 41
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de open-telemetry/opentelemetry-java
-
`B3PropagatorExtractorMultipleHeaders` allocates when headers are missingPosiblemente ocupada @Eliot5566 la tomó hoy. AbiertoBug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
open-telemetry/opentelemetry-java#9065 ·
Los mantenedores suelen responder en 3 días
-
[incubator] ComposableProbabilitySampler does not validate ratio rangePosiblemente ocupada @eminfikret la tomó hace 4 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
open-telemetry/opentelemetry-java#9046 · 2 comentarios · 1 asignado ·
Los mantenedores suelen responder en 3 días
-
PrometheusComponentProvider promotes all resource attributes when resource_constant_labels is empty ({})Posiblemente ocupada @rooks-ns la tomó hace 19 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
open-telemetry/opentelemetry-java#9014 · 1 comentario ·
Los mantenedores suelen responder en 3 días
-
Fix `otel.sdk.log.created` counting semanticsPosiblemente ocupada @anuraaga la tomó hace 112 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
open-telemetry/opentelemetry-java#8688 ·
Los mantenedores suelen responder en 3 días
-
SdkSpanBuilder drops invalid parent TraceState when IdGenerator.generatesRandomTraceIds() is truePosiblemente ocupada @Eliot5566 la tomó hoy. AbiertoBug SDK
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
open-telemetry/opentelemetry-java#9062 · 1 comentario ·
Los mantenedores suelen responder en 3 días
Todos los issues de open-telemetry/opentelemetry-java
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 79/100
micronaut-projects/micronaut-core#14585 ·
Los mantenedores suelen responder en 1 día
-
Mend: dependency security vulnerability untriaged
Dificultad 1/5 Menos de una hora Aptitud para principiantes 78/100
opensearch-project/cross-cluster-replication#1805 ·
Los mantenedores suelen responder en 1 día
-
feature request needs triage
Dificultad 1/5 Menos de una hora Aptitud para principiantes 66/100
TeamNewPipe/NewPipe#14083 ·
Los mantenedores suelen responder en 1 día
-
NeoForge 安装任务的子任务描述有误Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 68/100
PCL-Community/PCL-CE#3907 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 73/100
Los mantenedores suelen responder en 2 días