Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: more context in errors reported to logger, specifically 'Unknown topic or partition' #239

Open
apeloquin-agilysys opened this issue Jan 14, 2025 · 1 comment

Comments

@apeloquin-agilysys
Copy link

apeloquin-agilysys commented Jan 14, 2025

Environment Information

  • OS: Mac M3 Sonoma 14.6.1
  • Node Version: 20.14.0
  • NPM Version: 10.7.0
  • confluent-kafka-javascript version: 1.0.0

Steps to Reproduce

In general the errors sent to the logger often lack some critical context that would make the source easy to identify.

In our case we have an application that is spinning up consumers for dozens of topics from different components. The following is an example error for a recent issue as received in the logger:

{
  "message": "Consumer encountered error while consuming. Retrying. Error details: KafkaJSProtocolError: Broker: Unknown topic or partition : Error: Broker: Unknown topic or partition\n    at Function.createLibrdkafkaError [as create] (/Users/peloquina/src/agilysys-inc/stay/backplane-base/node_modules/@confluentinc/kafka-javascript/lib/error.js:459:10)\n    at /Users/peloquina/src/agilysys-inc/stay/backplane-base/node_modules/@confluentinc/kafka-javascript/lib/kafka-consumer.js:557:29\n    at callbackTrampoline (node:internal/async_hooks:130:17)",
  "extras": {
    "name": "Confluent#consumer-6",
    "fac": "BINDING",
    "timestamp": 1736870741813
  }
}

If the extras included the topic name in this case, it would have saved hours spent narrowing down which consumer was actually at fault.

The name value seems like it should be a useful cross-reference, but as it a # private field on the consumer it can only be associated with other log entries and is completely inaccessible from within our application.

Image

@milindl
Copy link
Contributor

milindl commented Jan 24, 2025

Regarding correlation between the consumer and the logs, the name within the consumer is a concatenation of the config's clientId and consumer-$N or producer-N. By setting the clientId, it's possible to recognize which consumer is logging the statement.

        kafkaJS: {
            // ...
            clientId: 'myConsumer'
        },

Will have logs like

...
  timestamp: 1737687965299,
  name: 'myConsumer#producer-1'
}

Regarding the other question, I'll check if it's possible to add the topic/partition info within the message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants