autotel 2.25.5 → 2.26.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.
Files changed (123) hide show
  1. package/README.md +47 -1
  2. package/dist/attribute-redacting-processor.cjs +14 -6
  3. package/dist/attribute-redacting-processor.d.cts +63 -1
  4. package/dist/attribute-redacting-processor.d.ts +63 -1
  5. package/dist/attribute-redacting-processor.js +1 -1
  6. package/dist/attributes.cjs +21 -21
  7. package/dist/attributes.js +2 -2
  8. package/dist/auto.cjs +8 -8
  9. package/dist/auto.js +6 -6
  10. package/dist/{chunk-RUD7KS4R.js → chunk-3SDILILG.js} +3 -3
  11. package/dist/{chunk-RUD7KS4R.js.map → chunk-3SDILILG.js.map} +1 -1
  12. package/dist/{chunk-B33XPEKY.js → chunk-55ER2KD5.js} +4 -4
  13. package/dist/chunk-55ER2KD5.js.map +1 -0
  14. package/dist/{chunk-ITYASFHQ.cjs → chunk-563EL6O6.cjs} +153 -15
  15. package/dist/chunk-563EL6O6.cjs.map +1 -0
  16. package/dist/{chunk-EEJGUBWV.cjs → chunk-6YGUN7IY.cjs} +5 -5
  17. package/dist/{chunk-EEJGUBWV.cjs.map → chunk-6YGUN7IY.cjs.map} +1 -1
  18. package/dist/{chunk-XDKK53OL.js → chunk-A4E5AQFK.js} +3 -3
  19. package/dist/{chunk-XDKK53OL.js.map → chunk-A4E5AQFK.js.map} +1 -1
  20. package/dist/{chunk-XB2GITM5.js → chunk-BJ2XPN77.js} +3 -3
  21. package/dist/{chunk-XB2GITM5.js.map → chunk-BJ2XPN77.js.map} +1 -1
  22. package/dist/{chunk-KZEC4CHV.cjs → chunk-CEAQK2QY.cjs} +5 -5
  23. package/dist/{chunk-KZEC4CHV.cjs.map → chunk-CEAQK2QY.cjs.map} +1 -1
  24. package/dist/chunk-CMNGGTQL.cjs +349 -0
  25. package/dist/chunk-CMNGGTQL.cjs.map +1 -0
  26. package/dist/{chunk-VYA6QDNA.js → chunk-DPSA4QLA.js} +4 -2
  27. package/dist/chunk-DPSA4QLA.js.map +1 -0
  28. package/dist/{chunk-M4US3P4K.js → chunk-ER43K7ES.js} +3 -3
  29. package/dist/{chunk-M4US3P4K.js.map → chunk-ER43K7ES.js.map} +1 -1
  30. package/dist/{chunk-AZ24DJAG.cjs → chunk-FU6R566Y.cjs} +4 -4
  31. package/dist/chunk-FU6R566Y.cjs.map +1 -0
  32. package/dist/{chunk-OPTGXEVN.js → chunk-HPUGKUMZ.js} +4 -4
  33. package/dist/{chunk-OPTGXEVN.js.map → chunk-HPUGKUMZ.js.map} +1 -1
  34. package/dist/{chunk-XRBP4RYL.cjs → chunk-JKIMEPI2.cjs} +4 -4
  35. package/dist/{chunk-XRBP4RYL.cjs.map → chunk-JKIMEPI2.cjs.map} +1 -1
  36. package/dist/{chunk-I6JPSD4R.cjs → chunk-OBWXM4NN.cjs} +9 -9
  37. package/dist/{chunk-I6JPSD4R.cjs.map → chunk-OBWXM4NN.cjs.map} +1 -1
  38. package/dist/{chunk-OFPZULMQ.cjs → chunk-OC6X2VIN.cjs} +8 -8
  39. package/dist/{chunk-OFPZULMQ.cjs.map → chunk-OC6X2VIN.cjs.map} +1 -1
  40. package/dist/{chunk-QDREXAD7.js → chunk-QC5MNKVF.js} +4 -4
  41. package/dist/{chunk-QDREXAD7.js.map → chunk-QC5MNKVF.js.map} +1 -1
  42. package/dist/chunk-TDNKIHKT.js +341 -0
  43. package/dist/chunk-TDNKIHKT.js.map +1 -0
  44. package/dist/{chunk-CMUM4JQI.js → chunk-U54FTVFH.js} +3 -3
  45. package/dist/{chunk-CMUM4JQI.js.map → chunk-U54FTVFH.js.map} +1 -1
  46. package/dist/{chunk-QQLP4M6W.cjs → chunk-UTZR7P7E.cjs} +36 -36
  47. package/dist/{chunk-QQLP4M6W.cjs.map → chunk-UTZR7P7E.cjs.map} +1 -1
  48. package/dist/{chunk-7FIGORWI.cjs → chunk-VH77IPJN.cjs} +4 -2
  49. package/dist/chunk-VH77IPJN.cjs.map +1 -0
  50. package/dist/{chunk-MNBAXRVG.js → chunk-W35FVJBC.js} +144 -9
  51. package/dist/chunk-W35FVJBC.js.map +1 -0
  52. package/dist/{chunk-A5ZUL2RZ.cjs → chunk-WZOKY3PW.cjs} +13 -13
  53. package/dist/{chunk-A5ZUL2RZ.cjs.map → chunk-WZOKY3PW.cjs.map} +1 -1
  54. package/dist/{chunk-MN6PZ4AN.cjs → chunk-YEVCD6DR.cjs} +7 -7
  55. package/dist/{chunk-MN6PZ4AN.cjs.map → chunk-YEVCD6DR.cjs.map} +1 -1
  56. package/dist/{chunk-WYP6OOCT.js → chunk-YN7USLHW.js} +3 -3
  57. package/dist/{chunk-WYP6OOCT.js.map → chunk-YN7USLHW.js.map} +1 -1
  58. package/dist/decorators.cjs +7 -7
  59. package/dist/decorators.js +7 -7
  60. package/dist/event.cjs +10 -10
  61. package/dist/event.js +7 -7
  62. package/dist/functional.cjs +14 -14
  63. package/dist/functional.js +7 -7
  64. package/dist/index.cjs +214 -96
  65. package/dist/index.cjs.map +1 -1
  66. package/dist/index.d.cts +8 -2
  67. package/dist/index.d.ts +8 -2
  68. package/dist/index.js +142 -33
  69. package/dist/index.js.map +1 -1
  70. package/dist/{init-CIzpC5kZ.d.cts → init-CMuTaFAV.d.cts} +49 -1
  71. package/dist/{init-C_PiC_Su.d.ts → init-D6JfWEjL.d.ts} +49 -1
  72. package/dist/instrumentation.cjs +14 -14
  73. package/dist/instrumentation.js +6 -6
  74. package/dist/logger.cjs +8 -8
  75. package/dist/logger.js +1 -1
  76. package/dist/messaging.cjs +11 -11
  77. package/dist/messaging.js +8 -8
  78. package/dist/metric.cjs +1 -1
  79. package/dist/metric.js +1 -1
  80. package/dist/sampling.cjs +15 -15
  81. package/dist/sampling.js +2 -2
  82. package/dist/semantic-helpers.cjs +12 -12
  83. package/dist/semantic-helpers.js +8 -8
  84. package/dist/tail-sampling-processor.cjs +4 -4
  85. package/dist/tail-sampling-processor.js +3 -3
  86. package/dist/testing.cjs +1 -1
  87. package/dist/testing.js +1 -1
  88. package/dist/webhook.cjs +9 -8
  89. package/dist/webhook.cjs.map +1 -1
  90. package/dist/webhook.js +8 -7
  91. package/dist/webhook.js.map +1 -1
  92. package/dist/workflow-distributed.cjs +9 -9
  93. package/dist/workflow-distributed.js +7 -7
  94. package/dist/workflow.cjs +12 -12
  95. package/dist/workflow.js +8 -8
  96. package/dist/yaml-config.cjs +6 -6
  97. package/dist/yaml-config.d.cts +1 -1
  98. package/dist/yaml-config.d.ts +1 -1
  99. package/dist/yaml-config.js +3 -3
  100. package/package.json +41 -41
  101. package/src/attribute-redacting-processor.test.ts +81 -16
  102. package/src/attribute-redacting-processor.ts +278 -24
  103. package/src/autotel-logger.ts +2 -2
  104. package/src/devtools.ts +60 -0
  105. package/src/hook.mjs +2 -2
  106. package/src/index.ts +2 -1
  107. package/src/init.customization.test.ts +81 -0
  108. package/src/init.ts +188 -3
  109. package/src/request-logger.test.ts +266 -1
  110. package/src/request-logger.ts +115 -16
  111. package/src/shutdown.test.ts +35 -1
  112. package/src/shutdown.ts +3 -1
  113. package/src/structured-error.ts +54 -1
  114. package/dist/chunk-7FIGORWI.cjs.map +0 -1
  115. package/dist/chunk-AZ24DJAG.cjs.map +0 -1
  116. package/dist/chunk-B33XPEKY.js.map +0 -1
  117. package/dist/chunk-ELW34S4C.cjs +0 -173
  118. package/dist/chunk-ELW34S4C.cjs.map +0 -1
  119. package/dist/chunk-ITYASFHQ.cjs.map +0 -1
  120. package/dist/chunk-MNBAXRVG.js.map +0 -1
  121. package/dist/chunk-SNINLBEE.js +0 -167
  122. package/dist/chunk-SNINLBEE.js.map +0 -1
  123. package/dist/chunk-VYA6QDNA.js.map +0 -1
package/README.md CHANGED
@@ -146,8 +146,10 @@ Replace `NODE_OPTIONS` and 30+ lines of SDK boilerplate with `init()`, wrap func
146
146
 
147
147
  ```bash
148
148
  npm install autotel
149
+ npm install -D autotel-devtools # optional but recommended for local DX
149
150
  # or
150
151
  pnpm add autotel
152
+ pnpm add -D autotel-devtools
151
153
  ```
152
154
 
153
155
  ### 2. Initialize once at startup
@@ -157,7 +159,7 @@ import { init } from 'autotel';
157
159
 
158
160
  init({
159
161
  service: 'checkout-api',
160
- environment: process.env.NODE_ENV,
162
+ devtools: true,
161
163
  });
162
164
  ```
163
165
 
@@ -169,6 +171,29 @@ Defaults:
169
171
  - Version: auto-detected from `package.json`
170
172
  - Events auto-flush when the root span finishes
171
173
 
174
+ Recommended local workflow:
175
+
176
+ ```typescript
177
+ init({
178
+ service: 'checkout-api',
179
+ devtools: true,
180
+ });
181
+ ```
182
+
183
+ - `devtools: true` points traces, metrics, and logs at local `autotel-devtools`
184
+ - `devtools: { embedded: true }` tries to start `autotel-devtools` for you
185
+ - when you switch to a hosted backend, replace `devtools` with `endpoint` and optional `headers`
186
+
187
+ Example remote backend config:
188
+
189
+ ```typescript
190
+ init({
191
+ service: 'checkout-api',
192
+ endpoint: process.env.OTEL_EXPORTER_OTLP_ENDPOINT,
193
+ headers: process.env.OTEL_EXPORTER_OTLP_HEADERS,
194
+ });
195
+ ```
196
+
172
197
  Sampling presets:
173
198
 
174
199
  - Simple path: `sampling: 'development' | 'errors-only' | 'production' | 'off'`
@@ -1978,6 +2003,14 @@ OTLP_ENDPOINT=https://otel.mycompany.com node server.js
1978
2003
  init({
1979
2004
  service: string; // required
1980
2005
  subscribers?: EventSubscriber[];
2006
+ devtools?: boolean | {
2007
+ enabled?: boolean;
2008
+ endpoint?: string;
2009
+ embedded?: boolean;
2010
+ host?: string;
2011
+ port?: number;
2012
+ verbose?: boolean;
2013
+ };
1981
2014
  endpoint?: string;
1982
2015
  protocol?: 'http' | 'grpc'; // OTLP protocol (default: 'http')
1983
2016
  metrics?: boolean | 'auto';
@@ -2006,6 +2039,19 @@ init({
2006
2039
  });
2007
2040
  ```
2008
2041
 
2042
+ Local-first recommendation:
2043
+
2044
+ ```typescript
2045
+ init({
2046
+ service: 'my-app',
2047
+ devtools: true,
2048
+ });
2049
+ ```
2050
+
2051
+ - `devtools: true` routes traces, metrics, and logs to local `autotel-devtools`
2052
+ - `devtools: { embedded: true }` attempts to start `autotel-devtools` automatically
2053
+ - use `endpoint` and `headers` when you are ready to ship telemetry to a hosted backend
2054
+
2009
2055
  **Sampling Configuration:**
2010
2056
 
2011
2057
  ```typescript
@@ -1,29 +1,37 @@
1
1
  'use strict';
2
2
 
3
- var chunkELW34S4C_cjs = require('./chunk-ELW34S4C.cjs');
3
+ var chunkCMNGGTQL_cjs = require('./chunk-CMNGGTQL.cjs');
4
4
  require('./chunk-JEQ2X3Z6.cjs');
5
5
 
6
6
 
7
7
 
8
8
  Object.defineProperty(exports, "AttributeRedactingProcessor", {
9
9
  enumerable: true,
10
- get: function () { return chunkELW34S4C_cjs.AttributeRedactingProcessor; }
10
+ get: function () { return chunkCMNGGTQL_cjs.AttributeRedactingProcessor; }
11
11
  });
12
12
  Object.defineProperty(exports, "REDACTOR_PATTERNS", {
13
13
  enumerable: true,
14
- get: function () { return chunkELW34S4C_cjs.REDACTOR_PATTERNS; }
14
+ get: function () { return chunkCMNGGTQL_cjs.REDACTOR_PATTERNS; }
15
15
  });
16
16
  Object.defineProperty(exports, "REDACTOR_PRESETS", {
17
17
  enumerable: true,
18
- get: function () { return chunkELW34S4C_cjs.REDACTOR_PRESETS; }
18
+ get: function () { return chunkCMNGGTQL_cjs.REDACTOR_PRESETS; }
19
+ });
20
+ Object.defineProperty(exports, "builtinPatterns", {
21
+ enumerable: true,
22
+ get: function () { return chunkCMNGGTQL_cjs.builtinPatterns; }
19
23
  });
20
24
  Object.defineProperty(exports, "createAttributeRedactor", {
21
25
  enumerable: true,
22
- get: function () { return chunkELW34S4C_cjs.createAttributeRedactor; }
26
+ get: function () { return chunkCMNGGTQL_cjs.createAttributeRedactor; }
23
27
  });
24
28
  Object.defineProperty(exports, "createRedactedSpan", {
25
29
  enumerable: true,
26
- get: function () { return chunkELW34S4C_cjs.createRedactedSpan; }
30
+ get: function () { return chunkCMNGGTQL_cjs.createRedactedSpan; }
31
+ });
32
+ Object.defineProperty(exports, "normalizeAttributeRedactorConfig", {
33
+ enumerable: true,
34
+ get: function () { return chunkCMNGGTQL_cjs.normalizeAttributeRedactorConfig; }
27
35
  });
28
36
  //# sourceMappingURL=attribute-redacting-processor.cjs.map
29
37
  //# sourceMappingURL=attribute-redacting-processor.cjs.map
@@ -37,6 +37,10 @@ type AttributeRedactorFn = (key: string, value: AttributeValue) => AttributeValu
37
37
  * Built-in redactor preset names
38
38
  */
39
39
  type AttributeRedactorPreset = 'default' | 'strict' | 'pci-dss';
40
+ /**
41
+ * Masker function type - receives the matched string and returns a masked version
42
+ */
43
+ type MaskFn = (match: string) => string;
40
44
  /**
41
45
  * Value pattern configuration
42
46
  */
@@ -47,7 +51,13 @@ interface ValuePatternConfig {
47
51
  pattern: RegExp;
48
52
  /** Custom replacement (default: uses global replacement) */
49
53
  replacement?: string;
54
+ /** Mask function for smart partial masking (overrides replacement) */
55
+ mask?: MaskFn;
50
56
  }
57
+ /**
58
+ * Built-in PII pattern names
59
+ */
60
+ type BuiltinPatternName = keyof typeof builtinPatterns;
51
61
  /**
52
62
  * Attribute redactor configuration
53
63
  */
@@ -56,6 +66,12 @@ interface AttributeRedactorConfig {
56
66
  keyPatterns?: RegExp[];
57
67
  /** Patterns to match against attribute values (redacts matched portion) */
58
68
  valuePatterns?: ValuePatternConfig[];
69
+ /** Dot-notation paths to redact (e.g. 'user.password', 'payment.card') */
70
+ paths?: string[];
71
+ /** Built-in PII patterns to enable. `true` enables all, `false` disables all, array selects specific ones. */
72
+ builtins?: boolean | BuiltinPatternName[];
73
+ /** Custom RegExp patterns for string-level redaction */
74
+ patterns?: RegExp[];
59
75
  /** Default replacement string (default: '[REDACTED]') */
60
76
  replacement?: string;
61
77
  /** Custom redactor function for full control */
@@ -80,10 +96,56 @@ declare const REDACTOR_PATTERNS: {
80
96
  readonly jwt: RegExp;
81
97
  readonly sensitiveKey: RegExp;
82
98
  };
99
+ /**
100
+ * Built-in PII detection patterns with smart masking.
101
+ * Each builtin preserves just enough signal for debugging while scrubbing PII.
102
+ */
103
+ declare const builtinPatterns: {
104
+ /** Credit card numbers → ****1111 (PCI DSS: last 4 allowed) */
105
+ readonly creditCard: {
106
+ readonly pattern: RegExp;
107
+ readonly mask: (m: string) => string;
108
+ };
109
+ /** Email addresses → a***@***.com */
110
+ readonly email: {
111
+ readonly pattern: RegExp;
112
+ readonly mask: (m: string) => string;
113
+ };
114
+ /** IPv4 addresses → ***.***.***.100 (last octet only) */
115
+ readonly ipv4: {
116
+ readonly pattern: RegExp;
117
+ readonly mask: (m: string) => string;
118
+ };
119
+ /** International phone numbers → +33******78 (country code + last 2 digits) */
120
+ readonly phone: {
121
+ readonly pattern: RegExp;
122
+ readonly mask: (m: string) => string;
123
+ };
124
+ /** JWT tokens → eyJ***.*** */
125
+ readonly jwt: {
126
+ readonly pattern: RegExp;
127
+ readonly mask: () => string;
128
+ };
129
+ /** Bearer tokens → Bearer *** */
130
+ readonly bearer: {
131
+ readonly pattern: RegExp;
132
+ readonly mask: () => string;
133
+ };
134
+ /** IBAN → FR76****189 (country + check digits + last 3) */
135
+ readonly iban: {
136
+ readonly pattern: RegExp;
137
+ readonly mask: (m: string) => string;
138
+ };
139
+ };
83
140
  /**
84
141
  * Built-in redactor presets
85
142
  */
86
143
  declare const REDACTOR_PRESETS: Record<AttributeRedactorPreset, AttributeRedactorConfig>;
144
+ /**
145
+ * Normalize redactor config that may have been deserialized from JSON/YAML.
146
+ * Converts regex-like values back to RegExp instances.
147
+ */
148
+ declare function normalizeAttributeRedactorConfig(raw: AttributeRedactorConfig | AttributeRedactorPreset | unknown): AttributeRedactorConfig | AttributeRedactorPreset | undefined;
87
149
  /**
88
150
  * Create a proxy wrapper around ReadableSpan with redacted attributes
89
151
  *
@@ -133,4 +195,4 @@ declare class AttributeRedactingProcessor implements SpanProcessor {
133
195
  shutdown(): Promise<void>;
134
196
  }
135
197
 
136
- export { AttributeRedactingProcessor, type AttributeRedactingProcessorOptions, type AttributeRedactorConfig, type AttributeRedactorFn, type AttributeRedactorPreset, REDACTOR_PATTERNS, REDACTOR_PRESETS, type ValuePatternConfig, createAttributeRedactor, createRedactedSpan };
198
+ export { AttributeRedactingProcessor, type AttributeRedactingProcessorOptions, type AttributeRedactorConfig, type AttributeRedactorFn, type AttributeRedactorPreset, type BuiltinPatternName, type MaskFn, REDACTOR_PATTERNS, REDACTOR_PRESETS, type ValuePatternConfig, builtinPatterns, createAttributeRedactor, createRedactedSpan, normalizeAttributeRedactorConfig };
@@ -37,6 +37,10 @@ type AttributeRedactorFn = (key: string, value: AttributeValue) => AttributeValu
37
37
  * Built-in redactor preset names
38
38
  */
39
39
  type AttributeRedactorPreset = 'default' | 'strict' | 'pci-dss';
40
+ /**
41
+ * Masker function type - receives the matched string and returns a masked version
42
+ */
43
+ type MaskFn = (match: string) => string;
40
44
  /**
41
45
  * Value pattern configuration
42
46
  */
@@ -47,7 +51,13 @@ interface ValuePatternConfig {
47
51
  pattern: RegExp;
48
52
  /** Custom replacement (default: uses global replacement) */
49
53
  replacement?: string;
54
+ /** Mask function for smart partial masking (overrides replacement) */
55
+ mask?: MaskFn;
50
56
  }
57
+ /**
58
+ * Built-in PII pattern names
59
+ */
60
+ type BuiltinPatternName = keyof typeof builtinPatterns;
51
61
  /**
52
62
  * Attribute redactor configuration
53
63
  */
@@ -56,6 +66,12 @@ interface AttributeRedactorConfig {
56
66
  keyPatterns?: RegExp[];
57
67
  /** Patterns to match against attribute values (redacts matched portion) */
58
68
  valuePatterns?: ValuePatternConfig[];
69
+ /** Dot-notation paths to redact (e.g. 'user.password', 'payment.card') */
70
+ paths?: string[];
71
+ /** Built-in PII patterns to enable. `true` enables all, `false` disables all, array selects specific ones. */
72
+ builtins?: boolean | BuiltinPatternName[];
73
+ /** Custom RegExp patterns for string-level redaction */
74
+ patterns?: RegExp[];
59
75
  /** Default replacement string (default: '[REDACTED]') */
60
76
  replacement?: string;
61
77
  /** Custom redactor function for full control */
@@ -80,10 +96,56 @@ declare const REDACTOR_PATTERNS: {
80
96
  readonly jwt: RegExp;
81
97
  readonly sensitiveKey: RegExp;
82
98
  };
99
+ /**
100
+ * Built-in PII detection patterns with smart masking.
101
+ * Each builtin preserves just enough signal for debugging while scrubbing PII.
102
+ */
103
+ declare const builtinPatterns: {
104
+ /** Credit card numbers → ****1111 (PCI DSS: last 4 allowed) */
105
+ readonly creditCard: {
106
+ readonly pattern: RegExp;
107
+ readonly mask: (m: string) => string;
108
+ };
109
+ /** Email addresses → a***@***.com */
110
+ readonly email: {
111
+ readonly pattern: RegExp;
112
+ readonly mask: (m: string) => string;
113
+ };
114
+ /** IPv4 addresses → ***.***.***.100 (last octet only) */
115
+ readonly ipv4: {
116
+ readonly pattern: RegExp;
117
+ readonly mask: (m: string) => string;
118
+ };
119
+ /** International phone numbers → +33******78 (country code + last 2 digits) */
120
+ readonly phone: {
121
+ readonly pattern: RegExp;
122
+ readonly mask: (m: string) => string;
123
+ };
124
+ /** JWT tokens → eyJ***.*** */
125
+ readonly jwt: {
126
+ readonly pattern: RegExp;
127
+ readonly mask: () => string;
128
+ };
129
+ /** Bearer tokens → Bearer *** */
130
+ readonly bearer: {
131
+ readonly pattern: RegExp;
132
+ readonly mask: () => string;
133
+ };
134
+ /** IBAN → FR76****189 (country + check digits + last 3) */
135
+ readonly iban: {
136
+ readonly pattern: RegExp;
137
+ readonly mask: (m: string) => string;
138
+ };
139
+ };
83
140
  /**
84
141
  * Built-in redactor presets
85
142
  */
86
143
  declare const REDACTOR_PRESETS: Record<AttributeRedactorPreset, AttributeRedactorConfig>;
144
+ /**
145
+ * Normalize redactor config that may have been deserialized from JSON/YAML.
146
+ * Converts regex-like values back to RegExp instances.
147
+ */
148
+ declare function normalizeAttributeRedactorConfig(raw: AttributeRedactorConfig | AttributeRedactorPreset | unknown): AttributeRedactorConfig | AttributeRedactorPreset | undefined;
87
149
  /**
88
150
  * Create a proxy wrapper around ReadableSpan with redacted attributes
89
151
  *
@@ -133,4 +195,4 @@ declare class AttributeRedactingProcessor implements SpanProcessor {
133
195
  shutdown(): Promise<void>;
134
196
  }
135
197
 
136
- export { AttributeRedactingProcessor, type AttributeRedactingProcessorOptions, type AttributeRedactorConfig, type AttributeRedactorFn, type AttributeRedactorPreset, REDACTOR_PATTERNS, REDACTOR_PRESETS, type ValuePatternConfig, createAttributeRedactor, createRedactedSpan };
198
+ export { AttributeRedactingProcessor, type AttributeRedactingProcessorOptions, type AttributeRedactorConfig, type AttributeRedactorFn, type AttributeRedactorPreset, type BuiltinPatternName, type MaskFn, REDACTOR_PATTERNS, REDACTOR_PRESETS, type ValuePatternConfig, builtinPatterns, createAttributeRedactor, createRedactedSpan, normalizeAttributeRedactorConfig };
@@ -1,4 +1,4 @@
1
- export { AttributeRedactingProcessor, REDACTOR_PATTERNS, REDACTOR_PRESETS, createAttributeRedactor, createRedactedSpan } from './chunk-SNINLBEE.js';
1
+ export { AttributeRedactingProcessor, REDACTOR_PATTERNS, REDACTOR_PRESETS, builtinPatterns, createAttributeRedactor, createRedactedSpan, normalizeAttributeRedactorConfig } from './chunk-TDNKIHKT.js';
2
2
  import './chunk-DGUM43GV.js';
3
3
  //# sourceMappingURL=attribute-redacting-processor.js.map
4
4
  //# sourceMappingURL=attribute-redacting-processor.js.map
@@ -1,87 +1,87 @@
1
1
  'use strict';
2
2
 
3
- var chunkXRBP4RYL_cjs = require('./chunk-XRBP4RYL.cjs');
3
+ var chunkJKIMEPI2_cjs = require('./chunk-JKIMEPI2.cjs');
4
4
  require('./chunk-ESMHTKLJ.cjs');
5
- require('./chunk-ELW34S4C.cjs');
5
+ require('./chunk-CMNGGTQL.cjs');
6
6
  require('./chunk-JEQ2X3Z6.cjs');
7
7
 
8
8
 
9
9
 
10
10
  Object.defineProperty(exports, "attrs", {
11
11
  enumerable: true,
12
- get: function () { return chunkXRBP4RYL_cjs.attrs; }
12
+ get: function () { return chunkJKIMEPI2_cjs.attrs; }
13
13
  });
14
14
  Object.defineProperty(exports, "autoRedactPII", {
15
15
  enumerable: true,
16
- get: function () { return chunkXRBP4RYL_cjs.autoRedactPII; }
16
+ get: function () { return chunkJKIMEPI2_cjs.autoRedactPII; }
17
17
  });
18
18
  Object.defineProperty(exports, "checkDeprecatedAttribute", {
19
19
  enumerable: true,
20
- get: function () { return chunkXRBP4RYL_cjs.checkDeprecatedAttribute; }
20
+ get: function () { return chunkJKIMEPI2_cjs.checkDeprecatedAttribute; }
21
21
  });
22
22
  Object.defineProperty(exports, "dbClient", {
23
23
  enumerable: true,
24
- get: function () { return chunkXRBP4RYL_cjs.dbClient; }
24
+ get: function () { return chunkJKIMEPI2_cjs.dbClient; }
25
25
  });
26
26
  Object.defineProperty(exports, "defaultGuardrails", {
27
27
  enumerable: true,
28
- get: function () { return chunkXRBP4RYL_cjs.defaultGuardrails; }
28
+ get: function () { return chunkJKIMEPI2_cjs.defaultGuardrails; }
29
29
  });
30
30
  Object.defineProperty(exports, "httpClient", {
31
31
  enumerable: true,
32
- get: function () { return chunkXRBP4RYL_cjs.httpClient; }
32
+ get: function () { return chunkJKIMEPI2_cjs.httpClient; }
33
33
  });
34
34
  Object.defineProperty(exports, "httpServer", {
35
35
  enumerable: true,
36
- get: function () { return chunkXRBP4RYL_cjs.httpServer; }
36
+ get: function () { return chunkJKIMEPI2_cjs.httpServer; }
37
37
  });
38
38
  Object.defineProperty(exports, "identify", {
39
39
  enumerable: true,
40
- get: function () { return chunkXRBP4RYL_cjs.identify; }
40
+ get: function () { return chunkJKIMEPI2_cjs.identify; }
41
41
  });
42
42
  Object.defineProperty(exports, "mergeAttrs", {
43
43
  enumerable: true,
44
- get: function () { return chunkXRBP4RYL_cjs.mergeAttrs; }
44
+ get: function () { return chunkJKIMEPI2_cjs.mergeAttrs; }
45
45
  });
46
46
  Object.defineProperty(exports, "mergeServiceResource", {
47
47
  enumerable: true,
48
- get: function () { return chunkXRBP4RYL_cjs.mergeServiceResource; }
48
+ get: function () { return chunkJKIMEPI2_cjs.mergeServiceResource; }
49
49
  });
50
50
  Object.defineProperty(exports, "request", {
51
51
  enumerable: true,
52
- get: function () { return chunkXRBP4RYL_cjs.request; }
52
+ get: function () { return chunkJKIMEPI2_cjs.request; }
53
53
  });
54
54
  Object.defineProperty(exports, "safeSetAttributes", {
55
55
  enumerable: true,
56
- get: function () { return chunkXRBP4RYL_cjs.safeSetAttributes; }
56
+ get: function () { return chunkJKIMEPI2_cjs.safeSetAttributes; }
57
57
  });
58
58
  Object.defineProperty(exports, "setDevice", {
59
59
  enumerable: true,
60
- get: function () { return chunkXRBP4RYL_cjs.setDevice; }
60
+ get: function () { return chunkJKIMEPI2_cjs.setDevice; }
61
61
  });
62
62
  Object.defineProperty(exports, "setError", {
63
63
  enumerable: true,
64
- get: function () { return chunkXRBP4RYL_cjs.setError; }
64
+ get: function () { return chunkJKIMEPI2_cjs.setError; }
65
65
  });
66
66
  Object.defineProperty(exports, "setException", {
67
67
  enumerable: true,
68
- get: function () { return chunkXRBP4RYL_cjs.setException; }
68
+ get: function () { return chunkJKIMEPI2_cjs.setException; }
69
69
  });
70
70
  Object.defineProperty(exports, "setSession", {
71
71
  enumerable: true,
72
- get: function () { return chunkXRBP4RYL_cjs.setSession; }
72
+ get: function () { return chunkJKIMEPI2_cjs.setSession; }
73
73
  });
74
74
  Object.defineProperty(exports, "setUser", {
75
75
  enumerable: true,
76
- get: function () { return chunkXRBP4RYL_cjs.setUser; }
76
+ get: function () { return chunkJKIMEPI2_cjs.setUser; }
77
77
  });
78
78
  Object.defineProperty(exports, "transaction", {
79
79
  enumerable: true,
80
- get: function () { return chunkXRBP4RYL_cjs.transaction; }
80
+ get: function () { return chunkJKIMEPI2_cjs.transaction; }
81
81
  });
82
82
  Object.defineProperty(exports, "validateAttribute", {
83
83
  enumerable: true,
84
- get: function () { return chunkXRBP4RYL_cjs.validateAttribute; }
84
+ get: function () { return chunkJKIMEPI2_cjs.validateAttribute; }
85
85
  });
86
86
  //# sourceMappingURL=attributes.cjs.map
87
87
  //# sourceMappingURL=attributes.cjs.map
@@ -1,6 +1,6 @@
1
- export { attrs, autoRedactPII, checkDeprecatedAttribute, dbClient, defaultGuardrails, httpClient, httpServer, identify, mergeAttrs, mergeServiceResource, request, safeSetAttributes, setDevice, setError, setException, setSession, setUser, transaction, validateAttribute } from './chunk-M4US3P4K.js';
1
+ export { attrs, autoRedactPII, checkDeprecatedAttribute, dbClient, defaultGuardrails, httpClient, httpServer, identify, mergeAttrs, mergeServiceResource, request, safeSetAttributes, setDevice, setError, setException, setSession, setUser, transaction, validateAttribute } from './chunk-ER43K7ES.js';
2
2
  import './chunk-4A53YIAX.js';
3
- import './chunk-SNINLBEE.js';
3
+ import './chunk-TDNKIHKT.js';
4
4
  import './chunk-DGUM43GV.js';
5
5
  //# sourceMappingURL=attributes.js.map
6
6
  //# sourceMappingURL=attributes.js.map
package/dist/auto.cjs CHANGED
@@ -1,16 +1,16 @@
1
1
  'use strict';
2
2
 
3
- var chunkITYASFHQ_cjs = require('./chunk-ITYASFHQ.cjs');
4
- var chunkOFPZULMQ_cjs = require('./chunk-OFPZULMQ.cjs');
5
- require('./chunk-KZEC4CHV.cjs');
3
+ var chunk563EL6O6_cjs = require('./chunk-563EL6O6.cjs');
4
+ var chunkOC6X2VIN_cjs = require('./chunk-OC6X2VIN.cjs');
5
+ require('./chunk-CEAQK2QY.cjs');
6
6
  require('./chunk-ZNMBW67B.cjs');
7
7
  require('./chunk-IOYFAFHJ.cjs');
8
- require('./chunk-ELW34S4C.cjs');
8
+ require('./chunk-CMNGGTQL.cjs');
9
9
  require('./chunk-CU6IDACR.cjs');
10
10
  require('./chunk-6S5RUKU3.cjs');
11
11
  require('./chunk-YS6C2YJE.cjs');
12
- require('./chunk-7FIGORWI.cjs');
13
- require('./chunk-AZ24DJAG.cjs');
12
+ require('./chunk-VH77IPJN.cjs');
13
+ require('./chunk-FU6R566Y.cjs');
14
14
  require('./chunk-ESLWRGAG.cjs');
15
15
  require('./chunk-YREV3LGG.cjs');
16
16
  require('./chunk-JEQ2X3Z6.cjs');
@@ -20,10 +20,10 @@ var importInTheMiddle = require('import-in-the-middle');
20
20
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
21
21
  var { registerOptions } = importInTheMiddle.createAddHookMessageChannel();
22
22
  module$1.register("import-in-the-middle/hook.mjs", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('auto.cjs', document.baseURI).href)), registerOptions);
23
- var yamlConfig = chunkOFPZULMQ_cjs.loadYamlConfig();
23
+ var yamlConfig = chunkOC6X2VIN_cjs.loadYamlConfig();
24
24
  var autoInstrumentationsEnv = process.env.AUTOTEL_INTEGRATIONS;
25
25
  var autoInstrumentations = autoInstrumentationsEnv === "true" ? true : autoInstrumentationsEnv ? autoInstrumentationsEnv.split(",").map((s) => s.trim()) : yamlConfig?.autoInstrumentations ?? ["http", "express"];
26
- chunkITYASFHQ_cjs.init({
26
+ chunk563EL6O6_cjs.init({
27
27
  service: yamlConfig?.service ?? process.env.OTEL_SERVICE_NAME ?? "unknown-service",
28
28
  debug: yamlConfig?.debug ?? process.env.AUTOTEL_DEBUG === "true",
29
29
  autoInstrumentations
package/dist/auto.js CHANGED
@@ -1,14 +1,14 @@
1
- import { init } from './chunk-MNBAXRVG.js';
2
- import { loadYamlConfig } from './chunk-RUD7KS4R.js';
3
- import './chunk-XDKK53OL.js';
1
+ import { init } from './chunk-W35FVJBC.js';
2
+ import { loadYamlConfig } from './chunk-3SDILILG.js';
3
+ import './chunk-A4E5AQFK.js';
4
4
  import './chunk-WGWSHJ2N.js';
5
5
  import './chunk-GYR5K654.js';
6
- import './chunk-SNINLBEE.js';
6
+ import './chunk-TDNKIHKT.js';
7
7
  import './chunk-6UQRVUN3.js';
8
8
  import './chunk-3QXBFGKP.js';
9
9
  import './chunk-33WTKH7X.js';
10
- import './chunk-VYA6QDNA.js';
11
- import './chunk-B33XPEKY.js';
10
+ import './chunk-DPSA4QLA.js';
11
+ import './chunk-55ER2KD5.js';
12
12
  import './chunk-J5QENANM.js';
13
13
  import './chunk-HA2WBOGQ.js';
14
14
  import './chunk-DGUM43GV.js';
@@ -1,5 +1,5 @@
1
1
  import { requireModule } from './chunk-33WTKH7X.js';
2
- import { AdaptiveSampler, RandomSampler, NeverSampler, AlwaysSampler } from './chunk-VYA6QDNA.js';
2
+ import { AdaptiveSampler, RandomSampler, NeverSampler, AlwaysSampler } from './chunk-DPSA4QLA.js';
3
3
  import { readFileSync, existsSync } from 'fs';
4
4
  import path from 'path';
5
5
 
@@ -166,5 +166,5 @@ function hasYamlConfig() {
166
166
  }
167
167
 
168
168
  export { hasYamlConfig, loadYamlConfig, loadYamlConfigFromFile };
169
- //# sourceMappingURL=chunk-RUD7KS4R.js.map
170
- //# sourceMappingURL=chunk-RUD7KS4R.js.map
169
+ //# sourceMappingURL=chunk-3SDILILG.js.map
170
+ //# sourceMappingURL=chunk-3SDILILG.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/yaml-config.ts"],"names":[],"mappings":";;;;;AAwCA,SAAS,cAAA,GAA+C;AACtD,EAAA,IAAI;AACF,IAAA,MAAM,GAAA,GAAM,cAAuD,MAAM,CAAA;AACzE,IAAA,OAAO,GAAA,CAAI,KAAA;AAAA,EACb,CAAA,CAAA,MAAQ;AACN,IAAA,MAAM,IAAI,MAAM,oDAAoD,CAAA;AAAA,EACtE;AACF;AAmCA,IAAM,eAAA,GAAkB,mDAAA;AAYxB,SAAS,kBAAkB,KAAA,EAAuB;AAChD,EAAA,OAAO,KAAA,CAAM,UAAA;AAAA,IACX,eAAA;AAAA,IACA,CAAC,MAAA,EAAQ,OAAA,EAAiB,YAAA,KAA0B;AAClD,MAAA,MAAM,QAAA,GAAW,OAAA,CAAQ,GAAA,CAAI,OAAO,CAAA;AACpC,MAAA,IAAI,QAAA,KAAa,QAAW,OAAO,QAAA;AACnC,MAAA,IAAI,YAAA,KA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EACT;AACF;AAkBO,SAAS,uBACd,QAAA,EACwB;AACxB,EAAA,MAAM,QAAA,GAAW,IAAA,CAAK,OAAA,CAAQ,QAAQ,CAAA;AACtC,EAAA,MAAM,OAAA,GAAU,YAAA,CAAa,QAAA,EAAU,MAAM,CAAA;AAC7C,EAAA,MAAM,YAAY,cAAA,EAAe;AACjC,EAAA,MAAM,OAAA,GAAU,UAAU,OAAO,CAAA;AACjC,EAAA,MAAM,WAAA,GAAc,sBAAsB,OAAO,CAAA;AACjD,EAAA,OAAO,oBAAoB,WAAW,CAAA;AACxC;AAOO,SAAS,aAAA,GAAyB;AACvC,EAAA,OAAO,gBAAe,KAAM,IAAA;AAC9B","file":"chunk-RUD7KS4R.js","sourcesContent":["/**\n * YAML configuration loader for autotel\n *\n * Supports:\n * - Auto-discovery of autotel.yaml in cwd\n * - AUTOTEL_CONFIG_FILE env var override\n * - Environment variable substitution: ${env:VAR} and ${env:VAR:-default}\n *\n * @example Auto-discovery\n * ```yaml\n * # autotel.yaml in project root\n * service:\n * name: my-service\n * exporter:\n * endpoint: ${env:OTEL_EXPORTER_OTLP_ENDPOINT:-http://localhost:4318}\n * ```\n *\n * @example Explicit path\n * ```bash\n * AUTOTEL_CONFIG_FILE=./config/otel.yaml tsx --import autotel/auto src/index.ts\n * ```\n */\n\nimport { readFileSync, existsSync } from 'node:fs';\nimport path from 'node:path';\nimport type { AutotelConfig } from './init';\nimport {\n AdaptiveSampler,\n AlwaysSampler,\n NeverSampler,\n RandomSampler,\n type SamplingPreset,\n} from './sampling';\n\n/**\n * Lazy-load yaml parser (optional peer dependency)\n * Only loads when a YAML config file is actually found\n */\nimport { requireModule } from './node-require';\n\nfunction loadYamlParser(): (content: string) => unknown {\n try {\n const mod = requireModule<{ parse: (content: string) => unknown }>('yaml');\n return mod.parse;\n } catch {\n throw new Error('YAML parser not found. Install with: pnpm add yaml');\n }\n}\n\n/**\n * YAML config structure\n * Maps to AutotelConfig with user-friendly naming\n */\nexport interface YamlConfig {\n service?: {\n name?: string;\n version?: string;\n environment?: string;\n };\n exporter?: {\n endpoint?: string;\n protocol?: 'http' | 'grpc';\n headers?: Record<string, string>;\n };\n resource?: Record<string, string | number | boolean>;\n sampling?: {\n preset?: SamplingPreset;\n type?: 'adaptive' | 'always_on' | 'always_off' | 'ratio';\n ratio?: number;\n baseline_rate?: number;\n always_sample_errors?: boolean;\n always_sample_slow?: boolean;\n slow_threshold_ms?: number;\n };\n autoInstrumentations?: string[] | Record<string, { enabled?: boolean }>;\n debug?: boolean;\n}\n\n/**\n * Environment variable substitution regex\n * Matches ${env:VAR_NAME} and ${env:VAR_NAME:-default}\n */\nconst ENV_VAR_PATTERN = /\\$\\{env:([A-Za-z_][A-Za-z0-9_]*)(?::-([^}]*))?\\}/g;\n\n/**\n * Substitute ${env:VAR} and ${env:VAR:-default} in a string\n *\n * @param value - String potentially containing env var references\n * @returns String with env vars substituted\n *\n * @example\n * substituteEnvVars('${env:NODE_ENV:-development}')\n * // Returns 'production' if NODE_ENV=production, else 'development'\n */\nfunction substituteEnvVars(value: string): string {\n return value.replaceAll(\n ENV_VAR_PATTERN,\n (_match, varName: string, defaultValue?: string) => {\n const envValue = process.env[varName];\n if (envValue !== undefined) return envValue;\n if (defaultValue !== undefined) return defaultValue;\n console.warn(\n `[autotel] Environment variable ${varName} not set and no default provided`,\n );\n return '';\n },\n );\n}\n\n/**\n * Recursively substitute env vars in an object\n *\n * @param obj - Object to process\n * @returns Object with all string values having env vars substituted\n */\nfunction substituteEnvVarsDeep(obj: unknown): unknown {\n if (typeof obj === 'string') {\n return substituteEnvVars(obj);\n }\n if (Array.isArray(obj)) {\n return obj.map((item) => substituteEnvVarsDeep(item));\n }\n if (obj && typeof obj === 'object') {\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(obj)) {\n result[key] = substituteEnvVarsDeep(value);\n }\n return result;\n }\n return obj;\n}\n\n/**\n * Find YAML config file path\n *\n * Priority:\n * 1. AUTOTEL_CONFIG_FILE env var (explicit path)\n * 2. autotel.yaml in cwd (convention)\n * 3. autotel.yml in cwd (alternative extension)\n *\n * @returns File path if found, null otherwise\n */\nfunction findConfigFile(): string | null {\n // Check env var first (explicit takes priority)\n const envPath = process.env.AUTOTEL_CONFIG_FILE;\n if (envPath) {\n const resolved = path.resolve(envPath);\n if (existsSync(resolved)) return resolved;\n console.warn(`[autotel] Config file not found: ${envPath}`);\n return null;\n }\n\n // Auto-discover autotel.yaml in cwd\n const conventionPath = path.resolve(process.cwd(), 'autotel.yaml');\n if (existsSync(conventionPath)) return conventionPath;\n\n // Also check .yml extension\n const altPath = path.resolve(process.cwd(), 'autotel.yml');\n if (existsSync(altPath)) return altPath;\n\n return null;\n}\n\n/**\n * Convert YAML config structure to AutotelConfig\n *\n * @param yaml - Parsed and env-substituted YAML config\n * @returns Partial AutotelConfig ready for merging\n */\nfunction yamlToAutotelConfig(yaml: YamlConfig): Partial<AutotelConfig> {\n const config: Partial<AutotelConfig> = {};\n\n // Service configuration\n if (yaml.service?.name) config.service = yaml.service.name;\n if (yaml.service?.version) config.version = yaml.service.version;\n if (yaml.service?.environment) config.environment = yaml.service.environment;\n\n // Exporter configuration\n if (yaml.exporter?.endpoint) config.endpoint = yaml.exporter.endpoint;\n if (yaml.exporter?.protocol) config.protocol = yaml.exporter.protocol;\n if (yaml.exporter?.headers) config.headers = yaml.exporter.headers;\n\n // Resource attributes (flattened)\n if (yaml.resource) config.resourceAttributes = yaml.resource;\n\n // Integrations\n if (yaml.autoInstrumentations)\n config.autoInstrumentations = yaml.autoInstrumentations;\n\n // Debug mode\n if (yaml.debug !== undefined) config.debug = yaml.debug;\n\n // Sampling configuration\n if (yaml.sampling?.preset) {\n warnOnIgnoredPresetOverrides(yaml.sampling);\n config.sampling = yaml.sampling.preset;\n } else {\n const sampler = createSamplerFromYaml(yaml.sampling);\n if (sampler) config.sampler = sampler;\n }\n\n return config;\n}\n\nfunction createSamplerFromYaml(\n sampling?: YamlConfig['sampling'],\n): AutotelConfig['sampler'] {\n if (!sampling) return undefined;\n if (sampling.preset) return undefined;\n\n const type = sampling.type ?? 'adaptive';\n\n try {\n switch (type) {\n case 'adaptive': {\n return new AdaptiveSampler({\n baselineSampleRate: sampling.baseline_rate,\n alwaysSampleErrors: sampling.always_sample_errors,\n alwaysSampleSlow: sampling.always_sample_slow,\n slowThresholdMs: sampling.slow_threshold_ms,\n });\n }\n case 'always_on': {\n return new AlwaysSampler();\n }\n case 'always_off': {\n return new NeverSampler();\n }\n case 'ratio': {\n if (sampling.ratio === undefined) {\n console.warn(\n '[autotel] sampling.ratio missing in YAML sampling config. Falling back to adaptive sampler.',\n );\n return new AdaptiveSampler();\n }\n return new RandomSampler(sampling.ratio);\n }\n default: {\n console.warn(\n `[autotel] Unknown sampling type \"${type}\" in YAML config. Falling back to defaults.`,\n );\n return undefined;\n }\n }\n } catch (error) {\n console.warn(\n `[autotel] Failed to configure sampling from YAML: ${error instanceof Error ? error.message : String(error)}`,\n );\n return undefined;\n }\n}\n\nfunction warnOnIgnoredPresetOverrides(\n sampling: NonNullable<YamlConfig['sampling']>,\n): void {\n const ignoredFields = [\n 'type',\n 'ratio',\n 'baseline_rate',\n 'always_sample_errors',\n 'always_sample_slow',\n 'slow_threshold_ms',\n ].filter((field) => sampling[field as keyof typeof sampling] !== undefined);\n\n if (ignoredFields.length === 0) {\n return;\n }\n\n console.warn(\n `[autotel] sampling.preset=\"${sampling.preset}\" ignores these YAML fields: ${ignoredFields.join(', ')}. ` +\n 'Use the programmatic API with sampler or samplingPresets.*(...) for tuned presets.',\n );\n}\n\n/**\n * Load and parse YAML config file (auto-discovery)\n *\n * Automatically finds and loads autotel.yaml or uses AUTOTEL_CONFIG_FILE.\n * Returns null if no config file found (not an error - YAML config is optional).\n *\n * @returns Partial AutotelConfig or null if no config file found\n *\n * @example\n * const yamlConfig = loadYamlConfig();\n * if (yamlConfig) {\n * init({ ...yamlConfig, debug: true });\n * }\n */\nexport function loadYamlConfig(): Partial<AutotelConfig> | null {\n const filePath = findConfigFile();\n if (!filePath) return null;\n\n try {\n const content = readFileSync(filePath, 'utf8');\n const parseYaml = loadYamlParser();\n const rawYaml = parseYaml(content) as YamlConfig;\n const substituted = substituteEnvVarsDeep(rawYaml) as YamlConfig;\n return yamlToAutotelConfig(substituted);\n } catch (error) {\n console.error(\n `[autotel] Failed to load YAML config from ${filePath}:`,\n error,\n );\n return null;\n }\n}\n\n/**\n * Load YAML config from a specific file path\n *\n * Unlike loadYamlConfig(), this throws if the file cannot be read.\n *\n * @param filePath - Path to YAML config file\n * @returns Partial AutotelConfig\n * @throws Error if file cannot be read or parsed\n *\n * @example\n * import { loadYamlConfigFromFile } from 'autotel/yaml';\n * import { init } from 'autotel';\n *\n * const config = loadYamlConfigFromFile('./config/otel.yaml');\n * init({ ...config, debug: true });\n */\nexport function loadYamlConfigFromFile(\n filePath: string,\n): Partial<AutotelConfig> {\n const resolved = path.resolve(filePath);\n const content = readFileSync(resolved, 'utf8');\n const parseYaml = loadYamlParser();\n const rawYaml = parseYaml(content) as YamlConfig;\n const substituted = substituteEnvVarsDeep(rawYaml) as YamlConfig;\n return yamlToAutotelConfig(substituted);\n}\n\n/**\n * Check if a YAML config file exists (without loading it)\n *\n * @returns true if a config file would be found by loadYamlConfig()\n */\nexport function hasYamlConfig(): boolean {\n return findConfigFile() !== null;\n}\n"]}
1
+ {"version":3,"sources":["../src/yaml-config.ts"],"names":[],"mappings":";;;;;AAwCA,SAAS,cAAA,GAA+C;AACtD,EAAA,IAAI;AACF,IAAA,MAAM,GAAA,GAAM,cAAuD,MAAM,CAAA;AACzE,IAAA,OAAO,GAAA,CAAI,KAAA;AAAA,EACb,CAAA,CAAA,MAAQ;AACN,IAAA,MAAM,IAAI,MAAM,oDAAoD,CAAA;AAAA,EACtE;AACF;AAmCA,IAAM,eAAA,GAAkB,mDAAA;AAYxB,SAAS,kBAAkB,KAAA,EAAuB;AAChD,EAAA,OAAO,KAAA,CAAM,UAAA;AAAA,IACX,eAAA;AAAA,IACA,C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AA,OAAO,oBAAoB,WAAW,CAAA;AAAA,EACxC,SAAS,KAAA,EAAO;AACd,IAAA,OAAA,CAAQ,KAAA;AAAA,MACN,6CAA6C,QAAQ,CAAA,CAAA,CAAA;AAAA,MACrD;AAAA,KACF;AACA,IAAA,OAAO,IAAA;AAAA,EACT;AACF;AAkBO,SAAS,uBACd,QAAA,EACwB;AACxB,EAAA,MAAM,QAAA,GAAW,IAAA,CAAK,OAAA,CAAQ,QAAQ,CAAA;AACtC,EAAA,MAAM,OAAA,GAAU,YAAA,CAAa,QAAA,EAAU,MAAM,CAAA;AAC7C,EAAA,MAAM,YAAY,cAAA,EAAe;AACjC,EAAA,MAAM,OAAA,GAAU,UAAU,OAAO,CAAA;AACjC,EAAA,MAAM,WAAA,GAAc,sBAAsB,OAAO,CAAA;AACjD,EAAA,OAAO,oBAAoB,WAAW,CAAA;AACxC;AAOO,SAAS,aAAA,GAAyB;AACvC,EAAA,OAAO,gBAAe,KAAM,IAAA;AAC9B","file":"chunk-3SDILILG.js","sourcesContent":["/**\n * YAML configuration loader for autotel\n *\n * Supports:\n * - Auto-discovery of autotel.yaml in cwd\n * - AUTOTEL_CONFIG_FILE env var override\n * - Environment variable substitution: ${env:VAR} and ${env:VAR:-default}\n *\n * @example Auto-discovery\n * ```yaml\n * # autotel.yaml in project root\n * service:\n * name: my-service\n * exporter:\n * endpoint: ${env:OTEL_EXPORTER_OTLP_ENDPOINT:-http://localhost:4318}\n * ```\n *\n * @example Explicit path\n * ```bash\n * AUTOTEL_CONFIG_FILE=./config/otel.yaml tsx --import autotel/auto src/index.ts\n * ```\n */\n\nimport { readFileSync, existsSync } from 'node:fs';\nimport path from 'node:path';\nimport type { AutotelConfig } from './init';\nimport {\n AdaptiveSampler,\n AlwaysSampler,\n NeverSampler,\n RandomSampler,\n type SamplingPreset,\n} from './sampling';\n\n/**\n * Lazy-load yaml parser (optional peer dependency)\n * Only loads when a YAML config file is actually found\n */\nimport { requireModule } from './node-require';\n\nfunction loadYamlParser(): (content: string) => unknown {\n try {\n const mod = requireModule<{ parse: (content: string) => unknown }>('yaml');\n return mod.parse;\n } catch {\n throw new Error('YAML parser not found. Install with: pnpm add yaml');\n }\n}\n\n/**\n * YAML config structure\n * Maps to AutotelConfig with user-friendly naming\n */\nexport interface YamlConfig {\n service?: {\n name?: string;\n version?: string;\n environment?: string;\n };\n exporter?: {\n endpoint?: string;\n protocol?: 'http' | 'grpc';\n headers?: Record<string, string>;\n };\n resource?: Record<string, string | number | boolean>;\n sampling?: {\n preset?: SamplingPreset;\n type?: 'adaptive' | 'always_on' | 'always_off' | 'ratio';\n ratio?: number;\n baseline_rate?: number;\n always_sample_errors?: boolean;\n always_sample_slow?: boolean;\n slow_threshold_ms?: number;\n };\n autoInstrumentations?: string[] | Record<string, { enabled?: boolean }>;\n debug?: boolean;\n}\n\n/**\n * Environment variable substitution regex\n * Matches ${env:VAR_NAME} and ${env:VAR_NAME:-default}\n */\nconst ENV_VAR_PATTERN = /\\$\\{env:([A-Za-z_][A-Za-z0-9_]*)(?::-([^}]*))?\\}/g;\n\n/**\n * Substitute ${env:VAR} and ${env:VAR:-default} in a string\n *\n * @param value - String potentially containing env var references\n * @returns String with env vars substituted\n *\n * @example\n * substituteEnvVars('${env:NODE_ENV:-development}')\n * // Returns 'production' if NODE_ENV=production, else 'development'\n */\nfunction substituteEnvVars(value: string): string {\n return value.replaceAll(\n ENV_VAR_PATTERN,\n (_match, varName: string, defaultValue?: string) => {\n const envValue = process.env[varName];\n if (envValue !== undefined) return envValue;\n if (defaultValue !== undefined) return defaultValue;\n console.warn(\n `[autotel] Environment variable ${varName} not set and no default provided`,\n );\n return '';\n },\n );\n}\n\n/**\n * Recursively substitute env vars in an object\n *\n * @param obj - Object to process\n * @returns Object with all string values having env vars substituted\n */\nfunction substituteEnvVarsDeep(obj: unknown): unknown {\n if (typeof obj === 'string') {\n return substituteEnvVars(obj);\n }\n if (Array.isArray(obj)) {\n return obj.map((item) => substituteEnvVarsDeep(item));\n }\n if (obj && typeof obj === 'object') {\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(obj)) {\n result[key] = substituteEnvVarsDeep(value);\n }\n return result;\n }\n return obj;\n}\n\n/**\n * Find YAML config file path\n *\n * Priority:\n * 1. AUTOTEL_CONFIG_FILE env var (explicit path)\n * 2. autotel.yaml in cwd (convention)\n * 3. autotel.yml in cwd (alternative extension)\n *\n * @returns File path if found, null otherwise\n */\nfunction findConfigFile(): string | null {\n // Check env var first (explicit takes priority)\n const envPath = process.env.AUTOTEL_CONFIG_FILE;\n if (envPath) {\n const resolved = path.resolve(envPath);\n if (existsSync(resolved)) return resolved;\n console.warn(`[autotel] Config file not found: ${envPath}`);\n return null;\n }\n\n // Auto-discover autotel.yaml in cwd\n const conventionPath = path.resolve(process.cwd(), 'autotel.yaml');\n if (existsSync(conventionPath)) return conventionPath;\n\n // Also check .yml extension\n const altPath = path.resolve(process.cwd(), 'autotel.yml');\n if (existsSync(altPath)) return altPath;\n\n return null;\n}\n\n/**\n * Convert YAML config structure to AutotelConfig\n *\n * @param yaml - Parsed and env-substituted YAML config\n * @returns Partial AutotelConfig ready for merging\n */\nfunction yamlToAutotelConfig(yaml: YamlConfig): Partial<AutotelConfig> {\n const config: Partial<AutotelConfig> = {};\n\n // Service configuration\n if (yaml.service?.name) config.service = yaml.service.name;\n if (yaml.service?.version) config.version = yaml.service.version;\n if (yaml.service?.environment) config.environment = yaml.service.environment;\n\n // Exporter configuration\n if (yaml.exporter?.endpoint) config.endpoint = yaml.exporter.endpoint;\n if (yaml.exporter?.protocol) config.protocol = yaml.exporter.protocol;\n if (yaml.exporter?.headers) config.headers = yaml.exporter.headers;\n\n // Resource attributes (flattened)\n if (yaml.resource) config.resourceAttributes = yaml.resource;\n\n // Integrations\n if (yaml.autoInstrumentations)\n config.autoInstrumentations = yaml.autoInstrumentations;\n\n // Debug mode\n if (yaml.debug !== undefined) config.debug = yaml.debug;\n\n // Sampling configuration\n if (yaml.sampling?.preset) {\n warnOnIgnoredPresetOverrides(yaml.sampling);\n config.sampling = yaml.sampling.preset;\n } else {\n const sampler = createSamplerFromYaml(yaml.sampling);\n if (sampler) config.sampler = sampler;\n }\n\n return config;\n}\n\nfunction createSamplerFromYaml(\n sampling?: YamlConfig['sampling'],\n): AutotelConfig['sampler'] {\n if (!sampling) return undefined;\n if (sampling.preset) return undefined;\n\n const type = sampling.type ?? 'adaptive';\n\n try {\n switch (type) {\n case 'adaptive': {\n return new AdaptiveSampler({\n baselineSampleRate: sampling.baseline_rate,\n alwaysSampleErrors: sampling.always_sample_errors,\n alwaysSampleSlow: sampling.always_sample_slow,\n slowThresholdMs: sampling.slow_threshold_ms,\n });\n }\n case 'always_on': {\n return new AlwaysSampler();\n }\n case 'always_off': {\n return new NeverSampler();\n }\n case 'ratio': {\n if (sampling.ratio === undefined) {\n console.warn(\n '[autotel] sampling.ratio missing in YAML sampling config. Falling back to adaptive sampler.',\n );\n return new AdaptiveSampler();\n }\n return new RandomSampler(sampling.ratio);\n }\n default: {\n console.warn(\n `[autotel] Unknown sampling type \"${type}\" in YAML config. Falling back to defaults.`,\n );\n return undefined;\n }\n }\n } catch (error) {\n console.warn(\n `[autotel] Failed to configure sampling from YAML: ${error instanceof Error ? error.message : String(error)}`,\n );\n return undefined;\n }\n}\n\nfunction warnOnIgnoredPresetOverrides(\n sampling: NonNullable<YamlConfig['sampling']>,\n): void {\n const ignoredFields = [\n 'type',\n 'ratio',\n 'baseline_rate',\n 'always_sample_errors',\n 'always_sample_slow',\n 'slow_threshold_ms',\n ].filter((field) => sampling[field as keyof typeof sampling] !== undefined);\n\n if (ignoredFields.length === 0) {\n return;\n }\n\n console.warn(\n `[autotel] sampling.preset=\"${sampling.preset}\" ignores these YAML fields: ${ignoredFields.join(', ')}. ` +\n 'Use the programmatic API with sampler or samplingPresets.*(...) for tuned presets.',\n );\n}\n\n/**\n * Load and parse YAML config file (auto-discovery)\n *\n * Automatically finds and loads autotel.yaml or uses AUTOTEL_CONFIG_FILE.\n * Returns null if no config file found (not an error - YAML config is optional).\n *\n * @returns Partial AutotelConfig or null if no config file found\n *\n * @example\n * const yamlConfig = loadYamlConfig();\n * if (yamlConfig) {\n * init({ ...yamlConfig, debug: true });\n * }\n */\nexport function loadYamlConfig(): Partial<AutotelConfig> | null {\n const filePath = findConfigFile();\n if (!filePath) return null;\n\n try {\n const content = readFileSync(filePath, 'utf8');\n const parseYaml = loadYamlParser();\n const rawYaml = parseYaml(content) as YamlConfig;\n const substituted = substituteEnvVarsDeep(rawYaml) as YamlConfig;\n return yamlToAutotelConfig(substituted);\n } catch (error) {\n console.error(\n `[autotel] Failed to load YAML config from ${filePath}:`,\n error,\n );\n return null;\n }\n}\n\n/**\n * Load YAML config from a specific file path\n *\n * Unlike loadYamlConfig(), this throws if the file cannot be read.\n *\n * @param filePath - Path to YAML config file\n * @returns Partial AutotelConfig\n * @throws Error if file cannot be read or parsed\n *\n * @example\n * import { loadYamlConfigFromFile } from 'autotel/yaml';\n * import { init } from 'autotel';\n *\n * const config = loadYamlConfigFromFile('./config/otel.yaml');\n * init({ ...config, debug: true });\n */\nexport function loadYamlConfigFromFile(\n filePath: string,\n): Partial<AutotelConfig> {\n const resolved = path.resolve(filePath);\n const content = readFileSync(resolved, 'utf8');\n const parseYaml = loadYamlParser();\n const rawYaml = parseYaml(content) as YamlConfig;\n const substituted = substituteEnvVarsDeep(rawYaml) as YamlConfig;\n return yamlToAutotelConfig(substituted);\n}\n\n/**\n * Check if a YAML config file exists (without loading it)\n *\n * @returns true if a config file would be found by loadYamlConfig()\n */\nexport function hasYamlConfig(): boolean {\n return findConfigFile() !== null;\n}\n"]}
@@ -71,7 +71,7 @@ function createBuiltinLogger(service, options) {
71
71
  }
72
72
  log(level, extraOrMessage, message);
73
73
  } else {
74
- log(level, extraOrMessage, void 0);
74
+ log(level, extraOrMessage);
75
75
  }
76
76
  } else {
77
77
  log(level, message || "", extraOrMessage);
@@ -119,7 +119,7 @@ function createBuiltinLogger(service, options) {
119
119
  log("error", extraOrMessage, errorAttrs2);
120
120
  return;
121
121
  }
122
- log("error", extraOrMessage, void 0);
122
+ log("error", extraOrMessage);
123
123
  return;
124
124
  }
125
125
  const { err, ...rest } = extraOrMessage;
@@ -224,5 +224,5 @@ function LoggedOperation(operationNameOrOptions) {
224
224
  }
225
225
 
226
226
  export { LOG_LEVEL, LoggedOperation, autotelLogger, createBuiltinLogger, getActiveLogLevel, getTraceContext, runWithLogLevel };
227
- //# sourceMappingURL=chunk-B33XPEKY.js.map
228
- //# sourceMappingURL=chunk-B33XPEKY.js.map
227
+ //# sourceMappingURL=chunk-55ER2KD5.js.map
228
+ //# sourceMappingURL=chunk-55ER2KD5.js.map