@@ -49,6 +49,8 @@ diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.INFO);
49
49
* @param {string } [options.serviceName=process.env.SERVICE_NAME] - The name of the service.
50
50
* @param {string } [options.url=process.env.ENDPOINT] - The endpoint URL for the tracing collector.
51
51
* @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.
52
54
*
53
55
* @returns {Tracer } - The tracer for the service.
54
56
*/
@@ -60,6 +62,8 @@ export function setupTracing(options = {}) {
60
62
serviceName = process . env . SERVICE_NAME ,
61
63
url = process . env . ENDPOINT ,
62
64
concurrencyLimit = 10 ,
65
+ enableFsInstrumentation = false ,
66
+ enableDnsInstrumentation = false ,
63
67
} = options ;
64
68
65
69
// Configure exporter with the Collector endpoint - uses gRPC
@@ -103,18 +107,31 @@ export function setupTracing(options = {}) {
103
107
} ;
104
108
105
109
// Register instrumentations
106
- registerInstrumentations ( {
107
- tracerProvider : tracerProvider ,
108
- instrumentations : [
110
+ const instrumentations = [
109
111
new PinoInstrumentation ( ) ,
110
112
new HttpInstrumentation ( { requireParentforOutgoingSpans : false , requireParentforIncomingSpans : false , ignoreIncomingRequestHook, } ) ,
111
113
new ExpressInstrumentation ( { ignoreIncomingRequestHook, } ) ,
112
114
new ConnectInstrumentation ( ) ,
113
115
new AwsInstrumentation ( { sqsExtractContextPropagationFromPayload : true , } ) ,
114
116
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 ,
118
135
} ) ;
119
136
120
137
// Return the tracer for the service
0 commit comments