Skip to content

Commit c865083

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

File tree

5 files changed

+32
-13
lines changed

5 files changed

+32
-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: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.INFO);
4949
* @param {string} [options.serviceName=process.env.SERVICE_NAME] - The name of the service.
5050
* @param {string} [options.url=process.env.ENDPOINT] - The endpoint URL for the tracing collector.
5151
* @param {number} [options.concurrencyLimit=10] - The concurrency limit for the exporter.
52+
* @param {boolean} [options.enableFsInstrumentation=false] - Enable file system instrumentation.
53+
* @param {boolean} [options.enableDnsInstrumentation=false] - Enable DNS instrumentation.
5254
*
5355
* @returns {Tracer} - The tracer for the service.
5456
*/
@@ -60,6 +62,8 @@ export function setupTracing(options = {}) {
6062
serviceName = process.env.SERVICE_NAME,
6163
url = process.env.ENDPOINT,
6264
concurrencyLimit = 10,
65+
enableFsInstrumentation = false,
66+
enableDnsInstrumentation = false,
6367
} = options;
6468

6569
// Configure exporter with the Collector endpoint - uses gRPC
@@ -103,18 +107,31 @@ export function setupTracing(options = {}) {
103107
};
104108

105109
// Register instrumentations
106-
registerInstrumentations({
107-
tracerProvider: tracerProvider,
108-
instrumentations: [
110+
const instrumentations = [
109111
new PinoInstrumentation(),
110112
new HttpInstrumentation({ requireParentforOutgoingSpans: false, requireParentforIncomingSpans: false, ignoreIncomingRequestHook, }),
111113
new ExpressInstrumentation({ ignoreIncomingRequestHook, }),
112114
new ConnectInstrumentation(),
113115
new AwsInstrumentation({ sqsExtractContextPropagationFromPayload: true, }),
114116
new IORedisInstrumentation(),
115-
new FsInstrumentation(),
116-
new DnsInstrumentation(),
117-
],
117+
];
118+
119+
if (enableFsInstrumentation) {
120+
// Enable fs instrumentation if specified
121+
// This instrumentation is useful for tracing file system operations.
122+
instrumentations.push(new FsInstrumentation());
123+
}
124+
125+
if (enableDnsInstrumentation) {
126+
// Enable DNS instrumentation if specified
127+
// This instrumentation is useful for tracing DNS operations.
128+
instrumentations.push(new DnsInstrumentation());
129+
}
130+
131+
// Register instrumentations
132+
registerInstrumentations({
133+
tracerProvider: tracerProvider,
134+
instrumentations: instrumentations,
118135
});
119136

120137
// 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)