@atrim/instrument-web 0.8.1-dev.6bfb5ec.20260120022327 → 0.9.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.
@@ -1,10 +1,872 @@
1
1
  import { WebTracerProvider } from '@opentelemetry/sdk-trace-web';
2
- import { InstrumentationConfig, ConfigLoader } from '@atrim/instrument-core';
3
- export { ConfigError, ConfigFileError, ConfigUrlError, ConfigValidationError, ExportError, InitializationError, InstrumentationConfig, PatternConfig, PatternMatcher, ShutdownError, clearPatternMatcher, getPatternMatcher, initializePatternMatcher, shouldInstrumentSpan } from '@atrim/instrument-core';
2
+ import { z } from 'zod';
4
3
  import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
5
- import { Layer } from 'effect';
4
+ import { Layer, Context, Effect } from 'effect';
5
+ import * as effect_Cause from 'effect/Cause';
6
+ import * as effect_Types from 'effect/Types';
6
7
  import { SpanProcessor, ReadableSpan } from '@opentelemetry/sdk-trace-base';
7
- import { Context, Span } from '@opentelemetry/api';
8
+ import { Context as Context$1, Span } from '@opentelemetry/api';
9
+
10
+ /**
11
+ * Configuration schema using Zod
12
+ */
13
+
14
+ declare const PatternConfigSchema: z.ZodObject<{
15
+ pattern: z.ZodString;
16
+ enabled: z.ZodOptional<z.ZodBoolean>;
17
+ description: z.ZodOptional<z.ZodString>;
18
+ }, "strip", z.ZodTypeAny, {
19
+ pattern: string;
20
+ enabled?: boolean | undefined;
21
+ description?: string | undefined;
22
+ }, {
23
+ pattern: string;
24
+ enabled?: boolean | undefined;
25
+ description?: string | undefined;
26
+ }>;
27
+ declare const InstrumentationConfigSchema: z.ZodObject<{
28
+ version: z.ZodString;
29
+ instrumentation: z.ZodObject<{
30
+ enabled: z.ZodBoolean;
31
+ description: z.ZodOptional<z.ZodString>;
32
+ logging: z.ZodDefault<z.ZodOptional<z.ZodEnum<["on", "off", "minimal"]>>>;
33
+ instrument_patterns: z.ZodArray<z.ZodObject<{
34
+ pattern: z.ZodString;
35
+ enabled: z.ZodOptional<z.ZodBoolean>;
36
+ description: z.ZodOptional<z.ZodString>;
37
+ }, "strip", z.ZodTypeAny, {
38
+ pattern: string;
39
+ enabled?: boolean | undefined;
40
+ description?: string | undefined;
41
+ }, {
42
+ pattern: string;
43
+ enabled?: boolean | undefined;
44
+ description?: string | undefined;
45
+ }>, "many">;
46
+ ignore_patterns: z.ZodArray<z.ZodObject<{
47
+ pattern: z.ZodString;
48
+ enabled: z.ZodOptional<z.ZodBoolean>;
49
+ description: z.ZodOptional<z.ZodString>;
50
+ }, "strip", z.ZodTypeAny, {
51
+ pattern: string;
52
+ enabled?: boolean | undefined;
53
+ description?: string | undefined;
54
+ }, {
55
+ pattern: string;
56
+ enabled?: boolean | undefined;
57
+ description?: string | undefined;
58
+ }>, "many">;
59
+ }, "strip", z.ZodTypeAny, {
60
+ enabled: boolean;
61
+ logging: "on" | "off" | "minimal";
62
+ instrument_patterns: {
63
+ pattern: string;
64
+ enabled?: boolean | undefined;
65
+ description?: string | undefined;
66
+ }[];
67
+ ignore_patterns: {
68
+ pattern: string;
69
+ enabled?: boolean | undefined;
70
+ description?: string | undefined;
71
+ }[];
72
+ description?: string | undefined;
73
+ }, {
74
+ enabled: boolean;
75
+ instrument_patterns: {
76
+ pattern: string;
77
+ enabled?: boolean | undefined;
78
+ description?: string | undefined;
79
+ }[];
80
+ ignore_patterns: {
81
+ pattern: string;
82
+ enabled?: boolean | undefined;
83
+ description?: string | undefined;
84
+ }[];
85
+ description?: string | undefined;
86
+ logging?: "on" | "off" | "minimal" | undefined;
87
+ }>;
88
+ effect: z.ZodOptional<z.ZodObject<{
89
+ enabled: z.ZodDefault<z.ZodBoolean>;
90
+ exporter: z.ZodDefault<z.ZodEnum<["unified", "standalone"]>>;
91
+ exporter_config: z.ZodOptional<z.ZodObject<{
92
+ type: z.ZodDefault<z.ZodEnum<["otlp", "console", "none"]>>;
93
+ endpoint: z.ZodOptional<z.ZodString>;
94
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
95
+ processor: z.ZodDefault<z.ZodEnum<["batch", "simple"]>>;
96
+ batch: z.ZodOptional<z.ZodObject<{
97
+ scheduled_delay_millis: z.ZodDefault<z.ZodNumber>;
98
+ max_export_batch_size: z.ZodDefault<z.ZodNumber>;
99
+ }, "strip", z.ZodTypeAny, {
100
+ scheduled_delay_millis: number;
101
+ max_export_batch_size: number;
102
+ }, {
103
+ scheduled_delay_millis?: number | undefined;
104
+ max_export_batch_size?: number | undefined;
105
+ }>>;
106
+ }, "strip", z.ZodTypeAny, {
107
+ type: "none" | "otlp" | "console";
108
+ processor: "batch" | "simple";
109
+ endpoint?: string | undefined;
110
+ headers?: Record<string, string> | undefined;
111
+ batch?: {
112
+ scheduled_delay_millis: number;
113
+ max_export_batch_size: number;
114
+ } | undefined;
115
+ }, {
116
+ type?: "none" | "otlp" | "console" | undefined;
117
+ endpoint?: string | undefined;
118
+ headers?: Record<string, string> | undefined;
119
+ batch?: {
120
+ scheduled_delay_millis?: number | undefined;
121
+ max_export_batch_size?: number | undefined;
122
+ } | undefined;
123
+ processor?: "batch" | "simple" | undefined;
124
+ }>>;
125
+ auto_extract_metadata: z.ZodBoolean;
126
+ auto_isolation: z.ZodOptional<z.ZodObject<{
127
+ enabled: z.ZodDefault<z.ZodBoolean>;
128
+ operators: z.ZodDefault<z.ZodObject<{
129
+ fiberset_run: z.ZodDefault<z.ZodBoolean>;
130
+ effect_fork: z.ZodDefault<z.ZodBoolean>;
131
+ effect_fork_daemon: z.ZodDefault<z.ZodBoolean>;
132
+ effect_fork_in: z.ZodDefault<z.ZodBoolean>;
133
+ }, "strip", z.ZodTypeAny, {
134
+ fiberset_run: boolean;
135
+ effect_fork: boolean;
136
+ effect_fork_daemon: boolean;
137
+ effect_fork_in: boolean;
138
+ }, {
139
+ fiberset_run?: boolean | undefined;
140
+ effect_fork?: boolean | undefined;
141
+ effect_fork_daemon?: boolean | undefined;
142
+ effect_fork_in?: boolean | undefined;
143
+ }>>;
144
+ tracking: z.ZodDefault<z.ZodObject<{
145
+ use_span_links: z.ZodDefault<z.ZodBoolean>;
146
+ use_attributes: z.ZodDefault<z.ZodBoolean>;
147
+ capture_logical_parent: z.ZodDefault<z.ZodBoolean>;
148
+ }, "strip", z.ZodTypeAny, {
149
+ use_span_links: boolean;
150
+ use_attributes: boolean;
151
+ capture_logical_parent: boolean;
152
+ }, {
153
+ use_span_links?: boolean | undefined;
154
+ use_attributes?: boolean | undefined;
155
+ capture_logical_parent?: boolean | undefined;
156
+ }>>;
157
+ attributes: z.ZodDefault<z.ZodObject<{
158
+ category: z.ZodDefault<z.ZodString>;
159
+ add_metadata: z.ZodDefault<z.ZodBoolean>;
160
+ }, "strip", z.ZodTypeAny, {
161
+ category: string;
162
+ add_metadata: boolean;
163
+ }, {
164
+ category?: string | undefined;
165
+ add_metadata?: boolean | undefined;
166
+ }>>;
167
+ }, "strip", z.ZodTypeAny, {
168
+ enabled: boolean;
169
+ operators: {
170
+ fiberset_run: boolean;
171
+ effect_fork: boolean;
172
+ effect_fork_daemon: boolean;
173
+ effect_fork_in: boolean;
174
+ };
175
+ tracking: {
176
+ use_span_links: boolean;
177
+ use_attributes: boolean;
178
+ capture_logical_parent: boolean;
179
+ };
180
+ attributes: {
181
+ category: string;
182
+ add_metadata: boolean;
183
+ };
184
+ }, {
185
+ enabled?: boolean | undefined;
186
+ operators?: {
187
+ fiberset_run?: boolean | undefined;
188
+ effect_fork?: boolean | undefined;
189
+ effect_fork_daemon?: boolean | undefined;
190
+ effect_fork_in?: boolean | undefined;
191
+ } | undefined;
192
+ tracking?: {
193
+ use_span_links?: boolean | undefined;
194
+ use_attributes?: boolean | undefined;
195
+ capture_logical_parent?: boolean | undefined;
196
+ } | undefined;
197
+ attributes?: {
198
+ category?: string | undefined;
199
+ add_metadata?: boolean | undefined;
200
+ } | undefined;
201
+ }>>;
202
+ auto_instrumentation: z.ZodOptional<z.ZodObject<{
203
+ enabled: z.ZodDefault<z.ZodBoolean>;
204
+ granularity: z.ZodDefault<z.ZodEnum<["fiber", "operator"]>>;
205
+ span_naming: z.ZodDefault<z.ZodObject<{
206
+ default: z.ZodDefault<z.ZodString>;
207
+ infer_from_source: z.ZodDefault<z.ZodBoolean>;
208
+ rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
209
+ match: z.ZodObject<{
210
+ file: z.ZodOptional<z.ZodString>;
211
+ function: z.ZodOptional<z.ZodString>;
212
+ module: z.ZodOptional<z.ZodString>;
213
+ }, "strip", z.ZodTypeAny, {
214
+ function?: string | undefined;
215
+ file?: string | undefined;
216
+ module?: string | undefined;
217
+ }, {
218
+ function?: string | undefined;
219
+ file?: string | undefined;
220
+ module?: string | undefined;
221
+ }>;
222
+ name: z.ZodString;
223
+ }, "strip", z.ZodTypeAny, {
224
+ match: {
225
+ function?: string | undefined;
226
+ file?: string | undefined;
227
+ module?: string | undefined;
228
+ };
229
+ name: string;
230
+ }, {
231
+ match: {
232
+ function?: string | undefined;
233
+ file?: string | undefined;
234
+ module?: string | undefined;
235
+ };
236
+ name: string;
237
+ }>, "many">>;
238
+ }, "strip", z.ZodTypeAny, {
239
+ default: string;
240
+ infer_from_source: boolean;
241
+ rules: {
242
+ match: {
243
+ function?: string | undefined;
244
+ file?: string | undefined;
245
+ module?: string | undefined;
246
+ };
247
+ name: string;
248
+ }[];
249
+ }, {
250
+ default?: string | undefined;
251
+ infer_from_source?: boolean | undefined;
252
+ rules?: {
253
+ match: {
254
+ function?: string | undefined;
255
+ file?: string | undefined;
256
+ module?: string | undefined;
257
+ };
258
+ name: string;
259
+ }[] | undefined;
260
+ }>>;
261
+ span_relationships: z.ZodDefault<z.ZodObject<{
262
+ type: z.ZodDefault<z.ZodEnum<["parent-child", "span-links", "both"]>>;
263
+ link_attributes: z.ZodOptional<z.ZodObject<{
264
+ 'link.type': z.ZodDefault<z.ZodString>;
265
+ custom: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
266
+ }, "strip", z.ZodTypeAny, {
267
+ 'link.type': string;
268
+ custom?: Record<string, string> | undefined;
269
+ }, {
270
+ custom?: Record<string, string> | undefined;
271
+ 'link.type'?: string | undefined;
272
+ }>>;
273
+ }, "strip", z.ZodTypeAny, {
274
+ type: "parent-child" | "span-links" | "both";
275
+ link_attributes?: {
276
+ 'link.type': string;
277
+ custom?: Record<string, string> | undefined;
278
+ } | undefined;
279
+ }, {
280
+ type?: "parent-child" | "span-links" | "both" | undefined;
281
+ link_attributes?: {
282
+ custom?: Record<string, string> | undefined;
283
+ 'link.type'?: string | undefined;
284
+ } | undefined;
285
+ }>>;
286
+ filter: z.ZodDefault<z.ZodObject<{
287
+ include: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
288
+ exclude: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
289
+ }, "strip", z.ZodTypeAny, {
290
+ include: string[];
291
+ exclude: string[];
292
+ }, {
293
+ include?: string[] | undefined;
294
+ exclude?: string[] | undefined;
295
+ }>>;
296
+ performance: z.ZodDefault<z.ZodObject<{
297
+ sampling_rate: z.ZodDefault<z.ZodNumber>;
298
+ min_duration: z.ZodDefault<z.ZodString>;
299
+ max_concurrent: z.ZodDefault<z.ZodNumber>;
300
+ }, "strip", z.ZodTypeAny, {
301
+ sampling_rate: number;
302
+ min_duration: string;
303
+ max_concurrent: number;
304
+ }, {
305
+ sampling_rate?: number | undefined;
306
+ min_duration?: string | undefined;
307
+ max_concurrent?: number | undefined;
308
+ }>>;
309
+ metadata: z.ZodDefault<z.ZodObject<{
310
+ fiber_info: z.ZodDefault<z.ZodBoolean>;
311
+ source_location: z.ZodDefault<z.ZodBoolean>;
312
+ parent_fiber: z.ZodDefault<z.ZodBoolean>;
313
+ }, "strip", z.ZodTypeAny, {
314
+ fiber_info: boolean;
315
+ source_location: boolean;
316
+ parent_fiber: boolean;
317
+ }, {
318
+ fiber_info?: boolean | undefined;
319
+ source_location?: boolean | undefined;
320
+ parent_fiber?: boolean | undefined;
321
+ }>>;
322
+ }, "strip", z.ZodTypeAny, {
323
+ enabled: boolean;
324
+ filter: {
325
+ include: string[];
326
+ exclude: string[];
327
+ };
328
+ granularity: "fiber" | "operator";
329
+ span_naming: {
330
+ default: string;
331
+ infer_from_source: boolean;
332
+ rules: {
333
+ match: {
334
+ function?: string | undefined;
335
+ file?: string | undefined;
336
+ module?: string | undefined;
337
+ };
338
+ name: string;
339
+ }[];
340
+ };
341
+ span_relationships: {
342
+ type: "parent-child" | "span-links" | "both";
343
+ link_attributes?: {
344
+ 'link.type': string;
345
+ custom?: Record<string, string> | undefined;
346
+ } | undefined;
347
+ };
348
+ performance: {
349
+ sampling_rate: number;
350
+ min_duration: string;
351
+ max_concurrent: number;
352
+ };
353
+ metadata: {
354
+ fiber_info: boolean;
355
+ source_location: boolean;
356
+ parent_fiber: boolean;
357
+ };
358
+ }, {
359
+ enabled?: boolean | undefined;
360
+ filter?: {
361
+ include?: string[] | undefined;
362
+ exclude?: string[] | undefined;
363
+ } | undefined;
364
+ granularity?: "fiber" | "operator" | undefined;
365
+ span_naming?: {
366
+ default?: string | undefined;
367
+ infer_from_source?: boolean | undefined;
368
+ rules?: {
369
+ match: {
370
+ function?: string | undefined;
371
+ file?: string | undefined;
372
+ module?: string | undefined;
373
+ };
374
+ name: string;
375
+ }[] | undefined;
376
+ } | undefined;
377
+ span_relationships?: {
378
+ type?: "parent-child" | "span-links" | "both" | undefined;
379
+ link_attributes?: {
380
+ custom?: Record<string, string> | undefined;
381
+ 'link.type'?: string | undefined;
382
+ } | undefined;
383
+ } | undefined;
384
+ performance?: {
385
+ sampling_rate?: number | undefined;
386
+ min_duration?: string | undefined;
387
+ max_concurrent?: number | undefined;
388
+ } | undefined;
389
+ metadata?: {
390
+ fiber_info?: boolean | undefined;
391
+ source_location?: boolean | undefined;
392
+ parent_fiber?: boolean | undefined;
393
+ } | undefined;
394
+ }>>;
395
+ operation_tracing: z.ZodOptional<z.ZodObject<{
396
+ enabled: z.ZodDefault<z.ZodBoolean>;
397
+ span_naming: z.ZodDefault<z.ZodObject<{
398
+ include_location: z.ZodDefault<z.ZodBoolean>;
399
+ template: z.ZodDefault<z.ZodString>;
400
+ }, "strip", z.ZodTypeAny, {
401
+ include_location: boolean;
402
+ template: string;
403
+ }, {
404
+ include_location?: boolean | undefined;
405
+ template?: string | undefined;
406
+ }>>;
407
+ operations: z.ZodDefault<z.ZodArray<z.ZodObject<{
408
+ name: z.ZodString;
409
+ span_name: z.ZodOptional<z.ZodString>;
410
+ include_count: z.ZodDefault<z.ZodBoolean>;
411
+ include_stack: z.ZodDefault<z.ZodBoolean>;
412
+ }, "strip", z.ZodTypeAny, {
413
+ name: string;
414
+ include_count: boolean;
415
+ include_stack: boolean;
416
+ span_name?: string | undefined;
417
+ }, {
418
+ name: string;
419
+ span_name?: string | undefined;
420
+ include_count?: boolean | undefined;
421
+ include_stack?: boolean | undefined;
422
+ }>, "many">>;
423
+ }, "strip", z.ZodTypeAny, {
424
+ enabled: boolean;
425
+ span_naming: {
426
+ include_location: boolean;
427
+ template: string;
428
+ };
429
+ operations: {
430
+ name: string;
431
+ include_count: boolean;
432
+ include_stack: boolean;
433
+ span_name?: string | undefined;
434
+ }[];
435
+ }, {
436
+ enabled?: boolean | undefined;
437
+ span_naming?: {
438
+ include_location?: boolean | undefined;
439
+ template?: string | undefined;
440
+ } | undefined;
441
+ operations?: {
442
+ name: string;
443
+ span_name?: string | undefined;
444
+ include_count?: boolean | undefined;
445
+ include_stack?: boolean | undefined;
446
+ }[] | undefined;
447
+ }>>;
448
+ }, "strip", z.ZodTypeAny, {
449
+ enabled: boolean;
450
+ exporter: "unified" | "standalone";
451
+ auto_extract_metadata: boolean;
452
+ exporter_config?: {
453
+ type: "none" | "otlp" | "console";
454
+ processor: "batch" | "simple";
455
+ endpoint?: string | undefined;
456
+ headers?: Record<string, string> | undefined;
457
+ batch?: {
458
+ scheduled_delay_millis: number;
459
+ max_export_batch_size: number;
460
+ } | undefined;
461
+ } | undefined;
462
+ auto_isolation?: {
463
+ enabled: boolean;
464
+ operators: {
465
+ fiberset_run: boolean;
466
+ effect_fork: boolean;
467
+ effect_fork_daemon: boolean;
468
+ effect_fork_in: boolean;
469
+ };
470
+ tracking: {
471
+ use_span_links: boolean;
472
+ use_attributes: boolean;
473
+ capture_logical_parent: boolean;
474
+ };
475
+ attributes: {
476
+ category: string;
477
+ add_metadata: boolean;
478
+ };
479
+ } | undefined;
480
+ auto_instrumentation?: {
481
+ enabled: boolean;
482
+ filter: {
483
+ include: string[];
484
+ exclude: string[];
485
+ };
486
+ granularity: "fiber" | "operator";
487
+ span_naming: {
488
+ default: string;
489
+ infer_from_source: boolean;
490
+ rules: {
491
+ match: {
492
+ function?: string | undefined;
493
+ file?: string | undefined;
494
+ module?: string | undefined;
495
+ };
496
+ name: string;
497
+ }[];
498
+ };
499
+ span_relationships: {
500
+ type: "parent-child" | "span-links" | "both";
501
+ link_attributes?: {
502
+ 'link.type': string;
503
+ custom?: Record<string, string> | undefined;
504
+ } | undefined;
505
+ };
506
+ performance: {
507
+ sampling_rate: number;
508
+ min_duration: string;
509
+ max_concurrent: number;
510
+ };
511
+ metadata: {
512
+ fiber_info: boolean;
513
+ source_location: boolean;
514
+ parent_fiber: boolean;
515
+ };
516
+ } | undefined;
517
+ operation_tracing?: {
518
+ enabled: boolean;
519
+ span_naming: {
520
+ include_location: boolean;
521
+ template: string;
522
+ };
523
+ operations: {
524
+ name: string;
525
+ include_count: boolean;
526
+ include_stack: boolean;
527
+ span_name?: string | undefined;
528
+ }[];
529
+ } | undefined;
530
+ }, {
531
+ auto_extract_metadata: boolean;
532
+ enabled?: boolean | undefined;
533
+ exporter?: "unified" | "standalone" | undefined;
534
+ exporter_config?: {
535
+ type?: "none" | "otlp" | "console" | undefined;
536
+ endpoint?: string | undefined;
537
+ headers?: Record<string, string> | undefined;
538
+ batch?: {
539
+ scheduled_delay_millis?: number | undefined;
540
+ max_export_batch_size?: number | undefined;
541
+ } | undefined;
542
+ processor?: "batch" | "simple" | undefined;
543
+ } | undefined;
544
+ auto_isolation?: {
545
+ enabled?: boolean | undefined;
546
+ operators?: {
547
+ fiberset_run?: boolean | undefined;
548
+ effect_fork?: boolean | undefined;
549
+ effect_fork_daemon?: boolean | undefined;
550
+ effect_fork_in?: boolean | undefined;
551
+ } | undefined;
552
+ tracking?: {
553
+ use_span_links?: boolean | undefined;
554
+ use_attributes?: boolean | undefined;
555
+ capture_logical_parent?: boolean | undefined;
556
+ } | undefined;
557
+ attributes?: {
558
+ category?: string | undefined;
559
+ add_metadata?: boolean | undefined;
560
+ } | undefined;
561
+ } | undefined;
562
+ auto_instrumentation?: {
563
+ enabled?: boolean | undefined;
564
+ filter?: {
565
+ include?: string[] | undefined;
566
+ exclude?: string[] | undefined;
567
+ } | undefined;
568
+ granularity?: "fiber" | "operator" | undefined;
569
+ span_naming?: {
570
+ default?: string | undefined;
571
+ infer_from_source?: boolean | undefined;
572
+ rules?: {
573
+ match: {
574
+ function?: string | undefined;
575
+ file?: string | undefined;
576
+ module?: string | undefined;
577
+ };
578
+ name: string;
579
+ }[] | undefined;
580
+ } | undefined;
581
+ span_relationships?: {
582
+ type?: "parent-child" | "span-links" | "both" | undefined;
583
+ link_attributes?: {
584
+ custom?: Record<string, string> | undefined;
585
+ 'link.type'?: string | undefined;
586
+ } | undefined;
587
+ } | undefined;
588
+ performance?: {
589
+ sampling_rate?: number | undefined;
590
+ min_duration?: string | undefined;
591
+ max_concurrent?: number | undefined;
592
+ } | undefined;
593
+ metadata?: {
594
+ fiber_info?: boolean | undefined;
595
+ source_location?: boolean | undefined;
596
+ parent_fiber?: boolean | undefined;
597
+ } | undefined;
598
+ } | undefined;
599
+ operation_tracing?: {
600
+ enabled?: boolean | undefined;
601
+ span_naming?: {
602
+ include_location?: boolean | undefined;
603
+ template?: string | undefined;
604
+ } | undefined;
605
+ operations?: {
606
+ name: string;
607
+ span_name?: string | undefined;
608
+ include_count?: boolean | undefined;
609
+ include_stack?: boolean | undefined;
610
+ }[] | undefined;
611
+ } | undefined;
612
+ }>>;
613
+ http: z.ZodOptional<z.ZodObject<{
614
+ ignore_outgoing_urls: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
615
+ ignore_incoming_paths: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
616
+ require_parent_for_outgoing_spans: z.ZodOptional<z.ZodBoolean>;
617
+ propagate_trace_context: z.ZodOptional<z.ZodObject<{
618
+ strategy: z.ZodDefault<z.ZodEnum<["all", "none", "same-origin", "patterns"]>>;
619
+ include_urls: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
620
+ }, "strip", z.ZodTypeAny, {
621
+ strategy: "all" | "none" | "same-origin" | "patterns";
622
+ include_urls?: string[] | undefined;
623
+ }, {
624
+ strategy?: "all" | "none" | "same-origin" | "patterns" | undefined;
625
+ include_urls?: string[] | undefined;
626
+ }>>;
627
+ }, "strip", z.ZodTypeAny, {
628
+ ignore_outgoing_urls?: string[] | undefined;
629
+ ignore_incoming_paths?: string[] | undefined;
630
+ require_parent_for_outgoing_spans?: boolean | undefined;
631
+ propagate_trace_context?: {
632
+ strategy: "all" | "none" | "same-origin" | "patterns";
633
+ include_urls?: string[] | undefined;
634
+ } | undefined;
635
+ }, {
636
+ ignore_outgoing_urls?: string[] | undefined;
637
+ ignore_incoming_paths?: string[] | undefined;
638
+ require_parent_for_outgoing_spans?: boolean | undefined;
639
+ propagate_trace_context?: {
640
+ strategy?: "all" | "none" | "same-origin" | "patterns" | undefined;
641
+ include_urls?: string[] | undefined;
642
+ } | undefined;
643
+ }>>;
644
+ }, "strip", z.ZodTypeAny, {
645
+ version: string;
646
+ instrumentation: {
647
+ enabled: boolean;
648
+ logging: "on" | "off" | "minimal";
649
+ instrument_patterns: {
650
+ pattern: string;
651
+ enabled?: boolean | undefined;
652
+ description?: string | undefined;
653
+ }[];
654
+ ignore_patterns: {
655
+ pattern: string;
656
+ enabled?: boolean | undefined;
657
+ description?: string | undefined;
658
+ }[];
659
+ description?: string | undefined;
660
+ };
661
+ effect?: {
662
+ enabled: boolean;
663
+ exporter: "unified" | "standalone";
664
+ auto_extract_metadata: boolean;
665
+ exporter_config?: {
666
+ type: "none" | "otlp" | "console";
667
+ processor: "batch" | "simple";
668
+ endpoint?: string | undefined;
669
+ headers?: Record<string, string> | undefined;
670
+ batch?: {
671
+ scheduled_delay_millis: number;
672
+ max_export_batch_size: number;
673
+ } | undefined;
674
+ } | undefined;
675
+ auto_isolation?: {
676
+ enabled: boolean;
677
+ operators: {
678
+ fiberset_run: boolean;
679
+ effect_fork: boolean;
680
+ effect_fork_daemon: boolean;
681
+ effect_fork_in: boolean;
682
+ };
683
+ tracking: {
684
+ use_span_links: boolean;
685
+ use_attributes: boolean;
686
+ capture_logical_parent: boolean;
687
+ };
688
+ attributes: {
689
+ category: string;
690
+ add_metadata: boolean;
691
+ };
692
+ } | undefined;
693
+ auto_instrumentation?: {
694
+ enabled: boolean;
695
+ filter: {
696
+ include: string[];
697
+ exclude: string[];
698
+ };
699
+ granularity: "fiber" | "operator";
700
+ span_naming: {
701
+ default: string;
702
+ infer_from_source: boolean;
703
+ rules: {
704
+ match: {
705
+ function?: string | undefined;
706
+ file?: string | undefined;
707
+ module?: string | undefined;
708
+ };
709
+ name: string;
710
+ }[];
711
+ };
712
+ span_relationships: {
713
+ type: "parent-child" | "span-links" | "both";
714
+ link_attributes?: {
715
+ 'link.type': string;
716
+ custom?: Record<string, string> | undefined;
717
+ } | undefined;
718
+ };
719
+ performance: {
720
+ sampling_rate: number;
721
+ min_duration: string;
722
+ max_concurrent: number;
723
+ };
724
+ metadata: {
725
+ fiber_info: boolean;
726
+ source_location: boolean;
727
+ parent_fiber: boolean;
728
+ };
729
+ } | undefined;
730
+ operation_tracing?: {
731
+ enabled: boolean;
732
+ span_naming: {
733
+ include_location: boolean;
734
+ template: string;
735
+ };
736
+ operations: {
737
+ name: string;
738
+ include_count: boolean;
739
+ include_stack: boolean;
740
+ span_name?: string | undefined;
741
+ }[];
742
+ } | undefined;
743
+ } | undefined;
744
+ http?: {
745
+ ignore_outgoing_urls?: string[] | undefined;
746
+ ignore_incoming_paths?: string[] | undefined;
747
+ require_parent_for_outgoing_spans?: boolean | undefined;
748
+ propagate_trace_context?: {
749
+ strategy: "all" | "none" | "same-origin" | "patterns";
750
+ include_urls?: string[] | undefined;
751
+ } | undefined;
752
+ } | undefined;
753
+ }, {
754
+ version: string;
755
+ instrumentation: {
756
+ enabled: boolean;
757
+ instrument_patterns: {
758
+ pattern: string;
759
+ enabled?: boolean | undefined;
760
+ description?: string | undefined;
761
+ }[];
762
+ ignore_patterns: {
763
+ pattern: string;
764
+ enabled?: boolean | undefined;
765
+ description?: string | undefined;
766
+ }[];
767
+ description?: string | undefined;
768
+ logging?: "on" | "off" | "minimal" | undefined;
769
+ };
770
+ effect?: {
771
+ auto_extract_metadata: boolean;
772
+ enabled?: boolean | undefined;
773
+ exporter?: "unified" | "standalone" | undefined;
774
+ exporter_config?: {
775
+ type?: "none" | "otlp" | "console" | undefined;
776
+ endpoint?: string | undefined;
777
+ headers?: Record<string, string> | undefined;
778
+ batch?: {
779
+ scheduled_delay_millis?: number | undefined;
780
+ max_export_batch_size?: number | undefined;
781
+ } | undefined;
782
+ processor?: "batch" | "simple" | undefined;
783
+ } | undefined;
784
+ auto_isolation?: {
785
+ enabled?: boolean | undefined;
786
+ operators?: {
787
+ fiberset_run?: boolean | undefined;
788
+ effect_fork?: boolean | undefined;
789
+ effect_fork_daemon?: boolean | undefined;
790
+ effect_fork_in?: boolean | undefined;
791
+ } | undefined;
792
+ tracking?: {
793
+ use_span_links?: boolean | undefined;
794
+ use_attributes?: boolean | undefined;
795
+ capture_logical_parent?: boolean | undefined;
796
+ } | undefined;
797
+ attributes?: {
798
+ category?: string | undefined;
799
+ add_metadata?: boolean | undefined;
800
+ } | undefined;
801
+ } | undefined;
802
+ auto_instrumentation?: {
803
+ enabled?: boolean | undefined;
804
+ filter?: {
805
+ include?: string[] | undefined;
806
+ exclude?: string[] | undefined;
807
+ } | undefined;
808
+ granularity?: "fiber" | "operator" | undefined;
809
+ span_naming?: {
810
+ default?: string | undefined;
811
+ infer_from_source?: boolean | undefined;
812
+ rules?: {
813
+ match: {
814
+ function?: string | undefined;
815
+ file?: string | undefined;
816
+ module?: string | undefined;
817
+ };
818
+ name: string;
819
+ }[] | undefined;
820
+ } | undefined;
821
+ span_relationships?: {
822
+ type?: "parent-child" | "span-links" | "both" | undefined;
823
+ link_attributes?: {
824
+ custom?: Record<string, string> | undefined;
825
+ 'link.type'?: string | undefined;
826
+ } | undefined;
827
+ } | undefined;
828
+ performance?: {
829
+ sampling_rate?: number | undefined;
830
+ min_duration?: string | undefined;
831
+ max_concurrent?: number | undefined;
832
+ } | undefined;
833
+ metadata?: {
834
+ fiber_info?: boolean | undefined;
835
+ source_location?: boolean | undefined;
836
+ parent_fiber?: boolean | undefined;
837
+ } | undefined;
838
+ } | undefined;
839
+ operation_tracing?: {
840
+ enabled?: boolean | undefined;
841
+ span_naming?: {
842
+ include_location?: boolean | undefined;
843
+ template?: string | undefined;
844
+ } | undefined;
845
+ operations?: {
846
+ name: string;
847
+ span_name?: string | undefined;
848
+ include_count?: boolean | undefined;
849
+ include_stack?: boolean | undefined;
850
+ }[] | undefined;
851
+ } | undefined;
852
+ } | undefined;
853
+ http?: {
854
+ ignore_outgoing_urls?: string[] | undefined;
855
+ ignore_incoming_paths?: string[] | undefined;
856
+ require_parent_for_outgoing_spans?: boolean | undefined;
857
+ propagate_trace_context?: {
858
+ strategy?: "all" | "none" | "same-origin" | "patterns" | undefined;
859
+ include_urls?: string[] | undefined;
860
+ } | undefined;
861
+ } | undefined;
862
+ }>;
863
+ type InstrumentationConfig = z.infer<typeof InstrumentationConfigSchema>;
864
+ /**
865
+ * What a caller may pass in: the schema's input, where defaulted fields (e.g. `logging`) are
866
+ * optional. `InstrumentationConfig` is the validated output, with defaults filled in.
867
+ */
868
+ type InstrumentationConfigInput = z.input<typeof InstrumentationConfigSchema>;
869
+ type PatternConfig = z.infer<typeof PatternConfigSchema>;
8
870
 
9
871
  /**
10
872
  * SDK Initializer for Browser
@@ -39,7 +901,7 @@ interface SdkInitializationOptions {
39
901
  /**
40
902
  * Inline configuration object (takes precedence over file/URL)
41
903
  */
42
- config?: InstrumentationConfig;
904
+ config?: InstrumentationConfigInput;
43
905
  /**
44
906
  * OTLP endpoint URL
45
907
  * @default 'http://localhost:4318/v1/traces'
@@ -236,12 +1098,137 @@ declare function createOtlpExporter(options?: OtlpExporterOptions): OTLPTraceExp
236
1098
  declare function getOtlpEndpoint(): string;
237
1099
 
238
1100
  /**
239
- * Browser configuration loader using Effect Platform
1101
+ * Typed error hierarchy for @atrim/instrumentation
1102
+ *
1103
+ * These errors use Effect's Data.TaggedError for typed error handling
1104
+ * with proper discriminated unions.
1105
+ */
1106
+ declare const ConfigError_base: new <A extends Record<string, any> = {}>(args: effect_Types.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => effect_Cause.YieldableError & {
1107
+ readonly _tag: "ConfigError";
1108
+ } & Readonly<A>;
1109
+ /**
1110
+ * Base error for configuration-related failures
1111
+ */
1112
+ declare class ConfigError extends ConfigError_base<{
1113
+ reason: string;
1114
+ cause?: unknown;
1115
+ }> {
1116
+ get message(): string;
1117
+ }
1118
+ declare const ConfigUrlError_base: new <A extends Record<string, any> = {}>(args: effect_Types.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => effect_Cause.YieldableError & {
1119
+ readonly _tag: "ConfigUrlError";
1120
+ } & Readonly<A>;
1121
+ /**
1122
+ * Error when fetching configuration from a URL fails
1123
+ */
1124
+ declare class ConfigUrlError extends ConfigUrlError_base<{
1125
+ reason: string;
1126
+ cause?: unknown;
1127
+ }> {
1128
+ get message(): string;
1129
+ }
1130
+ declare const ConfigValidationError_base: new <A extends Record<string, any> = {}>(args: effect_Types.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => effect_Cause.YieldableError & {
1131
+ readonly _tag: "ConfigValidationError";
1132
+ } & Readonly<A>;
1133
+ /**
1134
+ * Error when configuration validation fails (invalid YAML, schema mismatch)
1135
+ */
1136
+ declare class ConfigValidationError extends ConfigValidationError_base<{
1137
+ reason: string;
1138
+ cause?: unknown;
1139
+ }> {
1140
+ get message(): string;
1141
+ }
1142
+ declare const ConfigFileError_base: new <A extends Record<string, any> = {}>(args: effect_Types.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => effect_Cause.YieldableError & {
1143
+ readonly _tag: "ConfigFileError";
1144
+ } & Readonly<A>;
1145
+ /**
1146
+ * Error when reading configuration from a file fails
1147
+ */
1148
+ declare class ConfigFileError extends ConfigFileError_base<{
1149
+ reason: string;
1150
+ cause?: unknown;
1151
+ }> {
1152
+ get message(): string;
1153
+ }
1154
+ declare const InitializationError_base: new <A extends Record<string, any> = {}>(args: effect_Types.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => effect_Cause.YieldableError & {
1155
+ readonly _tag: "InitializationError";
1156
+ } & Readonly<A>;
1157
+ /**
1158
+ * Error when OpenTelemetry SDK initialization fails
1159
+ */
1160
+ declare class InitializationError extends InitializationError_base<{
1161
+ reason: string;
1162
+ cause?: unknown;
1163
+ }> {
1164
+ get message(): string;
1165
+ }
1166
+ declare const ExportError_base: new <A extends Record<string, any> = {}>(args: effect_Types.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => effect_Cause.YieldableError & {
1167
+ readonly _tag: "ExportError";
1168
+ } & Readonly<A>;
1169
+ /**
1170
+ * Error when span export fails (e.g., ECONNREFUSED to collector)
1171
+ */
1172
+ declare class ExportError extends ExportError_base<{
1173
+ reason: string;
1174
+ cause?: unknown;
1175
+ }> {
1176
+ get message(): string;
1177
+ }
1178
+ declare const ShutdownError_base: new <A extends Record<string, any> = {}>(args: effect_Types.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => effect_Cause.YieldableError & {
1179
+ readonly _tag: "ShutdownError";
1180
+ } & Readonly<A>;
1181
+ /**
1182
+ * Error when shutting down the SDK fails
1183
+ */
1184
+ declare class ShutdownError extends ShutdownError_base<{
1185
+ reason: string;
1186
+ cause?: unknown;
1187
+ }> {
1188
+ get message(): string;
1189
+ }
1190
+
1191
+ /**
1192
+ * Browser configuration loader (Effect 4)
1193
+ *
1194
+ * Provides URI-based configuration loading:
1195
+ * - http:// and https:// URIs through HttpClient (HTTPS only)
1196
+ * - file:// URIs and relative paths through FileSystem when one is provided;
1197
+ * with no FileSystem (the browser), a relative path is fetched against the page origin
240
1198
  *
241
- * Provides HttpClient layer for the core ConfigLoader service
242
- * (No FileSystem in browser)
1199
+ * Lived in a separate private core package until the Effect 4 port moved it here.
243
1200
  */
244
1201
 
1202
+ /**
1203
+ * ConfigLoader service interface
1204
+ */
1205
+ interface ConfigLoaderService {
1206
+ /**
1207
+ * Load configuration from a URI
1208
+ *
1209
+ * Supports:
1210
+ * - file:// URIs (uses FileSystem if available)
1211
+ * - http:// and https:// URIs (uses HttpClient)
1212
+ * - Relative paths (treated as file:// when a FileSystem is provided, http:// otherwise)
1213
+ *
1214
+ * @param uri - Configuration URI
1215
+ * @returns Effect that resolves to validated configuration (NO requirements)
1216
+ */
1217
+ readonly loadFromUri: (uri: string) => Effect.Effect<InstrumentationConfig, ConfigError | ConfigFileError | ConfigUrlError | ConfigValidationError>;
1218
+ /**
1219
+ * Load configuration from inline content (YAML, JSON, or object)
1220
+ *
1221
+ * @param content - YAML string, JSON string, or plain object
1222
+ * @returns Effect that resolves to validated configuration
1223
+ */
1224
+ readonly loadFromInline: (content: string | unknown) => Effect.Effect<InstrumentationConfig, ConfigError | ConfigValidationError>;
1225
+ }
1226
+ declare const ConfigLoader_base: Context.ServiceClass<ConfigLoader, "ConfigLoader", ConfigLoaderService>;
1227
+ /**
1228
+ * ConfigLoader service key
1229
+ */
1230
+ declare class ConfigLoader extends ConfigLoader_base {
1231
+ }
245
1232
  /**
246
1233
  * Complete ConfigLoader layer with browser platform dependencies
247
1234
  *
@@ -268,11 +1255,75 @@ declare function loadConfig(uri: string): Promise<InstrumentationConfig>;
268
1255
  */
269
1256
  declare function loadConfigFromInline(content: string | unknown): Promise<InstrumentationConfig>;
270
1257
 
1258
+ /**
1259
+ * Pattern matching utilities
1260
+ *
1261
+ * Implements efficient pattern-based span filtering with caching.
1262
+ *
1263
+ * Matching rules:
1264
+ * 1. Check ignore patterns first (takes precedence)
1265
+ * 2. Check instrument patterns second
1266
+ * 3. Default behavior: If no patterns match, span is created (fail-open)
1267
+ */
1268
+
1269
+ /**
1270
+ * Pattern matcher with compiled regex cache
1271
+ */
1272
+ declare class PatternMatcher {
1273
+ private ignorePatterns;
1274
+ private instrumentPatterns;
1275
+ private enabled;
1276
+ constructor(config: InstrumentationConfig);
1277
+ /**
1278
+ * Compile a pattern configuration into a RegExp
1279
+ */
1280
+ private compilePattern;
1281
+ /**
1282
+ * Check if a span should be instrumented
1283
+ *
1284
+ * Returns true if the span should be created, false otherwise.
1285
+ *
1286
+ * Logic:
1287
+ * 1. If instrumentation disabled globally, return false
1288
+ * 2. Check ignore patterns - if any match, return false
1289
+ * 3. Check instrument patterns - if any match, return true
1290
+ * 4. Default: return true (fail-open - create span if no patterns match)
1291
+ */
1292
+ shouldInstrument(spanName: string): boolean;
1293
+ /**
1294
+ * Get statistics about pattern matching (for debugging/monitoring)
1295
+ */
1296
+ getStats(): {
1297
+ enabled: boolean;
1298
+ ignorePatternCount: number;
1299
+ instrumentPatternCount: number;
1300
+ };
1301
+ }
1302
+ /**
1303
+ * Initialize the global pattern matcher
1304
+ */
1305
+ declare function initializePatternMatcher(config: InstrumentationConfig): void;
1306
+ /**
1307
+ * Check if a span should be instrumented (uses global matcher)
1308
+ *
1309
+ * This is a convenience function for use without direct access to the matcher instance.
1310
+ * If no matcher is initialized, defaults to true (fail-open).
1311
+ */
1312
+ declare function shouldInstrumentSpan(spanName: string): boolean;
1313
+ /**
1314
+ * Get the global pattern matcher (for advanced use cases)
1315
+ */
1316
+ declare function getPatternMatcher(): PatternMatcher | null;
1317
+ /**
1318
+ * Clear the global pattern matcher (useful for testing)
1319
+ */
1320
+ declare function clearPatternMatcher(): void;
1321
+
271
1322
  /**
272
1323
  * Pattern-Based Span Processor for Browser
273
1324
  *
274
1325
  * Filters spans based on patterns defined in instrumentation.yaml
275
- * Re-uses pattern matching logic from @atrim/instrument-core
1326
+ * Uses the shared pattern matcher (./pattern-matcher.ts)
276
1327
  */
277
1328
 
278
1329
  /**
@@ -297,7 +1348,7 @@ declare class PatternSpanProcessor implements SpanProcessor {
297
1348
  * Called when a span is started
298
1349
  * No-op for this processor
299
1350
  */
300
- onStart(_span: ReadableSpan, _parentContext: Context): void;
1351
+ onStart(_span: ReadableSpan, _parentContext: Context$1): void;
301
1352
  /**
302
1353
  * Called when a span ends
303
1354
  * Filters out spans that don't match patterns
@@ -458,4 +1509,4 @@ declare function annotateNavigation(span: Span, options: {
458
1509
  type?: 'client-side' | 'server-side' | 'initial';
459
1510
  }): void;
460
1511
 
461
- export { type OtlpExporterOptions, PatternSpanProcessor, type SdkInitializationOptions, WebConfigLoaderLive, annotateCacheOperation, annotateHttpRequest, annotateNavigation, annotateUserInteraction, createOtlpExporter, getOtlpEndpoint, getSdkInstance, initializeInstrumentation, loadConfig, loadConfigFromInline, markSpanError, markSpanSuccess, recordException, resetSdk, setSpanAttributes, shutdownSdk };
1512
+ export { ConfigError, ConfigFileError, ConfigUrlError, ConfigValidationError, ExportError, InitializationError, type InstrumentationConfig, type InstrumentationConfigInput, type OtlpExporterOptions, type PatternConfig, PatternMatcher, PatternSpanProcessor, type SdkInitializationOptions, ShutdownError, WebConfigLoaderLive, annotateCacheOperation, annotateHttpRequest, annotateNavigation, annotateUserInteraction, clearPatternMatcher, createOtlpExporter, getOtlpEndpoint, getPatternMatcher, getSdkInstance, initializeInstrumentation, initializePatternMatcher, loadConfig, loadConfigFromInline, markSpanError, markSpanSuccess, recordException, resetSdk, setSpanAttributes, shouldInstrumentSpan, shutdownSdk };