Diagnostic

February 25, 2026 ยท View on GitHub

Support for diagnostic and instrumentation is provided via Node.js Diagnostic Channel API.

Execution model for tracing channels

The presence of the result and error properties and the order of tracing channels events follows the current pseudo-code flow:

function operation (options, callback) {
  const channel = tracingChannel('plt:kafka:example')
  const context = { operationId: 0n, options }

  try {
    channel.start.publish(context)

    doSomethingAsync((error, result) => {
      if (error) {
        context.error = error
        channel.error.publish(context)
        channel.asyncStart.publish(context)
        callback(error)
        channel.asyncEnd.publish(context)

        return
      }

      context.result = result
      channel.asyncStart.publish(context)
      callback(error)
      channel.asyncEnd.publish(context)
    })

    channel.end.publish(context)
  } catch (error) {
    context.error = error
    channel.error.publish(context)
    channel.end.publish(context)
  }
}

Common properties

Each tracing channel publishes events with the following common properties:

NameTypeDescription
connectionConnectionThe current connection. This is only used by the plt:kafka:connections:connects and plt:kafka:connections:api channels
connectionPoolConnectionPoolThe current connection pool. This is only used by the plt:kafka:connections:pools:gets channel.
clientDepends on the operationThe current client. It can be a Base, Admin, Producer or Consumer if appropriate.
operationIdbigintThe current operation ID. This is unique across all channels.
resultDepends on the operationThe result of the operation. This is only present in the asyncStart and asyncEnd events.
errorErrorThe error thrown by the operation. This is only present in the error event.

Published channels

NameDescription
plt:kafka:instancesNotifies any creation of a Connection, ConnectionPool, Base, Admin, Producer, Consumer, MessagesStream or ProducerStream. This channel will publish objects with the type and instance property.
plt:kafka:consumer:lagNotifies any Consumer lag obtained via Consumer.getLag (including the one triggered via Consumer.startLagMonitoring).

Published tracing channels

NameTargetDescription
plt:kafka:connections:connectsConnectionTraces a connection attempt to a broker.
plt:kafka:connections:apiConnectionTraces a low level API request.
plt:kafka:connections:pools:getsConnectionPoolTraces a connection retrieval attempt from a connection pool.
plt:kafka:base:apisBaseTraces a Base.listApis request.
plt:kafka:base:metadataBaseTraces a Base.metadata request.
plt:kafka:admin:topicsAdminTraces a Admin.createTopics or Admin.deleteTopics request.
plt:kafka:admin:groupsAdminTraces a Admin.listGroups, Admin.describeGroups, Admin.deleteGroups or Admin.removeMembersFromConsumerGroup request.
plt:kafka:admin:clientQuotasAdminTraces a Admin.describeClientQuotas or Admin.alterClientQuotas request.
plt:kafka:admin:logDirsAdminTraces a Admin.describeLogDirs request.
plt:kafka:admin:consumerGroupOffsetsAdminTraces a Admin.listConsumerGroupOffsets or Admin.deleteConsumerGroupOffsets request.
plt:kafka:admin:configsAdminTraces a Admin.describeConfigs, Admin.alterConfigs, or Admin.incrementalAlterConfigs request.
plt:kafka:admin:aclsAdminTraces a Admin.createAcls, Admin.describeAcls or Admin.deleteAcls request.
plt:kafka:admin:offsetsAdminTraces a Admin.listOffsets request.
plt:kafka:producer:initIdempotentProducerTraces a Producer.initIdempotentProducer request.
plt:kafka:producer:sendsProducerTraces a Producer.send request.
plt:kafka:consumer:groupConsumerTraces a Consumer.findGroupCoordinator, Consumer.joinGroup or Consumer.leaveGroup requests.
plt:kafka:consumer:heartbeatConsumerTraces the Consumer heartbeat requests.
plt:kafka:consumer:receivesConsumerTraces processing of every message.
plt:kafka:consumer:fetchesConsumerTraces a Consumer.fetch request.
plt:kafka:consumer:consumesConsumerTraces a Consumer.consume request.
plt:kafka:consumer:commitsConsumerTraces a Consumer.commit request.
plt:kafka:consumer:offsetsConsumerTraces a Consumer.listOffsets or Consumer.listCommittedOffsets request.