MultiSpanProcessor caches method values of delegates
Maintainer thường phản hồi trong vòng 3 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- java
- Lĩnh vực
- observability
Hướng nghiên cứu
Bắt đầu với MultiSpanProcessor và interface SpanProcessor, sau đó tái hiện hành vi bằng bài kiểm thử respectNeeds được nêu trong issue. Kiểm tra cách isStartRequired() và isEndRequired() được sử dụng trong quá trình khởi tạo và dispatch. Công việc được xem là hoàn tất khi hành vi đã được tài liệu hóa hoặc thống nhất được thể hiện bằng một regression test chạy thành công, đồng thời mọi ảnh hưởng về khả năng tương thích cho một major version trong tương lai đã được giải quyết.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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);
}
- 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
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của open-telemetry/opentelemetry-java
-
`B3PropagatorExtractorMultipleHeaders` allocates when headers are missingCó thể đã có người làm @Eliot5566 đã nhận hôm nay. Đang mởBug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
open-telemetry/opentelemetry-java#9065 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
[incubator] ComposableProbabilitySampler does not validate ratio rangeCó thể đã có người làm @eminfikret đã nhận 4 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
open-telemetry/opentelemetry-java#9046 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 3 ngày
-
PrometheusComponentProvider promotes all resource attributes when resource_constant_labels is empty ({})Có thể đã có người làm @rooks-ns đã nhận 19 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
open-telemetry/opentelemetry-java#9014 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Fix `otel.sdk.log.created` counting semanticsCó thể đã có người làm @anuraaga đã nhận 112 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
open-telemetry/opentelemetry-java#8688 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
SdkSpanBuilder drops invalid parent TraceState when IdGenerator.generatesRandomTraceIds() is trueCó thể đã có người làm @Eliot5566 đã nhận hôm nay. Đang mởBug SDK
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
open-telemetry/opentelemetry-java#9062 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
Tất cả issue của open-telemetry/opentelemetry-java
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
micronaut-projects/micronaut-core#14585 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Mend: dependency security vulnerability untriaged
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
opensearch-project/cross-cluster-replication#1805 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
feature request needs triage
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 66/100
TeamNewPipe/NewPipe#14083 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
NeoForge 安装任务的子任务描述有误Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
PCL-Community/PCL-CE#3907 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
Maintainer thường phản hồi trong vòng 2 ngày