@aspecto/opentelemetry-plugin-kafka-node

open telemetry instrumentation for the `kafka-node` kafka client

Usage no npm install needed!

<script type="module">
  import aspectoOpentelemetryPluginKafkaNode from 'https://cdn.skypack.dev/@aspecto/opentelemetry-plugin-kafka-node';
</script>

README

OpenTelemetry kafka-node Instrumentation for Node.js

This module provides automatic instrumentation for kafka-node.

Installation

npm install --save @aspecto/opentelemetry-plugin-kafka-node

Usage

To load a specific plugin (kafka-node in this case), specify it in the Node Tracer's configuration

const { NodeTracerProvider } = require('@opentelemetry/node');

const provider = new NodeTracerProvider({
  plugins: {
    'kafka-node': {
      enabled: true,
      // You may use a package name or absolute path to the file.
      path: '@aspecto/opentelemetry-plugin-kafka-node',
    }
  }
});

kafka-node Plugin Options

kafka-node plugin has few options available to choose from. You can set the following:

Options Type Description
producerHook KafkaProducerCustomAttributeFunction Hook called before producer message is sent, which allow to add custom attributes to span.
consumerHook KafkaConsumerCustomAttributeFunction Hook called before consumer message is processed, which allow to add custom attributes to span.

Known Issues

  • This library instrument only the Producer and Consumer.
  • Due to the lack of support in kafka-node in message headers, there is currently no context propagation between producers and consumers.