Source:
private Mono<DocumentCollection> readCollectionAsync(MetadataDiagnosticsContext metaDataDiagnosticsContext, String collectionLink, DocumentClientRetryPolicy retryPolicyInstance, Map<String, Object> properties) { String path = Utils.joinPath(collectionLink, null); RxDocumentServiceRequest request = RxDocumentServiceRequest.create( OperationType.Read, ResourceType.DocumentCollection, path, new HashMap<>()); request.getHeaders().put(HttpConstants.HttpHeaders.X_DATE, Utils.nowAsRFC1123()); if (tokenProvider.getAuthorizationTokenType() != AuthorizationTokenType.AadToken) { String resourceName = request.getResourceAddress(); String authorizationToken = tokenProvider.getUserAuthorizationToken( resourceName, request.getResourceType(), RequestVerb.GET, request.getHeaders(), AuthorizationTokenType.PrimaryMasterKey, properties); try { authorizationToken = URLEncoder.encode(authorizationToken, "UTF-8"); } catch (UnsupportedEncodingException e) { return Mono.error(new IllegalStateException("Failed to encode authtoken.", e)); } request.getHeaders().put(HttpConstants.HttpHeaders.AUTHORIZATION, authorizationToken); } if (retryPolicyInstance != null){ retryPolicyInstance.onBeforeSendRequest(request); } Instant addressCallStartTime = Instant.now(); Mono<RxDocumentServiceResponse> responseObs; if (tokenProvider.getAuthorizationTokenType() != AuthorizationTokenType.AadToken) { responseObs = this.storeModel.processMessage(request); } else { responseObs = tokenProvider .populateAuthorizationHeader(request) .flatMap(serviceRequest -> this.storeModel.processMessage(serviceRequest)); } return responseObs.map(response -> { if(metaDataDiagnosticsContext != null) { Instant addressCallEndTime = Instant.now(); MetadataDiagnosticsContext.MetadataDiagnostics metaDataDiagnostic = new MetadataDiagnosticsContext.MetadataDiagnostics(addressCallStartTime, addressCallEndTime, MetadataDiagnosticsContext.MetadataType.CONTAINER_LOOK_UP); metaDataDiagnosticsContext.addMetaDataDiagnostic(metaDataDiagnostic); } return BridgeInternal.toResourceResponse(response, DocumentCollection.class) .getResource(); }).single(); }

Target:
private Mono<DocumentCollection> readCollectionAsync(MetadataDiagnosticsContext metaDataDiagnosticsContext, String collectionLink, DocumentClientRetryPolicy retryPolicyInstance, Map<String, Object> properties) { String path = Utils.joinPath(collectionLink, null); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(this.diagnosticsClientContext, OperationType.Read, ResourceType.DocumentCollection, path, new HashMap<>()); request.getHeaders().put(HttpConstants.HttpHeaders.X_DATE, Utils.nowAsRFC1123()); if (tokenProvider.getAuthorizationTokenType() != AuthorizationTokenType.AadToken) { String resourceName = request.getResourceAddress(); String authorizationToken = tokenProvider.getUserAuthorizationToken( resourceName, request.getResourceType(), RequestVerb.GET, request.getHeaders(), AuthorizationTokenType.PrimaryMasterKey, properties); try { authorizationToken = URLEncoder.encode(authorizationToken, "UTF-8"); } catch (UnsupportedEncodingException e) { return Mono.error(new IllegalStateException("Failed to encode authtoken.", e)); } request.getHeaders().put(HttpConstants.HttpHeaders.AUTHORIZATION, authorizationToken); } if (retryPolicyInstance != null){ retryPolicyInstance.onBeforeSendRequest(request); } Instant addressCallStartTime = Instant.now(); Mono<RxDocumentServiceResponse> responseObs; if (tokenProvider.getAuthorizationTokenType() != AuthorizationTokenType.AadToken) { responseObs = this.storeModel.processMessage(request); } else { responseObs = tokenProvider .populateAuthorizationHeader(request) .flatMap(serviceRequest -> this.storeModel.processMessage(serviceRequest)); } return responseObs.map(response -> { if(metaDataDiagnosticsContext != null) { Instant addressCallEndTime = Instant.now(); MetadataDiagnosticsContext.MetadataDiagnostics metaDataDiagnostic = new MetadataDiagnosticsContext.MetadataDiagnostics(addressCallStartTime, addressCallEndTime, MetadataDiagnosticsContext.MetadataType.CONTAINER_LOOK_UP); metaDataDiagnosticsContext.addMetaDataDiagnostic(metaDataDiagnostic); } return BridgeInternal.toResourceResponse(response, DocumentCollection.class) .getResource(); }).single(); }