@saidsef/tracing-node 1.10.5 → 2.0.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/deployment/base/job.yml +1 -1
- package/libs/index.mjs +19 -21
- package/package.json +1 -1
package/deployment/base/job.yml
CHANGED
package/libs/index.mjs
CHANGED
|
@@ -34,28 +34,26 @@ import {B3Propagator, B3InjectEncoding} from '@opentelemetry/propagator-b3';
|
|
|
34
34
|
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.INFO);
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
|
-
* Sets up tracing for
|
|
38
|
-
* This function configures a NodeTracerProvider with specific resource attributes, including
|
|
39
|
-
* service name, namespace, and host. It also configures an exporter using the OTLP protocol
|
|
40
|
-
* over gRPC, with the option to specify an endpoint. Instrumentations for HTTP, Express,
|
|
41
|
-
* AWS, Pino, and DNS are registered to capture relevant spans. The function finally returns
|
|
42
|
-
* a tracer specific to the service for initiating and exporting spans.
|
|
37
|
+
* Sets up tracing for the application using OpenTelemetry.
|
|
43
38
|
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* @param {string
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* @returns {Tracer} - Returns a Tracer instance configured for the service. This tracer can
|
|
55
|
-
* be used to create and export spans for tracing various operations within
|
|
56
|
-
* the service.
|
|
39
|
+
* This function configures a NodeTracerProvider with various instrumentations
|
|
40
|
+
* and span processors to enable tracing for the application. It supports
|
|
41
|
+
* tracing for HTTP, Express, AWS, Pino, and DNS.
|
|
42
|
+
*
|
|
43
|
+
* @param {Object} options - Configuration options for tracing.
|
|
44
|
+
* @param {string} [options.serviceName=process.env.HOSTNAME] - The name of the service.
|
|
45
|
+
* @param {string} [options.appName=process.env.APP_NAME] - The name of the application.
|
|
46
|
+
* @param {string} [options.endpoint=process.env.ENDPOINT] - The endpoint for the trace exporter.
|
|
47
|
+
*
|
|
48
|
+
* @returns {Tracer} - The tracer for the service.
|
|
57
49
|
*/
|
|
58
|
-
export
|
|
50
|
+
export function setupTracing (options={}) {
|
|
51
|
+
const {
|
|
52
|
+
serviceName = process.env.HOSTNAME,
|
|
53
|
+
appName = process.env.APP_NAME,
|
|
54
|
+
endpoint = process.env.ENDPOINT
|
|
55
|
+
} = options;
|
|
56
|
+
|
|
59
57
|
const provider = new NodeTracerProvider({
|
|
60
58
|
resource: new Resource({
|
|
61
59
|
[SemanticResourceAttributes.SERVICE_NAME]: serviceName,
|
|
@@ -112,5 +110,5 @@ export async function setupTracing (serviceName, appName='application', endpoint
|
|
|
112
110
|
})});
|
|
113
111
|
|
|
114
112
|
// Return the tracer for the service
|
|
115
|
-
return
|
|
113
|
+
return provider.getTracer(serviceName);
|
|
116
114
|
}
|