From b33d7dc3c77b562f0248f670d47a06d7c54ed6ba Mon Sep 17 00:00:00 2001 From: Bastian Krol Date: Tue, 2 Jul 2024 10:55:41 +0200 Subject: [PATCH] feat: add kafkajs instrumentation --- package-lock.json | 16 ++++++++++++++++ package.json | 1 + src/init.ts | 7 ++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 638255f..00a35d0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ "@opentelemetry/exporter-logs-otlp-proto": "^0.52.1", "@opentelemetry/exporter-metrics-otlp-proto": "^0.52.1", "@opentelemetry/exporter-trace-otlp-proto": "^0.52.1", + "@opentelemetry/instrumentation-kafkajs": "^0.1.0", "@opentelemetry/resource-detector-container": "^0.3.11", "@opentelemetry/resources": "^1.25.1", "@opentelemetry/sdk-logs": "^0.52.1", @@ -1659,6 +1660,21 @@ "@opentelemetry/api": "^1.3.0" } }, + "node_modules/@opentelemetry/instrumentation-kafkajs": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-kafkajs/-/instrumentation-kafkajs-0.1.0.tgz", + "integrity": "sha512-e8oGUUIzg+yHae93KXtR4Sbrl37u+2IFaHQlzsV3Zwc+ch8dT7OkQBBBUcJWD4q3IVxvVBP3+uexfhR/e2GWiw==", + "dependencies": { + "@opentelemetry/instrumentation": "^0.52.0", + "@opentelemetry/semantic-conventions": "^1.24.0" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.3.0" + } + }, "node_modules/@opentelemetry/instrumentation-knex": { "version": "0.37.0", "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-knex/-/instrumentation-knex-0.37.0.tgz", diff --git a/package.json b/package.json index 81af2b8..52af178 100644 --- a/package.json +++ b/package.json @@ -58,6 +58,7 @@ "@opentelemetry/exporter-logs-otlp-proto": "^0.52.1", "@opentelemetry/exporter-metrics-otlp-proto": "^0.52.1", "@opentelemetry/exporter-trace-otlp-proto": "^0.52.1", + "@opentelemetry/instrumentation-kafkajs": "^0.1.0", "@opentelemetry/resource-detector-container": "^0.3.11", "@opentelemetry/resources": "^1.25.1", "@opentelemetry/sdk-logs": "^0.52.1", diff --git a/src/init.ts b/src/init.ts index 1941554..6262fb8 100644 --- a/src/init.ts +++ b/src/init.ts @@ -13,6 +13,7 @@ import { PeriodicExportingMetricReader } from '@opentelemetry/sdk-metrics'; import { NodeSDK, NodeSDKConfiguration } from '@opentelemetry/sdk-node'; import { BatchSpanProcessor, SpanProcessor } from '@opentelemetry/sdk-trace-base'; import { ConsoleSpanExporter } from '@opentelemetry/sdk-trace-node'; +import { KafkaJsInstrumentation } from '@opentelemetry/instrumentation-kafkajs'; import PodUidDetector from './detectors/node/opentelemetry-resource-detector-kubernetes-pod'; import ServiceNameFallbackDetector from './detectors/node/opentelemetry-resource-detector-service-name-fallback'; @@ -63,7 +64,11 @@ const configuration: Partial = { spanProcessors: spanProcessors(), metricReader: metricsReader(), logRecordProcessor: logRecordProcessor(), - instrumentations: [getNodeAutoInstrumentations(createInstrumentationConfig())], + instrumentations: [ + // + getNodeAutoInstrumentations(createInstrumentationConfig()), + new KafkaJsInstrumentation(), + ], resource: resource(), resourceDetectors: resourceDetectors(), };