Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Remove streams from B3Propagator #5326

Merged
merged 1 commit into from
Mar 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import io.opentelemetry.context.propagation.TextMapSetter;
import java.util.Collection;
import java.util.Optional;
import java.util.function.Supplier;
import java.util.stream.Stream;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;

Expand Down Expand Up @@ -113,15 +111,11 @@ public <C> void inject(Context context, @Nullable C carrier, TextMapSetter<C> se

@Override
public <C> Context extract(Context context, @Nullable C carrier, TextMapGetter<C> getter) {
return Stream.<Supplier<Optional<Context>>>of(
() -> singleHeaderExtractor.extract(context, carrier, getter),
() -> multipleHeadersExtractor.extract(context, carrier, getter),
() -> Optional.of(context))
.map(Supplier::get)
.filter(Optional::isPresent)
.map(Optional::get)
.findFirst()
.get();
Optional<Context> ctx = singleHeaderExtractor.extract(context, carrier, getter);
if (ctx.isPresent()) {
return ctx.get();
}
return multipleHeadersExtractor.extract(context, carrier, getter).orElse(context);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An example when streams result in worse readability and worse performance!

}

@Override
Expand Down