@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.
@@ -31,4 +31,4 @@ spec:
31
31
  gitRepo:
32
32
  directory: "."
33
33
  repository: "https://github.com/saidsef/tracing-node.git"
34
- revision: "dependabot-npm_and_yarn-opentelemetry-instrumentation-express-0.39.0"
34
+ revision: "tracking-func-signature"
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 a given service, allowing for the collection and export of trace data.
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
- * @param {string} serviceName - The name of the service to be traced. This will be used to
45
- * label traces and is essential for identifying traces belonging
46
- * to this service.
47
- * @param {string} [appName="application"] - The namespace or application name the service
48
- * belongs to. This helps in grouping services under
49
- * a common namespace for better trace organization.
50
- * @param {string|null} [endpoint=null] - The endpoint URL for the OTLP gRPC exporter. If not
51
- * provided, the exporter will default to its standard
52
- * configuration, which might not be suitable for all
53
- * deployments.
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 async function setupTracing (serviceName, appName='application', endpoint=null) {
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 await provider.getTracer(serviceName);
113
+ return provider.getTracer(serviceName);
116
114
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saidsef/tracing-node",
3
- "version": "1.10.5",
3
+ "version": "2.0.0",
4
4
  "description": "tracing NodeJS - This is a wrapper for OpenTelemetry instrumentation packages",
5
5
  "main": "libs/index.mjs",
6
6
  "scripts": {