Skip to content

Commit 6ed461d

Browse files
committed
chore: make dns and fs optional instrumentation
1 parent 68040b1 commit 6ed461d

File tree

5 files changed

+30
-13
lines changed

5 files changed

+30
-13
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ setupTracing({hostname: 'hostname', serviceName: 'service_name', url: 'endpoint'
5454
| hostname | string | container / pod hostname |
5555
| serviceName | string | service / application name |
5656
| url | string | tracing endpoint i.e. `<schema>://<host>:<port>` |
57+
| enableFsInstrumentation | boolean | enable FS instrumentation, default `false` |
58+
| enableDnsInstrumentation | boolean | enable DNS instrumentation, default `false` |
5759

5860
## Source
5961

deployment/base/job.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ spec:
3434
gitRepo:
3535
directory: "."
3636
repository: "https://github.com/saidsef/tracing-node.git"
37-
revision: "dependabot-npm_and_yarn-opentelemetry-instrumentation-aws-sdk-0.50.0"
37+
revision: "optional-dns-fs-instrumentation"

libs/index.mjs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ export function setupTracing(options = {}) {
6060
serviceName = process.env.SERVICE_NAME,
6161
url = process.env.ENDPOINT,
6262
concurrencyLimit = 10,
63+
enableFsInstrumentation = false,
64+
enableDnsInstrumentation = false,
6365
} = options;
6466

6567
// Configure exporter with the Collector endpoint - uses gRPC
@@ -103,18 +105,31 @@ export function setupTracing(options = {}) {
103105
};
104106

105107
// Register instrumentations
106-
registerInstrumentations({
107-
tracerProvider: tracerProvider,
108-
instrumentations: [
108+
const instrumentations = [
109109
new PinoInstrumentation(),
110110
new HttpInstrumentation({ requireParentforOutgoingSpans: false, requireParentforIncomingSpans: false, ignoreIncomingRequestHook, }),
111111
new ExpressInstrumentation({ ignoreIncomingRequestHook, }),
112112
new ConnectInstrumentation(),
113113
new AwsInstrumentation({ sqsExtractContextPropagationFromPayload: true, }),
114114
new IORedisInstrumentation(),
115-
new FsInstrumentation(),
116-
new DnsInstrumentation(),
117-
],
115+
];
116+
117+
if (enableFsInstrumentation) {
118+
// Enable fs instrumentation if specified
119+
// This instrumentation is useful for tracing file system operations.
120+
instrumentations.push(new FsInstrumentation());
121+
}
122+
123+
if (enableDnsInstrumentation) {
124+
// Enable DNS instrumentation if specified
125+
// This instrumentation is useful for tracing DNS operations.
126+
instrumentations.push(new DnsInstrumentation());
127+
}
128+
129+
// Register instrumentations
130+
registerInstrumentations({
131+
tracerProvider: tracerProvider,
132+
instrumentations: instrumentations,
118133
});
119134

120135
// Return the tracer for the service

package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@saidsef/tracing-node",
3-
"version": "3.4.5",
3+
"version": "3.4.6",
44
"description": "tracing NodeJS - Wrapper for OpenTelemetry instrumentation packages",
55
"main": "libs/index.mjs",
66
"scripts": {

0 commit comments

Comments
 (0)