From 1eb20447bc10f2e2f8185d73b13aedc588d6ee25 Mon Sep 17 00:00:00 2001 From: Bastian Krol Date: Tue, 2 Jul 2024 10:55:41 +0200 Subject: [PATCH 1/2] 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 2825fd1..b273fb1 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 045323e..0ad95af 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(), }; From 948205e94d6a12f0067e7c90693d81c6a5ff2f6d Mon Sep 17 00:00:00 2001 From: Bastian Krol Date: Tue, 2 Jul 2024 11:11:49 +0200 Subject: [PATCH 2/2] test: increase integration test timeout on CI --- test/.mocharc.integration.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/.mocharc.integration.js b/test/.mocharc.integration.js index e7b9db9..c495c28 100644 --- a/test/.mocharc.integration.js +++ b/test/.mocharc.integration.js @@ -3,7 +3,10 @@ 'use strict'; -/* global module */ +/* global module, require */ + +// eslint-disable-next-line @typescript-eslint/no-var-requires +const isCi = require('is-ci'); module.exports = { extension: ['ts'], @@ -14,5 +17,5 @@ module.exports = { require: ['ts-node/register'], slow: 3000, spec: ['test/**/*test.ts'], - timeout: 10000, + timeout: isCi ? 20000 : 10000, };