{"id":"17e80fffead738f0","repo":"apache/kafka","slug":"telemetry-is-not-enabled-set-config-consumerco","errorCode":null,"errorMessage":"Telemetry is not enabled. Set config `${ConsumerConfig.ENABLE_METRICS_PUSH_CONFIG}` to `true`.","messagePattern":"Telemetry is not enabled\\. Set config `(.+?)` to `true`\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumerImpl.java","lineNumber":936,"sourceCode":"                if (acknowledgementCommitCallbackHandler != null) {\n                    ShareAcknowledgementCommitCallbackRegistrationEvent event = new ShareAcknowledgementCommitCallbackRegistrationEvent(false);\n                    applicationEventHandler.add(event);\n                }\n                completedAcknowledgements.clear();\n                acknowledgementCommitCallbackHandler = null;\n            }\n        } finally {\n            release();\n        }\n    }\n\n    /**\n     * {@inheritDoc}\n     */\n    @Override\n    public Uuid clientInstanceId(final 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    /**\n     * {@inheritDoc}\n     */\n    @Override\n    public Optional<Integer> acquisitionLockTimeoutMs() {\n        acquireAndEnsureOpen();\n        try {\n            return currentFetch.acquisitionLockTimeoutMs();\n        } finally {\n            release();\n        }\n    }\n","sourceCodeStart":918,"sourceCodeEnd":954,"githubUrl":"https://github.com/apache/kafka/blob/c31c9215e131f8c17e79f8901b48c13ee6aa8e7a/clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumerImpl.java#L918-L954","documentation":"Thrown by ShareConsumerImpl.clientInstanceId(Duration) (line 936) when clientTelemetryReporter is empty — i.e. the consumer was built without enable.metrics.push=true. clientInstanceId returns the broker-assigned client instance UUID, which only exists when the client telemetry reporter is registered and pushing metrics. The guard prevents asking for an ID that can never be obtained.","triggerScenarios":"Calling consumer.clientInstanceId(timeout) on a KafkaShareConsumer whose config did not set enable.metrics.push=true. Also reached if the property was set but overridden/removed by a parent config layer, or misspelled.","commonSituations":"Telemetry/KIP-714 integrations that want the client instance id for correlation but forgot the prerequisite config; copying a working consumer config into a new module and dropping the metrics-push flag; environments where a security/compliance layer strips unknown properties; upgrading the client and assuming telemetry is on by default (it defaults to false).","solutions":["Set enable.metrics.push=true in the consumer properties passed to KafkaShareConsumer.","Verify the property survives any config-merge layer (Spring Boot, Quarkus, custom ConfigProvider) by logging ConsumerConfig values at startup.","If telemetry is genuinely not wanted, stop calling clientInstanceId() — remove that code path rather than enabling the reporter just to obtain an ID.","Ensure the broker version supports the telemetry endpoint (KRaft broker with client metrics support); an empty reporter can also result from a broker that advertised no telemetry during metadata exchange."],"exampleFix":"// before\nprops.put(ConsumerConfig.GROUP_ID_CONFIG, \"g1\");\nUuid id = consumer.clientInstanceId(Duration.ofSeconds(5));\n\n// after\nprops.put(ConsumerConfig.GROUP_ID_CONFIG, \"g1\");\nprops.put(ConsumerConfig.ENABLE_METRICS_PUSH_CONFIG, \"true\");\nUuid id = consumer.clientInstanceId(Duration.ofSeconds(5));","handlingStrategy":"validation","validationCode":"// Before invoking clientInstanceId(timeout), verify telemetry was enabled at construction time.\nObject raw = consumerConfig.get(org.apache.kafka.clients.consumer.ConsumerConfig.ENABLE_METRICS_PUSH_CONFIG);\nboolean telemetryEnabled = Boolean.parseBoolean(String.valueOf(raw));\nif (!telemetryEnabled) {\n    throw new IllegalStateException(\n        \"Cannot fetch client instance id: \" + org.apache.kafka.clients.consumer.ConsumerConfig.ENABLE_METRICS_PUSH_CONFIG + \" must be true\");\n}","typeGuard":"null","tryCatchPattern":"try {\n    org.apache.kafka.common.Uuid id = consumer.clientInstanceId(java.time.Duration.ofSeconds(5));\n} catch (IllegalStateException e) {\n    // Telemetry disabled: either enable enable.metrics.push and recreate consumer, or skip the call.\n    log.warn(\"clientInstanceId unavailable; enable {} in the consumer config\",\n             org.apache.kafka.clients.consumer.ConsumerConfig.ENABLE_METRICS_PUSH_CONFIG, e);\n}","preventionTips":["Set enable.metrics.push=true in the consumer config when you intend to call clientInstanceId.","Treat clientInstanceId() as optional and guard callers so a missing telemetry reporter does not crash the app.","Avoid calling clientInstanceId() on every request; cache the result once the consumer is initialized."],"tags":["share-consumer","telemetry","config","kafka-client"],"analyzedSha":"c31c9215e131f8c17e79f8901b48c13ee6aa8e7a","analyzedAt":"2026-08-03T12:34:05.770Z","schemaVersion":2}