autotel 6.4.1 → 7.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.
Files changed (166) hide show
  1. package/README.md +30 -23
  2. package/dist/{attribute-redacting-processor-Pk7lAzWd.d.cts → attribute-redacting-processor-CvBE0z1p.d.cts} +33 -1
  3. package/dist/{attribute-redacting-processor-Pk7lAzWd.d.ts → attribute-redacting-processor-CvBE0z1p.d.ts} +33 -1
  4. package/dist/attribute-redacting-processor.cjs +34 -32
  5. package/dist/attribute-redacting-processor.d.cts +1 -1
  6. package/dist/attribute-redacting-processor.d.ts +1 -1
  7. package/dist/attribute-redacting-processor.js +35 -32
  8. package/dist/{attributes-aDmJYral.cjs → attributes-Cxys8tgr.cjs} +34 -35
  9. package/dist/{attributes-B7wix2VG.js → attributes-Dt4YUYbP.js} +34 -35
  10. package/dist/attributes.cjs +1 -1
  11. package/dist/attributes.d.cts +1 -1
  12. package/dist/attributes.d.ts +1 -1
  13. package/dist/attributes.js +1 -1
  14. package/dist/auto.cjs +1 -1
  15. package/dist/auto.js +1 -1
  16. package/dist/business-baggage.cjs +19 -12
  17. package/dist/business-baggage.d.cts +8 -3
  18. package/dist/business-baggage.d.ts +8 -3
  19. package/dist/business-baggage.js +19 -12
  20. package/dist/{canonical-log-line-processor-DxtBGZIi.cjs → canonical-log-line-processor-DolzdawH.cjs} +43 -32
  21. package/dist/{canonical-log-line-processor-B4WgG-VS.d.cts → canonical-log-line-processor-cPB4Axk-.d.ts} +4 -3
  22. package/dist/{canonical-log-line-processor-B0vq_QR6.js → canonical-log-line-processor-hFUmS__K.js} +43 -32
  23. package/dist/{canonical-log-line-processor-CL_J7gb5.d.ts → canonical-log-line-processor-l0Aqe6yp.d.cts} +4 -3
  24. package/dist/config.d.cts +1 -1
  25. package/dist/config.d.ts +1 -1
  26. package/dist/{correlated-events-kSwLo3mi.cjs → correlated-events-CcuknWnU.cjs} +2 -1
  27. package/dist/{correlated-events-Bzh5y-UB.js → correlated-events-DwMMbItg.js} +3 -1
  28. package/dist/correlation-id.cjs +1 -1
  29. package/dist/correlation-id.js +1 -1
  30. package/dist/db.cjs +34 -19
  31. package/dist/db.js +34 -19
  32. package/dist/decorators.cjs +4 -2
  33. package/dist/decorators.d.cts +16 -11
  34. package/dist/decorators.d.ts +16 -11
  35. package/dist/decorators.js +4 -2
  36. package/dist/{define-event-CGG048HE.d.cts → define-event-BNeuKUPv.d.cts} +1 -1
  37. package/dist/{define-event-B2z1SBe7.d.ts → define-event-Bd8f8mST.d.ts} +1 -1
  38. package/dist/diagnostics.cjs +18 -16
  39. package/dist/diagnostics.d.cts +14 -10
  40. package/dist/diagnostics.d.ts +14 -10
  41. package/dist/diagnostics.js +18 -16
  42. package/dist/{event-subscriber-CWh8sTGh.d.cts → event-subscriber-DMACQA-1.d.cts} +19 -9
  43. package/dist/{event-subscriber-CWh8sTGh.d.ts → event-subscriber-DMACQA-1.d.ts} +19 -9
  44. package/dist/event-subscriber.d.cts +2 -2
  45. package/dist/event-subscriber.d.ts +2 -2
  46. package/dist/{event-testing-D0qWfqAy.d.cts → event-testing-CBtnJXE5.d.cts} +1 -1
  47. package/dist/{event-testing-CA2mIx1E.d.ts → event-testing-CkPgV3Ii.d.ts} +1 -1
  48. package/dist/event-testing.d.cts +1 -1
  49. package/dist/event-testing.d.ts +1 -1
  50. package/dist/event.cjs +1 -1
  51. package/dist/event.d.cts +5 -5
  52. package/dist/event.d.ts +5 -5
  53. package/dist/event.js +1 -1
  54. package/dist/exception-fingerprint.cjs +133 -0
  55. package/dist/exception-fingerprint.d.cts +51 -0
  56. package/dist/exception-fingerprint.d.ts +51 -0
  57. package/dist/exception-fingerprint.js +126 -0
  58. package/dist/{functional-AT22vCw6.d.ts → functional-CJn2zY4o.d.cts} +96 -39
  59. package/dist/{functional-e6jw5zQj.d.cts → functional-DXy1cHFF.d.ts} +96 -39
  60. package/dist/{functional-qZxRcIBp.cjs → functional-Da6Yv64r.cjs} +27 -15
  61. package/dist/{functional-0o9xSedq.js → functional-uSbNnnxK.js} +27 -15
  62. package/dist/functional.cjs +1 -1
  63. package/dist/functional.d.cts +2 -2
  64. package/dist/functional.d.ts +2 -2
  65. package/dist/functional.js +1 -1
  66. package/dist/http.cjs +11 -8
  67. package/dist/http.js +11 -8
  68. package/dist/{index-DolOVX6F.d.ts → index-CwrNAsgk.d.ts} +22 -26
  69. package/dist/{index-BPcxVucm.d.cts → index-DQHf4cNl.d.cts} +22 -26
  70. package/dist/index.cjs +41 -35
  71. package/dist/index.d.cts +45 -30
  72. package/dist/index.d.ts +45 -30
  73. package/dist/index.js +41 -35
  74. package/dist/{init-CsODvlau.d.ts → init-BgnYi2sm.d.ts} +94 -90
  75. package/dist/{init-BnxHAi2M.cjs → init-D4m5rCmD.cjs} +142 -123
  76. package/dist/{init-Cc7-vvzj.d.cts → init-DrlL1eis.d.cts} +94 -90
  77. package/dist/{init-BxfZ3Vbw.js → init-JtX-KKz_.js} +137 -124
  78. package/dist/instrumentation.cjs +2 -2
  79. package/dist/instrumentation.js +2 -2
  80. package/dist/{logger-D3Ej3DII.js → logger-DdPp__xW.js} +63 -54
  81. package/dist/{logger-CN4xpzMd.d.cts → logger-S1Fgl0g3.d.cts} +0 -20
  82. package/dist/{logger-CN4xpzMd.d.ts → logger-S1Fgl0g3.d.ts} +0 -20
  83. package/dist/{logger-thMPLpOG.cjs → logger-Sm66cjKl.cjs} +63 -54
  84. package/dist/logger.cjs +1 -1
  85. package/dist/logger.d.cts +1 -1
  86. package/dist/logger.d.ts +1 -1
  87. package/dist/logger.js +1 -1
  88. package/dist/messaging-adapters.cjs +26 -12
  89. package/dist/messaging-adapters.d.cts +0 -30
  90. package/dist/messaging-adapters.d.ts +0 -30
  91. package/dist/messaging-adapters.js +26 -12
  92. package/dist/messaging.cjs +37 -34
  93. package/dist/messaging.d.cts +21 -62
  94. package/dist/messaging.d.ts +21 -62
  95. package/dist/messaging.js +37 -34
  96. package/dist/{metric-testing-CpvP3ZIa.d.cts → metric-testing-86WO1wan.d.cts} +1 -1
  97. package/dist/{metric-testing-CWm6UhaR.d.ts → metric-testing-CbCxdPBp.d.ts} +1 -1
  98. package/dist/metric-testing.d.cts +1 -1
  99. package/dist/metric-testing.d.ts +1 -1
  100. package/dist/metric.d.cts +3 -3
  101. package/dist/metric.d.ts +3 -3
  102. package/dist/{node-require-vROmTeJ8.js → node-require-DSPjaw_l.js} +3 -2
  103. package/dist/{node-require-PFqDihze.cjs → node-require-EifOMikz.cjs} +3 -2
  104. package/dist/parse-error.cjs +18 -12
  105. package/dist/parse-error.d.cts +2 -1
  106. package/dist/parse-error.d.ts +2 -1
  107. package/dist/parse-error.js +19 -12
  108. package/dist/policy.cjs +0 -0
  109. package/dist/policy.js +0 -0
  110. package/dist/processors.cjs +1 -1
  111. package/dist/processors.d.cts +1 -1
  112. package/dist/processors.d.ts +1 -1
  113. package/dist/processors.js +1 -1
  114. package/dist/{sampling-BR9fkSwx.d.cts → sampling-CM5S2Lp3.d.ts} +5 -6
  115. package/dist/{sampling-CP3e7-Yr.d.ts → sampling-CmRdnXUi.d.cts} +5 -6
  116. package/dist/sampling.cjs +3 -2
  117. package/dist/sampling.d.cts +1 -1
  118. package/dist/sampling.d.ts +1 -1
  119. package/dist/sampling.js +3 -2
  120. package/dist/semantic-helpers.cjs +9 -9
  121. package/dist/semantic-helpers.d.cts +1 -1
  122. package/dist/semantic-helpers.d.ts +1 -1
  123. package/dist/semantic-helpers.js +9 -9
  124. package/dist/{stable-hash-ChFBIhNt.js → stable-hash-BkoAYVks.js} +4 -3
  125. package/dist/{stable-hash-CS9BxvVQ.cjs → stable-hash-C0pOegH_.cjs} +4 -3
  126. package/dist/{structured-error-CHg7DoIQ.cjs → structured-error--_wXpd_C.cjs} +34 -25
  127. package/dist/{structured-error-9--cxBay.js → structured-error-YIuka-FE.js} +34 -25
  128. package/dist/test-span-collector.cjs +15 -8
  129. package/dist/test-span-collector.js +15 -8
  130. package/dist/testing.cjs +16 -18
  131. package/dist/testing.d.cts +7 -6
  132. package/dist/testing.d.ts +7 -6
  133. package/dist/testing.js +16 -18
  134. package/dist/{trace-context-IuyoPyNq.d.cts → trace-context-C1Cn1q0y.d.cts} +8 -7
  135. package/dist/{trace-context-IuyoPyNq.d.ts → trace-context-f89xPJbK.d.ts} +8 -7
  136. package/dist/trace-helpers.cjs +16 -13
  137. package/dist/trace-helpers.d.cts +9 -4
  138. package/dist/trace-helpers.d.ts +9 -4
  139. package/dist/trace-helpers.js +16 -13
  140. package/dist/tracer-provider.cjs +8 -12
  141. package/dist/tracer-provider.js +8 -12
  142. package/dist/validate.cjs +22 -20
  143. package/dist/validate.d.cts +3 -2
  144. package/dist/validate.d.ts +3 -2
  145. package/dist/validate.js +22 -20
  146. package/dist/values-BenyvWKz.js +141 -0
  147. package/dist/values-CeMH-mYG.d.cts +8 -0
  148. package/dist/values-CeMH-mYG.d.ts +8 -0
  149. package/dist/values-DApyq53y.cjs +267 -0
  150. package/dist/webhook.cjs +3 -3
  151. package/dist/webhook.d.cts +1 -1
  152. package/dist/webhook.d.ts +1 -1
  153. package/dist/webhook.js +3 -3
  154. package/dist/workflow-distributed.cjs +9 -7
  155. package/dist/workflow-distributed.d.cts +9 -8
  156. package/dist/workflow-distributed.d.ts +9 -8
  157. package/dist/workflow-distributed.js +9 -7
  158. package/dist/workflow.cjs +26 -17
  159. package/dist/workflow.d.cts +1 -28
  160. package/dist/workflow.d.ts +1 -28
  161. package/dist/workflow.js +26 -17
  162. package/dist/yaml-config.cjs +26 -11
  163. package/dist/yaml-config.d.cts +9 -3
  164. package/dist/yaml-config.d.ts +9 -3
  165. package/dist/yaml-config.js +26 -11
  166. package/package.json +6 -1
package/README.md CHANGED
@@ -237,9 +237,9 @@ export const createUser = trace(async function createUser(
237
237
 
238
238
  - Named function expressions automatically become span names (`code.function`).
239
239
  - Errors are recorded, spans are ended, and status is set automatically.
240
- - When inference may be unreliable, use `trace('user.create', fn)` or
241
- `instrument({ key: 'user.create', fn })`. For a module-sized batch, use
242
- `instrument({ functions: { createUser, updateUser } })`.
240
+ - When inference may be unreliable, name the wrapper explicitly with
241
+ `trace('user.create', fn)` or `instrument({ key: 'user.create', fn })`. For a
242
+ module-sized batch, use `instrument({ functions: { createUser, updateUser } })`.
243
243
 
244
244
  ### 4. See the value everywhere
245
245
 
@@ -553,7 +553,7 @@ These use the `autotel.*` namespace intentionally. OpenTelemetry does not define
553
553
  Wrap any sync/async function to create spans automatically.
554
554
 
555
555
  ```typescript
556
- import { trace, span, withTracing } from 'autotel';
556
+ import { trace, span, instrument, withTracing } from 'autotel';
557
557
 
558
558
  export const updateUser = trace(async function updateUser(
559
559
  id: string,
@@ -563,8 +563,9 @@ export const updateUser = trace(async function updateUser(
563
563
  });
564
564
 
565
565
  // Explicit name (useful for anonymous/arrow functions)
566
- export const deleteUser = trace('user.delete', async (id: string) => {
567
- return db.users.delete(id);
566
+ export const deleteUser = instrument({
567
+ key: 'user.delete',
568
+ fn: async (id: string) => db.users.delete(id),
568
569
  });
569
570
 
570
571
  // Explicit factory form exposes the `ctx` helper
@@ -575,19 +576,22 @@ export const createOrder = withTracing({ name: 'order.create' })(
575
576
  },
576
577
  );
577
578
 
578
- // For one-off work, create the wrapper and call it
579
+ // For one-off work, run a named operation directly
579
580
  function timed<T>(operation: string, fn: () => Promise<T>): Promise<T> {
580
- return trace(operation, async () => {
581
- getActiveTraceContext()?.setAttribute('operation', operation);
581
+ return trace(operation, async (ctx) => {
582
+ ctx.setAttribute('operation', operation);
582
583
  return await fn();
583
- })();
584
+ });
584
585
  }
585
586
  ```
586
587
 
587
588
  **Context access:**
588
589
 
589
- 1. Plain `trace(name?, fn)` wrappers receive their real arguments; use `getActiveTraceContext()` inside.
590
- 2. Explicit factories use `withTracing({ name })(ctx => (...args) => result)`.
590
+ 1. Plain `trace(fn)` wrappers receive their real arguments; use `getActiveTraceContext()` inside.
591
+ 2. Reusable named wrappers use `trace(name, fn)` or `instrument({ key, fn })`; explicit factories use `withTracing({ name })(ctx => (...args) => result)`.
592
+ 3. `trace.run(name, ctx => result)` runs one operation immediately with explicit context.
593
+
594
+ **`trace` wraps, `trace.run` runs.** No `trace(...)` form executes your function, so importing a module of them has no side effects. Reach the span inside any traced body through the ambient `ctx` import.
591
595
 
592
596
  - Automatic span lifecycle (`start`, `end`, status, and error recording).
593
597
  - Function names feed `operation.name`, `code.function`, and events enrichment.
@@ -1528,20 +1532,23 @@ Track user behavior, conversion funnels, and business outcomes alongside your Op
1528
1532
  **Recommended: Configure subscribers in `init()`, use global `track()` function:**
1529
1533
 
1530
1534
  ```typescript
1531
- import { init, track, trace, span, withTracing } from 'autotel';
1532
- import { PostHogSubscriber } from 'autotel-subscribers/posthog';
1535
+ import { init, instrument, track } from 'autotel';
1536
+ import { PostHogSubscriber } from 'autotel-posthog/subscriber';
1533
1537
 
1534
1538
  init({
1535
1539
  service: 'checkout',
1536
1540
  subscribers: [new PostHogSubscriber({ apiKey: process.env.POSTHOG_KEY! })],
1537
1541
  });
1538
1542
 
1539
- export const signup = trace('user.signup', async (user) => {
1540
- // All events use subscribers from init() automatically
1541
- track('user.signup', { userId: user.id, plan: user.plan });
1542
- track.funnelStep('checkout', 'completed', { cartValue: user.cartTotal });
1543
- track.value('lifetimeValue', user.cartTotal, { currency: 'USD' });
1544
- track.outcome('user.signup', 'success', { cohort: user.cohort });
1543
+ export const signup = instrument({
1544
+ key: 'user.signup',
1545
+ fn: async (user) => {
1546
+ // All events use subscribers from init() automatically
1547
+ track('user.signup', { userId: user.id, plan: user.plan });
1548
+ track.funnelStep('checkout', 'completed', { cartValue: user.cartTotal });
1549
+ track.value('lifetimeValue', user.cartTotal, { currency: 'USD' });
1550
+ track.outcome('user.signup', 'success', { cohort: user.cohort });
1551
+ },
1545
1552
  });
1546
1553
  ```
1547
1554
 
@@ -2240,7 +2247,7 @@ Configure event subscribers globally to send product events to PostHog, Mixpanel
2240
2247
 
2241
2248
  ```typescript
2242
2249
  import { init } from 'autotel';
2243
- import { PostHogSubscriber } from 'autotel-subscribers/posthog';
2250
+ import { PostHogSubscriber } from 'autotel-posthog/subscriber';
2244
2251
 
2245
2252
  init({
2246
2253
  service: 'my-app',
@@ -2735,10 +2742,10 @@ export default wrapModule(
2735
2742
  ## API Reference
2736
2743
 
2737
2744
  - `init(config)` : Bootstraps the SDK (call once).
2738
- - `trace(fn | name, fn)` : Wraps functions with spans and optional context access.
2745
+ - `trace(fn)` wraps a reusable inferred-name function; `trace(name, fn)` wraps under an explicit name; `trace.run(name, ctx => result)` runs named work immediately.
2739
2746
  - `span(options, fn)` : Creates nested spans for ad-hoc blocks.
2740
2747
  - `withTracing(options)` : Produces reusable wrappers with shared configuration.
2741
- - `instrument(target, options)` : Batch-wraps an object of functions.
2748
+ - `instrument({ key, fn })` is the options form of `trace(name, fn)`; `instrument({ functions })` batch-wraps a module.
2742
2749
  - `Trace` decorator : Adds tracing to class methods (TypeScript 5+).
2743
2750
  - `instrumentDatabase(db, options)` : Adds automatic DB spans (Drizzle, etc.).
2744
2751
  - `Metric` class & helpers (`createHistogram`, etc.) : Emit OpenTelemetry metrics.
@@ -121,7 +121,39 @@ declare const builtinPatterns: {
121
121
  /**
122
122
  * Built-in redactor presets
123
123
  */
124
- declare const REDACTOR_PRESETS: Record<AttributeRedactorPreset, AttributeRedactorConfig>;
124
+ declare const REDACTOR_PRESETS: {
125
+ /**
126
+ * Default preset - covers common PII patterns with smart masking
127
+ * Detects: emails (a***@***.com), phone numbers, SSNs, credit cards (****1111)
128
+ * Redacts keys: password, secret, token, apiKey, auth, credential
129
+ */
130
+ default: {
131
+ keyPatterns: RegExp[];
132
+ valuePatterns: ValuePatternConfig[];
133
+ builtins: true;
134
+ replacement: string;
135
+ };
136
+ /**
137
+ * Strict preset - more aggressive redaction for high-security environments
138
+ * Includes everything in default plus: Bearer tokens, JWTs, IBAN, API keys in values
139
+ */
140
+ strict: {
141
+ keyPatterns: RegExp[];
142
+ valuePatterns: ValuePatternConfig[];
143
+ builtins: true;
144
+ replacement: string;
145
+ };
146
+ /**
147
+ * PCI-DSS preset - focused on payment card industry compliance
148
+ * Redacts: credit card numbers (****1111), CVV-like patterns, card-related keys
149
+ */
150
+ 'pci-dss': {
151
+ keyPatterns: RegExp[];
152
+ valuePatterns: ValuePatternConfig[];
153
+ builtins: "creditCard"[];
154
+ replacement: string;
155
+ };
156
+ };
125
157
  /**
126
158
  * Normalize redactor config that may have been deserialized from JSON/YAML.
127
159
  * Converts regex-like values back to RegExp instances.
@@ -121,7 +121,39 @@ declare const builtinPatterns: {
121
121
  /**
122
122
  * Built-in redactor presets
123
123
  */
124
- declare const REDACTOR_PRESETS: Record<AttributeRedactorPreset, AttributeRedactorConfig>;
124
+ declare const REDACTOR_PRESETS: {
125
+ /**
126
+ * Default preset - covers common PII patterns with smart masking
127
+ * Detects: emails (a***@***.com), phone numbers, SSNs, credit cards (****1111)
128
+ * Redacts keys: password, secret, token, apiKey, auth, credential
129
+ */
130
+ default: {
131
+ keyPatterns: RegExp[];
132
+ valuePatterns: ValuePatternConfig[];
133
+ builtins: true;
134
+ replacement: string;
135
+ };
136
+ /**
137
+ * Strict preset - more aggressive redaction for high-security environments
138
+ * Includes everything in default plus: Bearer tokens, JWTs, IBAN, API keys in values
139
+ */
140
+ strict: {
141
+ keyPatterns: RegExp[];
142
+ valuePatterns: ValuePatternConfig[];
143
+ builtins: true;
144
+ replacement: string;
145
+ };
146
+ /**
147
+ * PCI-DSS preset - focused on payment card industry compliance
148
+ * Redacts: credit card numbers (****1111), CVV-like patterns, card-related keys
149
+ */
150
+ 'pci-dss': {
151
+ keyPatterns: RegExp[];
152
+ valuePatterns: ValuePatternConfig[];
153
+ builtins: "creditCard"[];
154
+ replacement: string;
155
+ };
156
+ };
125
157
  /**
126
158
  * Normalize redactor config that may have been deserialized from JSON/YAML.
127
159
  * Converts regex-like values back to RegExp instances.
@@ -1,4 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_values = require('./values-DApyq53y.cjs');
2
3
 
3
4
  //#region src/attribute-redacting-processor.ts
4
5
  /**
@@ -82,16 +83,12 @@ const builtinPatterns = {
82
83
  function cloneRegex(re) {
83
84
  return new RegExp(re.source, re.flags);
84
85
  }
85
- function isPlainObject(value) {
86
- return value !== null && typeof value === "object" && !Array.isArray(value);
87
- }
88
86
  function toRegExp(value) {
89
87
  if (value instanceof RegExp) return value;
90
- if (typeof value === "string") return new RegExp(value, "g");
91
- if (isPlainObject(value) && typeof value.source === "string") {
92
- const flags = typeof value.flags === "string" ? value.flags : "g";
93
- return new RegExp(value.source, flags);
94
- }
88
+ const literal = require_values.asString(value);
89
+ if (literal !== void 0) return new RegExp(literal, "g");
90
+ const source = require_values.asString(require_values.readProperty(value, "source"));
91
+ return source === void 0 ? void 0 : new RegExp(source, require_values.asString(require_values.readProperty(value, "flags")) ?? "g");
95
92
  }
96
93
  function toRegExpArray(value) {
97
94
  if (!Array.isArray(value)) return void 0;
@@ -184,29 +181,34 @@ const REDACTOR_PRESETS = {
184
181
  */
185
182
  function normalizeAttributeRedactorConfig(raw) {
186
183
  if (raw === void 0 || raw === null) return void 0;
187
- if (typeof raw === "string") return raw;
188
- if (!isPlainObject(raw)) return void 0;
184
+ const presetName = require_values.asString(raw);
185
+ if (presetName !== void 0) return presetName;
186
+ const record = require_values.asRecord(raw);
187
+ if (!record) return void 0;
189
188
  const config = {};
190
- if (Array.isArray(raw.paths)) config.paths = raw.paths.filter((value) => typeof value === "string");
191
- if (typeof raw.replacement === "string") config.replacement = raw.replacement;
192
- if (typeof raw.builtins === "boolean") config.builtins = raw.builtins;
193
- else if (Array.isArray(raw.builtins)) config.builtins = raw.builtins.filter((name) => typeof name === "string");
194
- if (typeof raw.redactor === "function") config.redactor = raw.redactor;
195
- const keyPatterns = toRegExpArray(raw.keyPatterns);
189
+ if (Array.isArray(record.paths)) config.paths = record.paths.filter((value) => require_values.asString(value) !== void 0);
190
+ const replacement = require_values.asString(record.replacement);
191
+ if (replacement !== void 0) config.replacement = replacement;
192
+ const builtins = require_values.asBoolean(record.builtins);
193
+ if (builtins !== void 0) config.builtins = builtins;
194
+ else if (Array.isArray(record.builtins)) config.builtins = record.builtins.filter((name) => require_values.asString(name) !== void 0);
195
+ if (require_values.isFunction(record.redactor)) config.redactor = record.redactor;
196
+ const keyPatterns = toRegExpArray(record.keyPatterns);
196
197
  if (keyPatterns) config.keyPatterns = keyPatterns;
197
- const patterns = toRegExpArray(raw.patterns);
198
+ const patterns = toRegExpArray(record.patterns);
198
199
  if (patterns) config.patterns = patterns;
199
- if (Array.isArray(raw.valuePatterns)) {
200
+ if (Array.isArray(record.valuePatterns)) {
200
201
  const valuePatterns = [];
201
- for (const item of raw.valuePatterns) {
202
- if (!isPlainObject(item) || typeof item.name !== "string") continue;
203
- const pattern = toRegExp(item.pattern);
204
- if (!pattern) continue;
202
+ for (const entry of record.valuePatterns) {
203
+ const item = require_values.asRecord(entry);
204
+ const name = require_values.asString(item?.name);
205
+ const pattern = toRegExp(item?.pattern);
206
+ if (!item || name === void 0 || !pattern) continue;
205
207
  valuePatterns.push({
206
- name: item.name,
208
+ name,
207
209
  pattern,
208
- replacement: typeof item.replacement === "string" ? item.replacement : void 0,
209
- mask: typeof item.mask === "function" ? item.mask : void 0
210
+ replacement: require_values.asString(item.replacement),
211
+ mask: require_values.isFunction(item.mask) ? item.mask : void 0
210
212
  });
211
213
  }
212
214
  config.valuePatterns = valuePatterns;
@@ -250,21 +252,22 @@ function createRedactorFromConfig(config) {
250
252
  const defaultReplacement = config.replacement ?? "[REDACTED]";
251
253
  const maskers = valuePatterns.filter((vp) => vp.mask).map((vp) => [cloneRegex(vp.pattern), vp.mask]);
252
254
  return (key, value) => {
253
- if (typeof value === "string") {
255
+ const text = require_values.asString(value);
256
+ if (text !== void 0) {
254
257
  for (const pattern of keyPatterns) {
255
258
  pattern.lastIndex = 0;
256
259
  if (pattern.test(key)) return defaultReplacement;
257
260
  }
258
261
  if (pathSet.has(key)) return defaultReplacement;
259
262
  }
260
- if (typeof value !== "string") {
263
+ if (text === void 0) {
261
264
  if (Array.isArray(value)) return value.map((item) => {
262
- if (typeof item === "string") return redactStringValue(item, valuePatterns, maskers, customPatterns, defaultReplacement);
263
- return item;
265
+ const itemText = require_values.asString(item);
266
+ return itemText === void 0 ? item : redactStringValue(itemText, valuePatterns, maskers, customPatterns, defaultReplacement);
264
267
  });
265
268
  return value;
266
269
  }
267
- return redactStringValue(value, valuePatterns, maskers, customPatterns, defaultReplacement);
270
+ return redactStringValue(text, valuePatterns, maskers, customPatterns, defaultReplacement);
268
271
  };
269
272
  }
270
273
  /**
@@ -301,8 +304,7 @@ function createRedactedSpan(span, redactor) {
301
304
  return new Proxy(span, { get(target, prop) {
302
305
  if (prop === "attributes") return redactedAttributes;
303
306
  const value = Reflect.get(target, prop);
304
- if (typeof value === "function") return value.bind(target);
305
- return value;
307
+ return require_values.isFunction(value) ? value.bind(target) : value;
306
308
  } });
307
309
  }
308
310
  /**
@@ -1,2 +1,2 @@
1
- import { a as AttributeRedactorPreset, c as REDACTOR_PATTERNS, d as builtinPatterns, f as createAttributeRedactor, i as AttributeRedactorFn, l as REDACTOR_PRESETS, m as normalizeAttributeRedactorConfig, n as AttributeRedactingProcessorOptions, o as BuiltinPatternName, p as createRedactedSpan, r as AttributeRedactorConfig, s as MaskFn, t as AttributeRedactingProcessor, u as ValuePatternConfig } from "./attribute-redacting-processor-Pk7lAzWd.cjs";
1
+ import { a as AttributeRedactorPreset, c as REDACTOR_PATTERNS, d as builtinPatterns, f as createAttributeRedactor, i as AttributeRedactorFn, l as REDACTOR_PRESETS, m as normalizeAttributeRedactorConfig, n as AttributeRedactingProcessorOptions, o as BuiltinPatternName, p as createRedactedSpan, r as AttributeRedactorConfig, s as MaskFn, t as AttributeRedactingProcessor, u as ValuePatternConfig } from "./attribute-redacting-processor-CvBE0z1p.cjs";
2
2
  export { AttributeRedactingProcessor, AttributeRedactingProcessorOptions, AttributeRedactorConfig, AttributeRedactorFn, AttributeRedactorPreset, BuiltinPatternName, MaskFn, REDACTOR_PATTERNS, REDACTOR_PRESETS, ValuePatternConfig, builtinPatterns, createAttributeRedactor, createRedactedSpan, normalizeAttributeRedactorConfig };
@@ -1,2 +1,2 @@
1
- import { a as AttributeRedactorPreset, c as REDACTOR_PATTERNS, d as builtinPatterns, f as createAttributeRedactor, i as AttributeRedactorFn, l as REDACTOR_PRESETS, m as normalizeAttributeRedactorConfig, n as AttributeRedactingProcessorOptions, o as BuiltinPatternName, p as createRedactedSpan, r as AttributeRedactorConfig, s as MaskFn, t as AttributeRedactingProcessor, u as ValuePatternConfig } from "./attribute-redacting-processor-Pk7lAzWd.js";
1
+ import { a as AttributeRedactorPreset, c as REDACTOR_PATTERNS, d as builtinPatterns, f as createAttributeRedactor, i as AttributeRedactorFn, l as REDACTOR_PRESETS, m as normalizeAttributeRedactorConfig, n as AttributeRedactingProcessorOptions, o as BuiltinPatternName, p as createRedactedSpan, r as AttributeRedactorConfig, s as MaskFn, t as AttributeRedactingProcessor, u as ValuePatternConfig } from "./attribute-redacting-processor-CvBE0z1p.js";
2
2
  export { AttributeRedactingProcessor, AttributeRedactingProcessorOptions, AttributeRedactorConfig, AttributeRedactorFn, AttributeRedactorPreset, BuiltinPatternName, MaskFn, REDACTOR_PATTERNS, REDACTOR_PRESETS, ValuePatternConfig, builtinPatterns, createAttributeRedactor, createRedactedSpan, normalizeAttributeRedactorConfig };
@@ -1,3 +1,5 @@
1
+ import { _ as readProperty, h as isFunction, l as asString, s as asRecord, t as asBoolean } from "./values-BenyvWKz.js";
2
+
1
3
  //#region src/attribute-redacting-processor.ts
2
4
  /**
3
5
  * Built-in patterns for detecting sensitive data
@@ -80,16 +82,12 @@ const builtinPatterns = {
80
82
  function cloneRegex(re) {
81
83
  return new RegExp(re.source, re.flags);
82
84
  }
83
- function isPlainObject(value) {
84
- return value !== null && typeof value === "object" && !Array.isArray(value);
85
- }
86
85
  function toRegExp(value) {
87
86
  if (value instanceof RegExp) return value;
88
- if (typeof value === "string") return new RegExp(value, "g");
89
- if (isPlainObject(value) && typeof value.source === "string") {
90
- const flags = typeof value.flags === "string" ? value.flags : "g";
91
- return new RegExp(value.source, flags);
92
- }
87
+ const literal = asString(value);
88
+ if (literal !== void 0) return new RegExp(literal, "g");
89
+ const source = asString(readProperty(value, "source"));
90
+ return source === void 0 ? void 0 : new RegExp(source, asString(readProperty(value, "flags")) ?? "g");
93
91
  }
94
92
  function toRegExpArray(value) {
95
93
  if (!Array.isArray(value)) return void 0;
@@ -182,29 +180,34 @@ const REDACTOR_PRESETS = {
182
180
  */
183
181
  function normalizeAttributeRedactorConfig(raw) {
184
182
  if (raw === void 0 || raw === null) return void 0;
185
- if (typeof raw === "string") return raw;
186
- if (!isPlainObject(raw)) return void 0;
183
+ const presetName = asString(raw);
184
+ if (presetName !== void 0) return presetName;
185
+ const record = asRecord(raw);
186
+ if (!record) return void 0;
187
187
  const config = {};
188
- if (Array.isArray(raw.paths)) config.paths = raw.paths.filter((value) => typeof value === "string");
189
- if (typeof raw.replacement === "string") config.replacement = raw.replacement;
190
- if (typeof raw.builtins === "boolean") config.builtins = raw.builtins;
191
- else if (Array.isArray(raw.builtins)) config.builtins = raw.builtins.filter((name) => typeof name === "string");
192
- if (typeof raw.redactor === "function") config.redactor = raw.redactor;
193
- const keyPatterns = toRegExpArray(raw.keyPatterns);
188
+ if (Array.isArray(record.paths)) config.paths = record.paths.filter((value) => asString(value) !== void 0);
189
+ const replacement = asString(record.replacement);
190
+ if (replacement !== void 0) config.replacement = replacement;
191
+ const builtins = asBoolean(record.builtins);
192
+ if (builtins !== void 0) config.builtins = builtins;
193
+ else if (Array.isArray(record.builtins)) config.builtins = record.builtins.filter((name) => asString(name) !== void 0);
194
+ if (isFunction(record.redactor)) config.redactor = record.redactor;
195
+ const keyPatterns = toRegExpArray(record.keyPatterns);
194
196
  if (keyPatterns) config.keyPatterns = keyPatterns;
195
- const patterns = toRegExpArray(raw.patterns);
197
+ const patterns = toRegExpArray(record.patterns);
196
198
  if (patterns) config.patterns = patterns;
197
- if (Array.isArray(raw.valuePatterns)) {
199
+ if (Array.isArray(record.valuePatterns)) {
198
200
  const valuePatterns = [];
199
- for (const item of raw.valuePatterns) {
200
- if (!isPlainObject(item) || typeof item.name !== "string") continue;
201
- const pattern = toRegExp(item.pattern);
202
- if (!pattern) continue;
201
+ for (const entry of record.valuePatterns) {
202
+ const item = asRecord(entry);
203
+ const name = asString(item?.name);
204
+ const pattern = toRegExp(item?.pattern);
205
+ if (!item || name === void 0 || !pattern) continue;
203
206
  valuePatterns.push({
204
- name: item.name,
207
+ name,
205
208
  pattern,
206
- replacement: typeof item.replacement === "string" ? item.replacement : void 0,
207
- mask: typeof item.mask === "function" ? item.mask : void 0
209
+ replacement: asString(item.replacement),
210
+ mask: isFunction(item.mask) ? item.mask : void 0
208
211
  });
209
212
  }
210
213
  config.valuePatterns = valuePatterns;
@@ -248,21 +251,22 @@ function createRedactorFromConfig(config) {
248
251
  const defaultReplacement = config.replacement ?? "[REDACTED]";
249
252
  const maskers = valuePatterns.filter((vp) => vp.mask).map((vp) => [cloneRegex(vp.pattern), vp.mask]);
250
253
  return (key, value) => {
251
- if (typeof value === "string") {
254
+ const text = asString(value);
255
+ if (text !== void 0) {
252
256
  for (const pattern of keyPatterns) {
253
257
  pattern.lastIndex = 0;
254
258
  if (pattern.test(key)) return defaultReplacement;
255
259
  }
256
260
  if (pathSet.has(key)) return defaultReplacement;
257
261
  }
258
- if (typeof value !== "string") {
262
+ if (text === void 0) {
259
263
  if (Array.isArray(value)) return value.map((item) => {
260
- if (typeof item === "string") return redactStringValue(item, valuePatterns, maskers, customPatterns, defaultReplacement);
261
- return item;
264
+ const itemText = asString(item);
265
+ return itemText === void 0 ? item : redactStringValue(itemText, valuePatterns, maskers, customPatterns, defaultReplacement);
262
266
  });
263
267
  return value;
264
268
  }
265
- return redactStringValue(value, valuePatterns, maskers, customPatterns, defaultReplacement);
269
+ return redactStringValue(text, valuePatterns, maskers, customPatterns, defaultReplacement);
266
270
  };
267
271
  }
268
272
  /**
@@ -299,8 +303,7 @@ function createRedactedSpan(span, redactor) {
299
303
  return new Proxy(span, { get(target, prop) {
300
304
  if (prop === "attributes") return redactedAttributes;
301
305
  const value = Reflect.get(target, prop);
302
- if (typeof value === "function") return value.bind(target);
303
- return value;
306
+ return isFunction(value) ? value.bind(target) : value;
304
307
  } });
305
308
  }
306
309
  /**
@@ -1,3 +1,4 @@
1
+ const require_values = require('./values-DApyq53y.cjs');
1
2
  const require_attribute_redacting_processor = require('./attribute-redacting-processor.cjs');
2
3
  const require_registry = require('./registry-DYgvb62e.cjs');
3
4
  let _opentelemetry_resources = require("@opentelemetry/resources");
@@ -330,34 +331,34 @@ const attrs = {
330
331
  //#endregion
331
332
  //#region src/attributes/validators.ts
332
333
  /**
333
- * Attribute validation, PII detection, and guardrails
334
- * Provides safe-by-default attribute handling with configurable policies
334
+ * Attributes OpenTelemetry has renamed, mapped to their replacement - or to
335
+ * `null` where the convention dropped them outright.
335
336
  */
336
- const DEPRECATED_ATTRIBUTES = {
337
- "enduser.id": "user.id",
338
- "enduser.role": "user.roles",
339
- "enduser.scope": void 0,
340
- "http.method": "http.request.method",
341
- "http.host": "server.address",
342
- "http.status_code": "http.response.status_code",
343
- "http.target": "url.path",
344
- "http.url": "url.full",
345
- "http.user_agent": "user_agent.original",
346
- "http.flavor": "network.protocol.name",
347
- "http.scheme": "url.scheme",
348
- "http.server_name": "server.address",
349
- "db.name": "db.namespace",
350
- "db.operation": "db.operation.name",
351
- "db.statement": "db.query.text",
352
- "db.system": "db.system.name",
353
- "db.collection": "db.collection.name",
354
- "db.instance.id": void 0,
355
- "db.jdbc.driver_classname": void 0,
356
- "db.mssql.instance_name": "mssql.instance.name",
357
- "db.sql.table": "db.collection.name",
358
- "http.client_ip": "client.address",
359
- "user_agent.original": "user_agent.original"
360
- };
337
+ const DEPRECATED_ATTRIBUTES = /* @__PURE__ */ new Map([
338
+ ["enduser.id", "user.id"],
339
+ ["enduser.role", "user.roles"],
340
+ ["enduser.scope", null],
341
+ ["http.method", "http.request.method"],
342
+ ["http.host", "server.address"],
343
+ ["http.status_code", "http.response.status_code"],
344
+ ["http.target", "url.path"],
345
+ ["http.url", "url.full"],
346
+ ["http.user_agent", "user_agent.original"],
347
+ ["http.flavor", "network.protocol.name"],
348
+ ["http.scheme", "url.scheme"],
349
+ ["http.server_name", "server.address"],
350
+ ["db.name", "db.namespace"],
351
+ ["db.operation", "db.operation.name"],
352
+ ["db.statement", "db.query.text"],
353
+ ["db.system", "db.system.name"],
354
+ ["db.collection", "db.collection.name"],
355
+ ["db.instance.id", null],
356
+ ["db.jdbc.driver_classname", null],
357
+ ["db.mssql.instance_name", "mssql.instance.name"],
358
+ ["db.sql.table", "db.collection.name"],
359
+ ["http.client_ip", "client.address"],
360
+ ["user_agent.original", "user_agent.original"]
361
+ ]);
361
362
  const HTTP_METHODS = /* @__PURE__ */ new Set([
362
363
  "GET",
363
364
  "POST",
@@ -373,8 +374,8 @@ const HTTP_METHODS = /* @__PURE__ */ new Set([
373
374
  function validateAttribute(key, value, policy = {}) {
374
375
  const { guardrails = {} } = policy;
375
376
  if (value === void 0 || value === null) return;
376
- if (typeof value !== "string") return value;
377
- const stringValue = value;
377
+ const stringValue = require_values.asString(value);
378
+ if (stringValue === void 0) return value;
378
379
  if (guardrails.pii) {
379
380
  const piiResult = applyPIIPolicy(key, stringValue, guardrails.pii);
380
381
  if (piiResult !== stringValue) return piiResult;
@@ -443,13 +444,11 @@ function checkDeprecatedAttribute(key, policy = {}) {
443
444
  const { guardrails = {}, deprecatedWarnings = {} } = policy;
444
445
  const { warnDeprecated = true } = guardrails;
445
446
  if (!warnDeprecated) return null;
446
- if (key in DEPRECATED_ATTRIBUTES) {
447
- const replacement = DEPRECATED_ATTRIBUTES[key];
448
- if (replacement === void 0) console.warn(`[autotel/attributes] Attribute "${key}" is deprecated and has no replacement. Remove or find a replacement in OpenTelemetry semantic conventions.`);
449
- else console.warn(`[autotel/attributes] Attribute "${key}" is deprecated. Use "${replacement}" instead.`);
450
- }
447
+ const replacement = DEPRECATED_ATTRIBUTES.get(key) ?? null;
448
+ if (DEPRECATED_ATTRIBUTES.has(key)) if (replacement === null) console.warn(`[autotel/attributes] Attribute "${key}" is deprecated and has no replacement. Remove or find a replacement in OpenTelemetry semantic conventions.`);
449
+ else console.warn(`[autotel/attributes] Attribute "${key}" is deprecated. Use "${replacement}" instead.`);
451
450
  if (deprecatedWarnings[key]) console.warn(`[autotel/attributes] ${deprecatedWarnings[key]}`);
452
- return DEPRECATED_ATTRIBUTES[key] ?? null;
451
+ return replacement;
453
452
  }
454
453
  function autoRedactPII(attributes, policy = {}) {
455
454
  const { guardrails = { pii: "redact" } } = policy;