When doing http request in traces i see delay about 200-300ms, where it is coming from?

50 Views Asked by At

I am having a web service that is receiving an HTTP request on callback and then does request to token endpoint of identity provider.

I am using following code to do a call to get tokens

  @WithSpan("getTokens")
    protected Uni<OidcTokenResponseDTO> getTokens(OidcCallbackDTO oidcCallbackDTO,
                                                  OidcRestClient oidcRestClient,
                                                  HydraClientOIDCProviderDTO oidcProviderProperties) {
        Log.infof("Obtaining IDP tokens for challenge: %s, code: %s", oidcCallbackDTO.getHydraLoginChallenge(), oidcCallbackDTO.getCode());
        return getTokenRequestParams(oidcCallbackDTO, oidcProviderProperties)
                .onItem()
                .transformToUni(params ->
                        oidcRestClient.getTokens(oidcProviderProperties.getTokenPath(),
                                        getBasicAuth(oidcProviderProperties),
                                        params.getGrantType(),
                                        params.getChallenge(),
                                        params.getCode(),
                                        params.getRedirectUri(),
                                        params.getCodeVerifier())
                                .ifNoItem().after(Duration.ofSeconds(oidcProviderProperties.getTokensRequestTimeout()))
                                .failWith(() -> new OIDCTokenRequestTimeoutException(oidcProviderProperties.getTokensRequestTimeout())));
    }

The issue is that when i investigate traces every time i see some strange "wait" of about 200-300ms between the operations.

Please see screenshot below

enter image description here

As you see in code i do getTokensParams, you can also see it in trace and right after i get these params i do a call to getTokens request. But beetwin this 2 operations there about 300ms delay or wait or whatever it's called.

Below is the code of the restClient

public interface OidcRestClient {
    @POST
    @Path("{tokenPath}")
    @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
    Uni<OidcTokenResponseDTO> getTokens(@PathParam("tokenPath") @Encoded String tokenPath,
                                        @HeaderParam(AUTHORIZATION) String basic,
                                        @FormParam("grant_type") String grantType,
                                        @FormParam("challenge") String challenge,
                                        @FormParam("code") String code,
                                        @FormParam("redirect_uri") String redirectUri,
                                        @FormParam("code_verifier") String codeVerifier);
}

Client itself is constructed like this

@WithSpan("getOidcRestClient")
public OidcRestClient getOidcRestClient(String baseURL) {
    return clientMap.computeIfAbsent(baseURL, key -> RestClientBuilder.newBuilder()
            .baseUri(URI.create(baseURL))
            .property(QuarkusRestClientProperties.CONNECTION_POOL_SIZE, Integer.valueOf(poolSize))
            .property(QuarkusRestClientProperties.SHARED, true)
            .build(OidcRestClient.class));
}

Could someone please explain why this 300ms wait occurs and how to get rid of it?

0

There are 0 best solutions below