apoorvmittal10 commented on code in PR #17021: URL: https://github.com/apache/kafka/pull/17021#discussion_r1828300874
########## clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java: ########## @@ -4915,47 +4934,16 @@ public Uuid clientInstanceId(Duration timeout) { throw new IllegalArgumentException("The timeout cannot be negative."); } - if (!clientTelemetryEnabled) { + if (clientTelemetryReporter.isEmpty()) { throw new IllegalStateException("Telemetry is not enabled. Set config `" + AdminClientConfig.ENABLE_METRICS_PUSH_CONFIG + "` to `true`."); + } if (clientInstanceId != null) { return clientInstanceId; } - final long now = time.milliseconds(); - final KafkaFutureImpl<Uuid> future = new KafkaFutureImpl<>(); - runnable.call(new Call("getTelemetrySubscriptions", calcDeadlineMs(now, (int) timeout.toMillis()), - new LeastLoadedNodeProvider()) { - - @Override - GetTelemetrySubscriptionsRequest.Builder createRequest(int timeoutMs) { - return new GetTelemetrySubscriptionsRequest.Builder(new GetTelemetrySubscriptionsRequestData(), true); - } - - @Override - void handleResponse(AbstractResponse abstractResponse) { - GetTelemetrySubscriptionsResponse response = (GetTelemetrySubscriptionsResponse) abstractResponse; - if (response.error() != Errors.NONE) { - future.completeExceptionally(response.error().exception()); - } else { - future.complete(response.data().clientInstanceId()); - } - } - - @Override - void handleFailure(Throwable throwable) { - future.completeExceptionally(throwable); - } - }, now); - - try { - clientInstanceId = future.get(); - } catch (Exception e) { - log.error("Error occurred while fetching client instance id", e); - throw new KafkaException("Error occurred while fetching client instance id", e); - } - + clientInstanceId = ClientTelemetryUtils.fetchClientInstanceId(clientTelemetryReporter.get(), timeout); Review Comment: Hmmm, so the previous implementation in admin client sent a new getTelemetryRequest which will anyways get the new client instance as it's a new API call. I think the changes you have done are correct. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org