@saidsef/tracing-node 1.9.8 → 1.10.1

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/.eslintrc.yml CHANGED
@@ -1,12 +1,26 @@
1
1
  env:
2
- browser: true
3
- commonjs: true
2
+ node: true
3
+ commonjs: false
4
4
  es2021: true
5
- jest: true
6
5
  extends: eslint:recommended
7
6
  parserOptions:
8
7
  ecmaVersion: latest
9
8
  sourceType: module
10
- rules: {}
9
+ rules:
10
+ "prefer-const": ["error", { "ignoreReadBeforeAssign": true }]
11
+ arrow-spacing: ["error", { "before": true, "after": true }]
12
+ computed-property-spacing: ["error", "never"]
13
+ eol-last: ["error", "always"]
14
+ no-compare-neg-zero: "error"
15
+ no-tabs: ["error", { allowIndentationTabs: true }]
16
+ no-trailing-spaces: "error"
17
+ no-unused-vars: "error"
18
+ no-whitespace-before-property: "error"
19
+ object-curly-spacing: ["error", "never"]
20
+ quotes: ["warn", "single"]
21
+ rest-spread-spacing: ["error", "always"]
22
+ semi: ["warn", "always"]
23
+ space-before-blocks: "error"
24
+ template-curly-spacing: "error"
11
25
  overrides:
12
- - files: ["*.js", "*.mjs"]
26
+ - files: [ "libs/index.mjs"]
package/README.md CHANGED
@@ -23,12 +23,12 @@ npm install @saidsef/tracing-node --save
23
23
  ## Usage
24
24
 
25
25
  ```
26
- const setupTracing = require('@saidsef/tracing-node');
26
+ const { setupTracing } = require('@saidsef/tracing-node');
27
27
  setupTracing('hostname', 'application_name', 'endpoint');
28
28
  ```
29
29
 
30
30
  ```
31
- import setupTracing from '@saidsef/tracing-node';
31
+ import { setupTracing } from '@saidsef/tracing-node';
32
32
  setupTracing('hostname', 'application_name', 'endpoint');
33
33
  ```
34
34
 
package/libs/index.mjs CHANGED
@@ -16,20 +16,20 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
- import { CompositePropagator, W3CBaggagePropagator, W3CTraceContextPropagator } from '@opentelemetry/core';
20
- import { registerInstrumentations } from '@opentelemetry/instrumentation';
21
- import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
22
- import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base';
23
- import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-grpc';
24
- import { HttpInstrumentation } from '@opentelemetry/instrumentation-http';
25
- import { ExpressInstrumentation } from '@opentelemetry/instrumentation-express';
26
- import { diag, DiagConsoleLogger, DiagLogLevel } from '@opentelemetry/api';
27
- import { Resource } from '@opentelemetry/resources';
28
- import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
29
- import { AwsInstrumentation } from '@opentelemetry/instrumentation-aws-sdk';
30
- import { PinoInstrumentation } from '@opentelemetry/instrumentation-pino';
31
- import { DnsInstrumentation } from '@opentelemetry/instrumentation-dns';
32
- import { B3Propagator, B3InjectEncoding } from '@opentelemetry/propagator-b3';
19
+ import {CompositePropagator, W3CBaggagePropagator, W3CTraceContextPropagator} from '@opentelemetry/core';
20
+ import {registerInstrumentations} from '@opentelemetry/instrumentation';
21
+ import {NodeTracerProvider} from '@opentelemetry/sdk-trace-node';
22
+ import {BatchSpanProcessor} from '@opentelemetry/sdk-trace-base';
23
+ import {OTLPTraceExporter} from '@opentelemetry/exporter-trace-otlp-grpc';
24
+ import {HttpInstrumentation} from '@opentelemetry/instrumentation-http';
25
+ import {ExpressInstrumentation} from '@opentelemetry/instrumentation-express';
26
+ import {diag, DiagConsoleLogger, DiagLogLevel} from '@opentelemetry/api';
27
+ import {Resource} from '@opentelemetry/resources';
28
+ import {SemanticResourceAttributes} from '@opentelemetry/semantic-conventions';
29
+ import {AwsInstrumentation} from '@opentelemetry/instrumentation-aws-sdk';
30
+ import {PinoInstrumentation} from '@opentelemetry/instrumentation-pino';
31
+ import {DnsInstrumentation} from '@opentelemetry/instrumentation-dns';
32
+ import {B3Propagator, B3InjectEncoding} from '@opentelemetry/propagator-b3';
33
33
 
34
34
  diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.INFO);
35
35
 
@@ -55,7 +55,7 @@ diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.INFO);
55
55
  * be used to create and export spans for tracing various operations within
56
56
  * the service.
57
57
  */
58
- export default function setupTracing (serviceName, appName="application", endpoint=null) {
58
+ export async function setupTracing (serviceName, appName='application', endpoint=null) {
59
59
  const provider = new NodeTracerProvider({
60
60
  resource: new Resource({
61
61
  [SemanticResourceAttributes.SERVICE_NAME]: serviceName,
@@ -79,7 +79,7 @@ export default function setupTracing (serviceName, appName="application", endpoi
79
79
  const ignoreIncomingRequestHook = (req) => {
80
80
  const isStaticAsset = !!req.url.match(/^\/metrics|\/healthz.*$/);
81
81
  return isStaticAsset;
82
- }
82
+ };
83
83
 
84
84
  // Register instrumentations
85
85
  registerInstrumentations({
@@ -108,9 +108,9 @@ export default function setupTracing (serviceName, appName="application", endpoi
108
108
  // Initialize the tracer provider
109
109
  provider.register({
110
110
  propagator: new CompositePropagator({
111
- propagators: [new W3CBaggagePropagator(), new W3CTraceContextPropagator(), new B3Propagator({ injectEncoding: B3InjectEncoding.MULTI_HEADER })],
111
+ propagators: [new W3CBaggagePropagator(), new W3CTraceContextPropagator(), new B3Propagator({injectEncoding: B3InjectEncoding.MULTI_HEADER})],
112
112
  })});
113
113
 
114
114
  // Return the tracer for the service
115
- return provider.getTracer(serviceName);
115
+ return await provider.getTracer(serviceName);
116
116
  }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@saidsef/tracing-node",
3
- "version": "1.9.8",
3
+ "version": "1.10.1",
4
4
  "description": "tracing NodeJS - This is a wrapper for OpenTelemetry instrumentation packages",
5
5
  "main": "libs/index.mjs",
6
6
  "scripts": {
7
7
  "test": "node --trace-warnings --test --report-uncaught-exception --heap-prof --cpu-prof --track-heap-objects --report-dir=test/ --diagnostic-dir=test/ --heap-prof-dir=test/ libs/index.mjs",
8
- "lint": "eslint libs -c .eslintrc.yml ",
9
- "rebuild": "rm -rfv node_modules/ package-lock.json && NODE_ENV=production npm install"
8
+ "lint": "eslint .",
9
+ "rebuild": "rm -rfv node_modules/ package-lock.json && npm install --prod --omit=dev"
10
10
  },
11
11
  "type": "module",
12
12
  "private": false,
@@ -31,7 +31,7 @@
31
31
  "author": "Said Sef <saidsef@gmail.com>",
32
32
  "license": "Apache-2.0",
33
33
  "engines": {
34
- "node": ">= 19"
34
+ "node": ">= 20"
35
35
  },
36
36
  "bugs": {
37
37
  "url": "https://github.com/saidsef/tracing-nodejs/issues"
@@ -53,7 +53,7 @@
53
53
  "@opentelemetry/semantic-conventions": "^1.22.0"
54
54
  },
55
55
  "devDependencies": {
56
- "eslint": "9.0.0",
56
+ "eslint": "^8.57.0",
57
57
  "jest": "^29.7.0"
58
58
  }
59
59
  }