diff --git a/README.md b/README.md index 1c03aed..a80921a 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,8 @@ setupTracing({hostname: 'hostname', serviceName: 'service_name', url: 'endpoint' | hostname | string | container / pod hostname | | serviceName | string | service / application name | | url | string | tracing endpoint i.e. `://:` | +| enableFsInstrumentation | boolean | enable FS instrumentation, default `false` | +| enableDnsInstrumentation | boolean | enable DNS instrumentation, default `false` | ## Source diff --git a/deployment/base/job.yml b/deployment/base/job.yml index 44c42b0..583df1a 100644 --- a/deployment/base/job.yml +++ b/deployment/base/job.yml @@ -34,4 +34,4 @@ spec: gitRepo: directory: "." repository: "https://github.com/saidsef/tracing-node.git" - revision: "dependabot-npm_and_yarn-opentelemetry-instrumentation-aws-sdk-0.50.0" + revision: "optional-dns-fs-instrumentation" diff --git a/libs/index.mjs b/libs/index.mjs index de26bc1..de1f68f 100644 --- a/libs/index.mjs +++ b/libs/index.mjs @@ -49,6 +49,8 @@ diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.INFO); * @param {string} [options.serviceName=process.env.SERVICE_NAME] - The name of the service. * @param {string} [options.url=process.env.ENDPOINT] - The endpoint URL for the tracing collector. * @param {number} [options.concurrencyLimit=10] - The concurrency limit for the exporter. +* @param {boolean} [options.enableFsInstrumentation=false] - Enable file system instrumentation. +* @param {boolean} [options.enableDnsInstrumentation=false] - Enable DNS instrumentation. * * @returns {Tracer} - The tracer for the service. */ @@ -60,6 +62,8 @@ export function setupTracing(options = {}) { serviceName = process.env.SERVICE_NAME, url = process.env.ENDPOINT, concurrencyLimit = 10, + enableFsInstrumentation = false, + enableDnsInstrumentation = false, } = options; // Configure exporter with the Collector endpoint - uses gRPC @@ -103,18 +107,31 @@ export function setupTracing(options = {}) { }; // Register instrumentations - registerInstrumentations({ - tracerProvider: tracerProvider, - instrumentations: [ + const instrumentations = [ new PinoInstrumentation(), new HttpInstrumentation({ requireParentforOutgoingSpans: false, requireParentforIncomingSpans: false, ignoreIncomingRequestHook, }), new ExpressInstrumentation({ ignoreIncomingRequestHook, }), new ConnectInstrumentation(), new AwsInstrumentation({ sqsExtractContextPropagationFromPayload: true, }), new IORedisInstrumentation(), - new FsInstrumentation(), - new DnsInstrumentation(), - ], + ]; + + if (enableFsInstrumentation) { + // Enable fs instrumentation if specified + // This instrumentation is useful for tracing file system operations. + instrumentations.push(new FsInstrumentation()); + } + + if (enableDnsInstrumentation) { + // Enable DNS instrumentation if specified + // This instrumentation is useful for tracing DNS operations. + instrumentations.push(new DnsInstrumentation()); + } + + // Register instrumentations + registerInstrumentations({ + tracerProvider: tracerProvider, + instrumentations: instrumentations, }); // Return the tracer for the service diff --git a/package-lock.json b/package-lock.json index 9a52601..0c8319c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@saidsef/tracing-node", - "version": "3.4.5", + "version": "3.4.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@saidsef/tracing-node", - "version": "3.4.5", + "version": "3.4.6", "license": "Apache-2.0", "dependencies": { "@opentelemetry/api": "^1.9.0", @@ -2337,9 +2337,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001709", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001709.tgz", - "integrity": "sha512-NgL3vUTnDrPCZ3zTahp4fsugQ4dc7EKTSzwQDPEel6DMoMnfH2jhry9n2Zm8onbSR+f/QtKHFOA+iAQu4kbtWA==", + "version": "1.0.30001710", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001710.tgz", + "integrity": "sha512-B5C0I0UmaGqHgo5FuqJ7hBd4L57A4dDD+Xi+XX1nXOoxGeDdY4Ko38qJYOyqznBVJEqON5p8P1x5zRR3+rsnxA==", "dev": true, "funding": [ { diff --git a/package.json b/package.json index ec2eb0b..325f137 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@saidsef/tracing-node", - "version": "3.4.5", + "version": "3.4.6", "description": "tracing NodeJS - Wrapper for OpenTelemetry instrumentation packages", "main": "libs/index.mjs", "scripts": {