{"id":"bf39f7f13c8e0fc3","repo":"apache/kafka","slug":"telemetry-is-not-enabled-set-config-enable-metri","errorCode":null,"errorMessage":"Telemetry is not enabled. Set config `enable.metrics.push` to `true`.","messagePattern":"Telemetry is not enabled\\. Set config `enable\\.metrics\\.push` to `true`\\.","errorType":"exception","errorClass":"java.lang.IllegalStateException","httpStatus":null,"severity":"error","filePath":"clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java","lineNumber":1855,"sourceCode":"            lastPendingAsyncCommit.whenComplete((v, t) -> futureToAwait.complete(null));\n            if (enableWakeup) {\n                wakeupTrigger.setActiveTask(futureToAwait);\n            }\n            ConsumerUtils.getResult(futureToAwait, timer);\n            lastPendingAsyncCommit = null;\n        } finally {\n            if (enableWakeup) {\n                wakeupTrigger.clearTask();\n            }\n            timer.update();\n        }\n        offsetCommitCallbackInvoker.executeCallbacks();\n    }\n\n    @Override\n    public Uuid clientInstanceId(Duration timeout) {\n        if (clientTelemetryReporter.isEmpty()) {\n            throw new IllegalStateException(\"Telemetry is not enabled. Set config `\" + ConsumerConfig.ENABLE_METRICS_PUSH_CONFIG + \"` to `true`.\");\n        }\n\n        return ClientTelemetryUtils.fetchClientInstanceId(clientTelemetryReporter.get(), timeout);\n    }\n\n    @Override\n    public Set<TopicPartition> assignment() {\n        acquireAndEnsureOpen();\n        try {\n            return Collections.unmodifiableSet(subscriptions.assignedPartitions());\n        } finally {\n            release();\n        }\n    }\n\n    /**\n     * Get the current subscription, or an empty set if no such call has\n     * been made.","sourceCodeStart":1837,"sourceCodeEnd":1873,"githubUrl":"https://github.com/apache/kafka/blob/c31c9215e131f8c17e79f8901b48c13ee6aa8e7a/clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java#L1837-L1873","documentation":"IllegalStateException from clientInstanceId(Duration) when the consumer was built without a ClientTelemetryReporter, i.e. enable.metrics.push=false (the default in many setups). clientInstanceId is meant to expose the broker-assigned client instance id used for the metrics-push pipeline; without telemetry enabled there is no reporter and therefore no instance id. The message explicitly points at ConsumerConfig.ENABLE_METRICS_PUSH_CONFIG as the fix.","triggerScenarios":"Calling consumer.clientInstanceId(timeout) on a consumer whose properties did not include enable.metrics.push=true. The optional clientTelemetryReporter field is empty, so the guard throws immediately before any network interaction.","commonSituations":"Integration with observability/telemetry collectors (e.g. client metrics to a broker-backed dashboard) where the application expects a clientInstanceId but the consumer config was copied from a non-telemetry template; upgrading the broker and wanting clientInstanceId correlation without flipping the metrics push flag; multi-tenant clients where some instances opt in and some do not.","solutions":["Set ConsumerConfig.ENABLE_METRICS_PUSH_CONFIG=true in the consumer properties before construction; the reporter is wired only at construction time.","Reconstruct the consumer after changing the config (toggling the flag post-construction has no effect).","Verify the broker actually supports the telemetry subscription API if you depend on the instance id downstream."],"exampleFix":"// before\nprops.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, brokers);\nconsumer = new AsyncKafkaConsumer<>(props, k, v);\nuuid = consumer.clientInstanceId(Duration.ofSeconds(5)); // throws\n\n// after\nprops.put(ConsumerConfig.ENABLE_METRICS_PUSH_CONFIG, \"true\");\nconsumer = new AsyncKafkaConsumer<>(props, k, v);\nuuid = consumer.clientInstanceId(Duration.ofSeconds(5));","handlingStrategy":"validation","validationCode":"boolean telemetryEnabled = Boolean.parseBoolean(\n    props.getProperty(ConsumerConfig.ENABLE_METRICS_PUSH_CONFIG, \"false\"));\nif (!telemetryEnabled) {\n    throw new IllegalStateException(\n        \"Cannot call clientInstanceId() without \" + ConsumerConfig.ENABLE_METRICS_PUSH_CONFIG + \"=true\");\n}\nnew KafkaConsumer<K, V>(props);","typeGuard":null,"tryCatchPattern":"try {\n    Uuid id = consumer.clientInstanceId(timeout);\n} catch (IllegalStateException e) {\n    // Telemetry not enabled at construction; nothing to retry — fix config and rebuild consumer.\n    log.warn(\"clientInstanceId unavailable: enable.metrics.push is disabled\", e);\n}","preventionTips":["clientInstanceId() requires ConsumerConfig.ENABLE_METRICS_PUSH_CONFIG=true at consumer construction — toggling it later has no effect.","Gate any telemetry/observability feature on a config check before calling clientInstanceId.","Treat IllegalStateException here as a permanent misconfiguration, not a transient condition."],"tags":["kafka","consumer","telemetry","metrics","configuration"],"analyzedSha":"c31c9215e131f8c17e79f8901b48c13ee6aa8e7a","analyzedAt":"2026-08-03T12:34:05.770Z","schemaVersion":2}