Skip to content

Commit

Permalink
Merge pull request #24608 from geoand/#23829
Browse files Browse the repository at this point in the history
Don't record start time when Reactive REST Client returns a Multi
  • Loading branch information
geoand authored Mar 30, 2022
2 parents b82d849 + 57cfcd7 commit 0de2c19
Showing 1 changed file with 7 additions and 2 deletions.
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

0 comments on commit 0de2c19

Please sign in to comment.