opentelemetry-instrumentation-kafkajs
TypeScript icon, indicating that this package has built-in type declarations

0.41.0 • Public • Published

OpenTelemetry kafkajs Instrumentation for Node.js

NPM version

This module provides automatic instrumentation for kafkajs.

Installation

npm install --save opentelemetry-instrumentation-kafkajs

Usage

For further automatic instrumentation instruction see the @opentelemetry/instrumentation package.

const { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
const { KafkaJsInstrumentation } = require('opentelemetry-instrumentation-kafkajs');

const tracerProvider = new NodeTracerProvider({
  // be sure to disable old plugin
  plugins: {
    kafkajs: { enabled: false, path: 'opentelemetry-plugin-kafkajs' }
  }
});

registerInstrumentations({
  tracerProvider,
  instrumentations: [
    new KafkaJsInstrumentation({
      // see under for available configuration
    })
  ]
});

kafkajs Instrumentation Options

kafkajs instrumentation 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.
moduleVersionAttributeName string If passed, a span attribute will be added to all spans with key of the provided moduleVersionAttributeName and value of the patched module version

This extension (and many others) was developed by Aspecto with ❤️

/opentelemetry-instrumentation-kafkajs/

    Package Sidebar

    Install

    npm i opentelemetry-instrumentation-kafkajs

    Weekly Downloads

    104,058

    Version

    0.41.0

    License

    Apache-2.0

    Unpacked Size

    53.4 kB

    Total Files

    18

    Last publish

    Collaborators

    • aspecto-release-bot