@carecard/telemetry 3.18.0 → 3.20.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/README.md CHANGED
@@ -19,7 +19,7 @@ explicit narrowing in all TypeScript-family files (`.ts`, `.tsx`, `.mts`,
19
19
  ## Install
20
20
 
21
21
  ```sh
22
- npm install @carecard/telemetry@3.17.0 --save-exact
22
+ npm install @carecard/telemetry@3.18.0 --save-exact
23
23
  ```
24
24
 
25
25
  ## Bootstrap
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carecard/telemetry",
3
- "version": "3.18.0",
3
+ "version": "3.20.0",
4
4
  "description": "Privacy-safe OpenTelemetry tracing for CareCard Node.js services",
5
5
  "main": "index.js",
6
6
  "module": "index.mjs",
@@ -31,15 +31,17 @@
31
31
  "registry": "https://registry.npmjs.org/"
32
32
  },
33
33
  "scripts": {
34
- "test": "node --test test/*.test.js test/*.test.mjs scripts/packageTaskRunner.test.mjs",
34
+ "test": "node scripts/runPackageTask.mjs test",
35
35
  "test:types": "tsc --noEmit",
36
- "test:coverage": "node --test --experimental-test-coverage --test-coverage-lines=90 --test-coverage-functions=90 --test-coverage-branches=85 test/*.test.js test/*.test.mjs",
36
+ "test:coverage": "node test/index.test.mjs",
37
37
  "test:All": "node scripts/runPackageTask.mjs test:All",
38
- "format": "prettier --write .",
39
- "format:check": "prettier --check .",
38
+ "validate:audits": "node scripts/runRepositoryAudits.mjs",
39
+ "format": "prettier --write \"**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts}\"",
40
+ "format:check": "prettier --check \"**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts}\"",
41
+ "lint-staged": "lint-staged",
40
42
  "prepare": "husky",
41
- "lint:fix": "eslint --fix .",
42
- "lint": "eslint ."
43
+ "lint:fix": "eslint . --fix --max-warnings 0",
44
+ "lint": "eslint . --max-warnings 0"
43
45
  },
44
46
  "keywords": [
45
47
  "carecard",
@@ -65,14 +67,18 @@
65
67
  "@opentelemetry/sdk-trace-node": "2.10.0"
66
68
  },
67
69
  "devDependencies": {
70
+ "@eslint/js": "9.39.5",
68
71
  "@types/node": "25.9.3",
69
- "eslint": "9.39.4",
72
+ "@typescript-eslint/parser": "8.67.0",
73
+ "eslint": "9.39.5",
74
+ "globals": "17.7.0",
70
75
  "husky": "9.1.7",
71
- "prettier": "3.8.4",
76
+ "lint-staged": "17.2.0",
77
+ "prettier": "3.9.6",
72
78
  "typescript": "6.0.3"
73
79
  },
74
80
  "overrides": {
75
- "brace-expansion": "5.0.8",
81
+ "brace-expansion": "5.0.9",
76
82
  "minimatch": "10.2.6"
77
83
  }
78
84
  }
@@ -63,7 +63,7 @@ function buildRuntime(provider, contextManager, instrumentations) {
63
63
  try {
64
64
  await provider.shutdown();
65
65
  } finally {
66
- instrumentations.forEach((instrumentation) => instrumentation.disable());
66
+ instrumentations.forEach(instrumentation => instrumentation.disable());
67
67
  contextManager.disable();
68
68
  }
69
69
  },
@@ -32,11 +32,24 @@ function isRoutineRequest(request) {
32
32
  );
33
33
  }
34
34
 
35
+ // Pattern: Normalizer - produces the bracketed URL host form for DNS, IPv4, and IPv6 inputs.
36
+ function normalizeRequestHost(requestHost) {
37
+ const host = String(requestHost || '')
38
+ .replace(/^https?:\/\//, '')
39
+ .split('/')[0];
40
+ if (host.startsWith('[') || host.split(':').length <= 2) {
41
+ return host;
42
+ }
43
+ return `[${host}]`;
44
+ }
45
+
35
46
  // Pattern: Normalizer - creates the endpoint host form without duplicating a supplied port.
36
47
  function requestHostWithPort(request) {
37
- const requestHost = request.hostname || request.host || request.origin;
38
- const normalizedHost = String(requestHost || '').replace(/^https?:\/\//, '');
39
- if (!request.port || normalizedHost.includes(':')) {
48
+ const normalizedHost = normalizeRequestHost(request.hostname || request.host || request.origin);
49
+ const hasExplicitPort = normalizedHost.startsWith('[')
50
+ ? normalizedHost.includes(']:')
51
+ : normalizedHost.includes(':');
52
+ if (!request.port || hasExplicitPort) {
40
53
  return normalizedHost;
41
54
  }
42
55
  return `${normalizedHost}:${request.port}`;
@@ -53,7 +66,7 @@ function createInstrumentations(endpointUrl) {
53
66
  return [
54
67
  new HttpInstrumentation({
55
68
  ignoreIncomingRequestHook: isRoutineRequest,
56
- ignoreOutgoingRequestHook: (request) => isExporterRequest(request, endpoint),
69
+ ignoreOutgoingRequestHook: request => isExporterRequest(request, endpoint),
57
70
  }),
58
71
  new ExpressInstrumentation(),
59
72
  new PgInstrumentation({
@@ -63,7 +76,7 @@ function createInstrumentations(endpointUrl) {
63
76
  }),
64
77
  new KafkaJsInstrumentation(),
65
78
  new UndiciInstrumentation({
66
- ignoreRequestHook: (request) => isExporterRequest(request, endpoint),
79
+ ignoreRequestHook: request => isExporterRequest(request, endpoint),
67
80
  }),
68
81
  ];
69
82
  }
@@ -67,7 +67,7 @@ function sanitizeSpanAttributes(attributes = {}) {
67
67
  }
68
68
 
69
69
  function sanitizeEvents(events = []) {
70
- return events.map((event) => ({
70
+ return events.map(event => ({
71
71
  ...event,
72
72
  name: SAFE_EVENT_NAMES.has(event.name) ? event.name : 'event',
73
73
  attributes: sanitizeExceptionAttributes(event.attributes),
@@ -80,7 +80,7 @@ function sanitizeExceptionAttributes(attributes = {}) {
80
80
  }
81
81
 
82
82
  function sanitizeLinks(links = []) {
83
- return links.map((link) => ({ ...link, attributes: {} }));
83
+ return links.map(link => ({ ...link, attributes: {} }));
84
84
  }
85
85
 
86
86
  function buildSemanticSpanName(attributes) {
@@ -67,7 +67,7 @@ async function runWithTraceparent({ spanName, traceparent }, operation) {
67
67
  validateOperation(spanName, operation);
68
68
  const tracer = trace.getTracer('@carecard/telemetry');
69
69
  const parentContext = extractParentContext(traceparent);
70
- return tracer.startActiveSpan(spanName, { kind: SpanKind.INTERNAL }, parentContext, (span) =>
70
+ return tracer.startActiveSpan(spanName, { kind: SpanKind.INTERNAL }, parentContext, span =>
71
71
  invokeOperation(span, operation),
72
72
  );
73
73
  }
@@ -31,7 +31,7 @@ function createTraceparentGetter(getter) {
31
31
  return key.toLowerCase() === TRACESTATE_HEADER ? undefined : getter.get(carrier, key);
32
32
  },
33
33
  keys(carrier) {
34
- return getter.keys(carrier).filter((key) => key.toLowerCase() !== TRACESTATE_HEADER);
34
+ return getter.keys(carrier).filter(key => key.toLowerCase() !== TRACESTATE_HEADER);
35
35
  },
36
36
  };
37
37
  }