Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Don't record start time when Reactive REST Client returns a Multi #24608

Merged
merged 1 commit into from
Mar 30, 2022
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 @@ -2,6 +2,7 @@

import io.netty.handler.codec.http.LastHttpContent;
import io.netty.handler.codec.http.multipart.InterfaceHttpData;
import io.smallrye.mutiny.Multi;
import io.smallrye.mutiny.Uni;
import io.smallrye.stork.Stork;
import io.smallrye.stork.api.ServiceInstance;
Expand Down Expand Up @@ -408,15 +409,15 @@ public Uni<HttpClientRequest> createRequest(RestClientRequestContext state) {
try {
serviceInstance = Stork.getInstance()
.getService(serviceName)
.selectInstanceAndRecordStart(true);
.selectInstanceAndRecordStart(shouldMeasureTime(state));
} catch (Throwable e) {
log.error("Error selecting service instance for serviceName: " + serviceName, e);
return Uni.createFrom().failure(e);
}
requestOptions = serviceInstance.onItem().transform(new Function<>() {
@Override
public RequestOptions apply(ServiceInstance serviceInstance) {
if (serviceInstance.gatherStatistics()) {
if (serviceInstance.gatherStatistics() && shouldMeasureTime(state)) {
state.setCallStatsCollector(serviceInstance);
}
return new RequestOptions()
Expand Down Expand Up @@ -457,6 +458,10 @@ public Uni<? extends HttpClientRequest> apply(RequestOptions options) {
});
}

private boolean shouldMeasureTime(RestClientRequestContext state) {
return !Multi.class.equals(state.getResponseType().getRawType());
}

private int getPort(boolean isHttps, int specifiedPort) {
return specifiedPort != -1 ? specifiedPort : defaultPort(isHttps);
}
Expand Down