bbejeck commented on code in PR #17021:
URL: https://github.com/apache/kafka/pull/17021#discussion_r1813686411
##########
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:
@apoorvmittal10 The
`KafkaStreamsTelemetryIntegrationTest.shouldPushMetricsToBroker` exposed an
issue where the client instance id returned to Kafka Streams didn't match the
one included in the pushed metrics. To fix this, I updated the
`clientInstanceId` method to use the same approach in the
`ClassicKafkaConsumer` and the integration test is working as expected now.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]