MultiSpanProcessor caches method values of delegates
メンテナーはふだん 3 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- java
調査の方向性
MultiSpanProcessor と SpanProcessor インターフェースから始め、次に issue に示されている respectNeeds テストで動作を再現します。構築時とディスパッチ時に isStartRequired() と isEndRequired() がどのように使用されるかを確認します。文書化された、または合意された動作が、成功する回帰テストによって取り込まれ、将来のメジャーバージョンに向けた互換性上の影響が解決されていれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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);
}
- 主要言語
- Java
- スター
- 2.5k
- フォーク
- 1.1k
- 平均マージ
- 5日 11時間
- マージ済み PR(30日)
- 41
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
open-telemetry/opentelemetry-java のほかの issue
-
`B3PropagatorExtractorMultipleHeaders` allocates when headers are missing対応中かも @Eliot5566 が今日担当しました。 オープンBug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
open-telemetry/opentelemetry-java#9065 ·
メンテナーはふだん 3 日以内に返信
-
[incubator] ComposableProbabilitySampler does not validate ratio range対応中かも @eminfikret が 4 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
open-telemetry/opentelemetry-java#9046 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 3 日以内に返信
-
PrometheusComponentProvider promotes all resource attributes when resource_constant_labels is empty ({})対応中かも @rooks-ns が 19 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
open-telemetry/opentelemetry-java#9014 · コメント 1 件 ·
メンテナーはふだん 3 日以内に返信
-
Fix `otel.sdk.log.created` counting semantics対応中かも @anuraaga が 112 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
open-telemetry/opentelemetry-java#8688 ·
メンテナーはふだん 3 日以内に返信
-
SdkSpanBuilder drops invalid parent TraceState when IdGenerator.generatesRandomTraceIds() is true対応中かも @Eliot5566 が今日担当しました。 オープンBug SDK
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
open-telemetry/opentelemetry-java#9062 · コメント 1 件 ·
メンテナーはふだん 3 日以内に返信
open-telemetry/opentelemetry-java の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
micronaut-projects/micronaut-core#14585 ·
メンテナーはふだん 1 日以内に返信
-
Mend: dependency security vulnerability untriaged
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
opensearch-project/cross-cluster-replication#1805 ·
メンテナーはふだん 1 日以内に返信
-
feature request needs triage
難易度 1/5 1時間未満 初心者へのやさしさ 66/100
TeamNewPipe/NewPipe#14083 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
PCL-Community/PCL-CE#3907 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
メンテナーはふだん 2 日以内に返信