Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
@opentelemetry/instrumentation-kafkajs
Advanced tools
OpenTelemetry instrumentation for `kafkajs` messaging client for Apache Kafka
@opentelemetry/instrumentation-kafkajs is an OpenTelemetry instrumentation library for KafkaJS, a popular Kafka client for Node.js. This package allows you to automatically collect and report telemetry data such as traces and metrics from KafkaJS applications, helping you monitor and troubleshoot your Kafka-based systems.
Automatic Tracing
This feature automatically captures and reports trace data for KafkaJS operations, such as producing and consuming messages. The code sample shows how to set up the NodeTracerProvider and register the KafkaJsInstrumentation to start collecting telemetry data.
const { NodeTracerProvider } = require('@opentelemetry/node');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
const { KafkaJsInstrumentation } = require('@opentelemetry/instrumentation-kafkajs');
const provider = new NodeTracerProvider();
provider.register();
registerInstrumentations({
instrumentations: [
new KafkaJsInstrumentation(),
],
});
Custom Span Attributes
This feature allows you to add custom attributes to spans for more detailed telemetry data. The code sample demonstrates how to configure the KafkaJsInstrumentation with hooks to add custom attributes to spans for both producer and consumer operations.
const { KafkaJsInstrumentation } = require('@opentelemetry/instrumentation-kafkajs');
const instrumentation = new KafkaJsInstrumentation({
producerHook: (span, topic, message) => {
span.setAttribute('custom.attribute', 'value');
},
consumerHook: (span, topic, message) => {
span.setAttribute('custom.attribute', 'value');
}
});
This package provides OpenTelemetry instrumentation for HTTP clients and servers. It automatically captures and reports telemetry data for HTTP requests and responses. Compared to @opentelemetry/instrumentation-kafkajs, it focuses on HTTP rather than KafkaJS.
This package offers OpenTelemetry instrumentation for Express.js applications. It captures and reports telemetry data for Express routes and middleware. While @opentelemetry/instrumentation-kafkajs is specific to KafkaJS, this package is tailored for Express.js.
This package provides OpenTelemetry instrumentation for GraphQL servers. It captures and reports telemetry data for GraphQL queries and mutations. Unlike @opentelemetry/instrumentation-kafkajs, which is for KafkaJS, this package is designed for GraphQL.
kafkajs
Instrumentation for Node.jsThis module provides automatic instrumentation for the kafkajs
package, which may be loaded using the @opentelemetry/sdk-trace-node
package and is included in the @opentelemetry/auto-instrumentations-node
bundle.
If total installation size is not constrained, it is recommended to use the @opentelemetry/auto-instrumentations-node
bundle with @opentelemetry/sdk-node for the most seamless instrumentation experience.
Compatible with OpenTelemetry JS API and SDK 1.0+
.
npm install --save @opentelemetry/instrumentation-kafkajs
kafkajs
versions >=0.1.0 <3
const { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node');
const { KafkaJsInstrumentation } = require('@opentelemetry/instrumentation-kafkajs');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
const provider = new NodeTracerProvider();
provider.register();
registerInstrumentations({
instrumentations: [
new KafkaJsInstrumentation({
// see below for available configuration
}),
],
});
You can set the following:
Options | Type | Description |
---|---|---|
producerHook | KafkaProducerCustomAttributeFunction | Function called before a producer message is sent. Allows for adding custom attributes to the span. |
consumerHook | KafkaConsumerCustomAttributeFunction | Function called before a consumer message is processed. Allows for adding custom attributes to the span. |
This package uses @opentelemetry/semantic-conventions
version 1.24+
, which implements Semantic Convention Version 1.7.0
Attributes collected:
Attribute | Short Description |
---|---|
messaging.system | An identifier for the messaging system being used. |
messaging.destination | The message destination name. |
messaging.operation | A string identifying the kind of messaging operation. |
Apache 2.0 - See LICENSE for more information.
FAQs
OpenTelemetry instrumentation for `kafkajs` messaging client for Apache Kafka
The npm package @opentelemetry/instrumentation-kafkajs receives a total of 1,177,700 weekly downloads. As such, @opentelemetry/instrumentation-kafkajs popularity was classified as popular.
We found that @opentelemetry/instrumentation-kafkajs demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.