@saidsef/tracing-node 3.9.0 → 3.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/libs/index.mjs +17 -1
- package/package.json +1 -1
package/libs/index.mjs
CHANGED
|
@@ -44,6 +44,8 @@ diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.INFO);
|
|
|
44
44
|
* This function configures a NodeTracerProvider with various instrumentations
|
|
45
45
|
* and span processors to enable tracing for the application. It supports
|
|
46
46
|
* tracing for HTTP, Express, AWS, Pino, DNS, Elasticsearch, and IORedis.
|
|
47
|
+
* The IORedis instrumentation includes peer.service attributes for proper
|
|
48
|
+
* service map visualization in distributed tracing tools like Tempo.
|
|
47
49
|
*
|
|
48
50
|
* @param {Object} options - Configuration options for tracing.
|
|
49
51
|
* @param {string} [options.hostname=process.env.HOSTNAME] - The hostname of the service.
|
|
@@ -118,6 +120,13 @@ export function setupTracing(options = {}) {
|
|
|
118
120
|
span.setAttribute('peer.service', 'elasticsearch');
|
|
119
121
|
span.setAttribute('db.system', 'elasticsearch');
|
|
120
122
|
}
|
|
123
|
+
|
|
124
|
+
// Detect Redis endpoints
|
|
125
|
+
if (hostname.includes('redis') || url.includes('redis') ||
|
|
126
|
+
hostname.includes(':6379') || url.includes(':6379')) {
|
|
127
|
+
span.setAttribute('peer.service', 'redis');
|
|
128
|
+
span.setAttribute('db.system', 'redis');
|
|
129
|
+
}
|
|
121
130
|
};
|
|
122
131
|
|
|
123
132
|
// Register instrumentations
|
|
@@ -131,7 +140,14 @@ export function setupTracing(options = {}) {
|
|
|
131
140
|
new PinoInstrumentation({logHook: (span, record) => {record['trace_id'] = span.spanContext().traceId;record['span_id'] = span.spanContext().spanId;},}),
|
|
132
141
|
new ConnectInstrumentation(),
|
|
133
142
|
new AwsInstrumentation({ sqsExtractContextPropagationFromPayload: true, }),
|
|
134
|
-
new IORedisInstrumentation(
|
|
143
|
+
new IORedisInstrumentation({
|
|
144
|
+
responseHook: (span) => {
|
|
145
|
+
span.setAttribute('peer.service', 'redis');
|
|
146
|
+
},
|
|
147
|
+
requestHook: (span) => {
|
|
148
|
+
span.setAttribute('peer.service', 'redis');
|
|
149
|
+
},
|
|
150
|
+
}),
|
|
135
151
|
new ElasticsearchInstrumentation(),
|
|
136
152
|
];
|
|
137
153
|
|