@atrim/instrument-web 0.8.1-dev.6bfb5ec.20260120022327 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -11
- package/package.json +5 -6
- package/target/dist/index.d.ts +354 -11
- package/target/dist/index.js +225 -4350
- package/target/dist/index.js.map +1 -1
package/README.md
CHANGED
|
@@ -293,17 +293,6 @@ Shutdown the SDK gracefully.
|
|
|
293
293
|
|
|
294
294
|
**Returns:** `Promise<void>`
|
|
295
295
|
|
|
296
|
-
## Comparison with Node.js Package
|
|
297
|
-
|
|
298
|
-
| Feature | @atrim/instrument-web | @atrim/instrument-node |
|
|
299
|
-
|---------|----------------------|------------------------|
|
|
300
|
-
| Platform | Browser | Node.js, Bun, Deno |
|
|
301
|
-
| Export Protocol | HTTP only | HTTP + gRPC |
|
|
302
|
-
| Auto-instrumentations | Fetch, XHR, DOM events | HTTP, gRPC, DB, etc. |
|
|
303
|
-
| Effect-TS | ❌ No | ✅ Yes |
|
|
304
|
-
| Bundle Size | <50KB | N/A |
|
|
305
|
-
| Service Detection | Manual | Automatic |
|
|
306
|
-
|
|
307
296
|
## Requirements
|
|
308
297
|
|
|
309
298
|
- **Modern browsers:** Chrome 90+, Firefox 88+, Safari 14+, Edge 90+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atrim/instrument-web",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "OpenTelemetry instrumentation for browsers with centralized YAML configuration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -48,8 +48,7 @@
|
|
|
48
48
|
"LICENSE"
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"
|
|
52
|
-
"effect": "^3.19.14",
|
|
51
|
+
"effect": "^4.1.7",
|
|
53
52
|
"@opentelemetry/api": "^1.9.0",
|
|
54
53
|
"@opentelemetry/auto-instrumentations-web": "^0.54.0",
|
|
55
54
|
"@opentelemetry/exporter-trace-otlp-http": "^0.208.0",
|
|
@@ -57,7 +56,8 @@
|
|
|
57
56
|
"@opentelemetry/resources": "^2.2.0",
|
|
58
57
|
"@opentelemetry/sdk-trace-base": "^2.2.0",
|
|
59
58
|
"@opentelemetry/sdk-trace-web": "^2.2.0",
|
|
60
|
-
"yaml": "^2.8.1"
|
|
59
|
+
"yaml": "^2.8.1",
|
|
60
|
+
"zod": "^4.6.6"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"@opentelemetry/context-zone": "^2.0.0"
|
|
@@ -76,8 +76,7 @@
|
|
|
76
76
|
"tsup": "^8.0.1",
|
|
77
77
|
"tsx": "^4.7.0",
|
|
78
78
|
"typescript": "^5.7.2",
|
|
79
|
-
"vitest": "^4.0.16"
|
|
80
|
-
"@atrim/instrument-core": "0.8.0"
|
|
79
|
+
"vitest": "^4.0.16"
|
|
81
80
|
},
|
|
82
81
|
"scripts": {
|
|
83
82
|
"build": "tsup",
|
package/target/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,164 @@
|
|
|
1
1
|
import { WebTracerProvider } from '@opentelemetry/sdk-trace-web';
|
|
2
|
-
import {
|
|
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
|
+
}, z.core.$strip>;
|
|
19
|
+
declare const InstrumentationConfigSchema: z.ZodObject<{
|
|
20
|
+
version: z.ZodString;
|
|
21
|
+
instrumentation: z.ZodObject<{
|
|
22
|
+
enabled: z.ZodBoolean;
|
|
23
|
+
description: z.ZodOptional<z.ZodString>;
|
|
24
|
+
logging: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
25
|
+
on: "on";
|
|
26
|
+
off: "off";
|
|
27
|
+
minimal: "minimal";
|
|
28
|
+
}>>>;
|
|
29
|
+
instrument_patterns: z.ZodArray<z.ZodObject<{
|
|
30
|
+
pattern: z.ZodString;
|
|
31
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
32
|
+
description: z.ZodOptional<z.ZodString>;
|
|
33
|
+
}, z.core.$strip>>;
|
|
34
|
+
ignore_patterns: z.ZodArray<z.ZodObject<{
|
|
35
|
+
pattern: z.ZodString;
|
|
36
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
37
|
+
description: z.ZodOptional<z.ZodString>;
|
|
38
|
+
}, z.core.$strip>>;
|
|
39
|
+
}, z.core.$strip>;
|
|
40
|
+
effect: z.ZodOptional<z.ZodObject<{
|
|
41
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
42
|
+
exporter: z.ZodDefault<z.ZodEnum<{
|
|
43
|
+
unified: "unified";
|
|
44
|
+
standalone: "standalone";
|
|
45
|
+
}>>;
|
|
46
|
+
exporter_config: z.ZodOptional<z.ZodObject<{
|
|
47
|
+
type: z.ZodDefault<z.ZodEnum<{
|
|
48
|
+
none: "none";
|
|
49
|
+
otlp: "otlp";
|
|
50
|
+
console: "console";
|
|
51
|
+
}>>;
|
|
52
|
+
endpoint: z.ZodOptional<z.ZodString>;
|
|
53
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
54
|
+
processor: z.ZodDefault<z.ZodEnum<{
|
|
55
|
+
batch: "batch";
|
|
56
|
+
simple: "simple";
|
|
57
|
+
}>>;
|
|
58
|
+
batch: z.ZodOptional<z.ZodObject<{
|
|
59
|
+
scheduled_delay_millis: z.ZodDefault<z.ZodNumber>;
|
|
60
|
+
max_export_batch_size: z.ZodDefault<z.ZodNumber>;
|
|
61
|
+
}, z.core.$strip>>;
|
|
62
|
+
}, z.core.$strip>>;
|
|
63
|
+
auto_extract_metadata: z.ZodBoolean;
|
|
64
|
+
auto_isolation: z.ZodOptional<z.ZodObject<{
|
|
65
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
66
|
+
operators: z.ZodPrefault<z.ZodObject<{
|
|
67
|
+
fiberset_run: z.ZodDefault<z.ZodBoolean>;
|
|
68
|
+
effect_fork: z.ZodDefault<z.ZodBoolean>;
|
|
69
|
+
effect_fork_daemon: z.ZodDefault<z.ZodBoolean>;
|
|
70
|
+
effect_fork_in: z.ZodDefault<z.ZodBoolean>;
|
|
71
|
+
}, z.core.$strip>>;
|
|
72
|
+
tracking: z.ZodPrefault<z.ZodObject<{
|
|
73
|
+
use_span_links: z.ZodDefault<z.ZodBoolean>;
|
|
74
|
+
use_attributes: z.ZodDefault<z.ZodBoolean>;
|
|
75
|
+
capture_logical_parent: z.ZodDefault<z.ZodBoolean>;
|
|
76
|
+
}, z.core.$strip>>;
|
|
77
|
+
attributes: z.ZodPrefault<z.ZodObject<{
|
|
78
|
+
category: z.ZodDefault<z.ZodString>;
|
|
79
|
+
add_metadata: z.ZodDefault<z.ZodBoolean>;
|
|
80
|
+
}, z.core.$strip>>;
|
|
81
|
+
}, z.core.$strip>>;
|
|
82
|
+
auto_instrumentation: z.ZodOptional<z.ZodObject<{
|
|
83
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
84
|
+
granularity: z.ZodDefault<z.ZodEnum<{
|
|
85
|
+
fiber: "fiber";
|
|
86
|
+
operator: "operator";
|
|
87
|
+
}>>;
|
|
88
|
+
span_naming: z.ZodPrefault<z.ZodObject<{
|
|
89
|
+
default: z.ZodDefault<z.ZodString>;
|
|
90
|
+
infer_from_source: z.ZodDefault<z.ZodBoolean>;
|
|
91
|
+
rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
92
|
+
match: z.ZodObject<{
|
|
93
|
+
file: z.ZodOptional<z.ZodString>;
|
|
94
|
+
function: z.ZodOptional<z.ZodString>;
|
|
95
|
+
module: z.ZodOptional<z.ZodString>;
|
|
96
|
+
}, z.core.$strip>;
|
|
97
|
+
name: z.ZodString;
|
|
98
|
+
}, z.core.$strip>>>;
|
|
99
|
+
}, z.core.$strip>>;
|
|
100
|
+
span_relationships: z.ZodPrefault<z.ZodObject<{
|
|
101
|
+
type: z.ZodDefault<z.ZodEnum<{
|
|
102
|
+
"parent-child": "parent-child";
|
|
103
|
+
"span-links": "span-links";
|
|
104
|
+
both: "both";
|
|
105
|
+
}>>;
|
|
106
|
+
link_attributes: z.ZodOptional<z.ZodObject<{
|
|
107
|
+
'link.type': z.ZodDefault<z.ZodString>;
|
|
108
|
+
custom: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
109
|
+
}, z.core.$strip>>;
|
|
110
|
+
}, z.core.$strip>>;
|
|
111
|
+
filter: z.ZodPrefault<z.ZodObject<{
|
|
112
|
+
include: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
113
|
+
exclude: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
114
|
+
}, z.core.$strip>>;
|
|
115
|
+
performance: z.ZodPrefault<z.ZodObject<{
|
|
116
|
+
sampling_rate: z.ZodDefault<z.ZodNumber>;
|
|
117
|
+
min_duration: z.ZodDefault<z.ZodString>;
|
|
118
|
+
max_concurrent: z.ZodDefault<z.ZodNumber>;
|
|
119
|
+
}, z.core.$strip>>;
|
|
120
|
+
metadata: z.ZodPrefault<z.ZodObject<{
|
|
121
|
+
fiber_info: z.ZodDefault<z.ZodBoolean>;
|
|
122
|
+
source_location: z.ZodDefault<z.ZodBoolean>;
|
|
123
|
+
parent_fiber: z.ZodDefault<z.ZodBoolean>;
|
|
124
|
+
}, z.core.$strip>>;
|
|
125
|
+
}, z.core.$strip>>;
|
|
126
|
+
operation_tracing: z.ZodOptional<z.ZodObject<{
|
|
127
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
128
|
+
span_naming: z.ZodPrefault<z.ZodObject<{
|
|
129
|
+
include_location: z.ZodDefault<z.ZodBoolean>;
|
|
130
|
+
template: z.ZodDefault<z.ZodString>;
|
|
131
|
+
}, z.core.$strip>>;
|
|
132
|
+
operations: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
133
|
+
name: z.ZodString;
|
|
134
|
+
span_name: z.ZodOptional<z.ZodString>;
|
|
135
|
+
include_count: z.ZodDefault<z.ZodBoolean>;
|
|
136
|
+
include_stack: z.ZodDefault<z.ZodBoolean>;
|
|
137
|
+
}, z.core.$strip>>>;
|
|
138
|
+
}, z.core.$strip>>;
|
|
139
|
+
}, z.core.$strip>>;
|
|
140
|
+
http: z.ZodOptional<z.ZodObject<{
|
|
141
|
+
ignore_outgoing_urls: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
142
|
+
ignore_incoming_paths: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
143
|
+
require_parent_for_outgoing_spans: z.ZodOptional<z.ZodBoolean>;
|
|
144
|
+
propagate_trace_context: z.ZodOptional<z.ZodObject<{
|
|
145
|
+
strategy: z.ZodDefault<z.ZodEnum<{
|
|
146
|
+
patterns: "patterns";
|
|
147
|
+
all: "all";
|
|
148
|
+
none: "none";
|
|
149
|
+
"same-origin": "same-origin";
|
|
150
|
+
}>>;
|
|
151
|
+
include_urls: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
152
|
+
}, z.core.$strip>>;
|
|
153
|
+
}, z.core.$strip>>;
|
|
154
|
+
}, z.core.$strip>;
|
|
155
|
+
type InstrumentationConfig = z.infer<typeof InstrumentationConfigSchema>;
|
|
156
|
+
/**
|
|
157
|
+
* What a caller may pass in: the schema's input, where defaulted fields (e.g. `logging`) are
|
|
158
|
+
* optional. `InstrumentationConfig` is the validated output, with defaults filled in.
|
|
159
|
+
*/
|
|
160
|
+
type InstrumentationConfigInput = z.input<typeof InstrumentationConfigSchema>;
|
|
161
|
+
type PatternConfig = z.infer<typeof PatternConfigSchema>;
|
|
8
162
|
|
|
9
163
|
/**
|
|
10
164
|
* SDK Initializer for Browser
|
|
@@ -39,7 +193,7 @@ interface SdkInitializationOptions {
|
|
|
39
193
|
/**
|
|
40
194
|
* Inline configuration object (takes precedence over file/URL)
|
|
41
195
|
*/
|
|
42
|
-
config?:
|
|
196
|
+
config?: InstrumentationConfigInput;
|
|
43
197
|
/**
|
|
44
198
|
* OTLP endpoint URL
|
|
45
199
|
* @default 'http://localhost:4318/v1/traces'
|
|
@@ -236,12 +390,137 @@ declare function createOtlpExporter(options?: OtlpExporterOptions): OTLPTraceExp
|
|
|
236
390
|
declare function getOtlpEndpoint(): string;
|
|
237
391
|
|
|
238
392
|
/**
|
|
239
|
-
*
|
|
393
|
+
* Typed error hierarchy for @atrim/instrumentation
|
|
394
|
+
*
|
|
395
|
+
* These errors use Effect's Data.TaggedError for typed error handling
|
|
396
|
+
* with proper discriminated unions.
|
|
397
|
+
*/
|
|
398
|
+
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 & {
|
|
399
|
+
readonly _tag: "ConfigError";
|
|
400
|
+
} & Readonly<A>;
|
|
401
|
+
/**
|
|
402
|
+
* Base error for configuration-related failures
|
|
403
|
+
*/
|
|
404
|
+
declare class ConfigError extends ConfigError_base<{
|
|
405
|
+
reason: string;
|
|
406
|
+
cause?: unknown;
|
|
407
|
+
}> {
|
|
408
|
+
get message(): string;
|
|
409
|
+
}
|
|
410
|
+
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 & {
|
|
411
|
+
readonly _tag: "ConfigUrlError";
|
|
412
|
+
} & Readonly<A>;
|
|
413
|
+
/**
|
|
414
|
+
* Error when fetching configuration from a URL fails
|
|
415
|
+
*/
|
|
416
|
+
declare class ConfigUrlError extends ConfigUrlError_base<{
|
|
417
|
+
reason: string;
|
|
418
|
+
cause?: unknown;
|
|
419
|
+
}> {
|
|
420
|
+
get message(): string;
|
|
421
|
+
}
|
|
422
|
+
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 & {
|
|
423
|
+
readonly _tag: "ConfigValidationError";
|
|
424
|
+
} & Readonly<A>;
|
|
425
|
+
/**
|
|
426
|
+
* Error when configuration validation fails (invalid YAML, schema mismatch)
|
|
427
|
+
*/
|
|
428
|
+
declare class ConfigValidationError extends ConfigValidationError_base<{
|
|
429
|
+
reason: string;
|
|
430
|
+
cause?: unknown;
|
|
431
|
+
}> {
|
|
432
|
+
get message(): string;
|
|
433
|
+
}
|
|
434
|
+
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 & {
|
|
435
|
+
readonly _tag: "ConfigFileError";
|
|
436
|
+
} & Readonly<A>;
|
|
437
|
+
/**
|
|
438
|
+
* Error when reading configuration from a file fails
|
|
439
|
+
*/
|
|
440
|
+
declare class ConfigFileError extends ConfigFileError_base<{
|
|
441
|
+
reason: string;
|
|
442
|
+
cause?: unknown;
|
|
443
|
+
}> {
|
|
444
|
+
get message(): string;
|
|
445
|
+
}
|
|
446
|
+
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 & {
|
|
447
|
+
readonly _tag: "InitializationError";
|
|
448
|
+
} & Readonly<A>;
|
|
449
|
+
/**
|
|
450
|
+
* Error when OpenTelemetry SDK initialization fails
|
|
451
|
+
*/
|
|
452
|
+
declare class InitializationError extends InitializationError_base<{
|
|
453
|
+
reason: string;
|
|
454
|
+
cause?: unknown;
|
|
455
|
+
}> {
|
|
456
|
+
get message(): string;
|
|
457
|
+
}
|
|
458
|
+
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 & {
|
|
459
|
+
readonly _tag: "ExportError";
|
|
460
|
+
} & Readonly<A>;
|
|
461
|
+
/**
|
|
462
|
+
* Error when span export fails (e.g., ECONNREFUSED to collector)
|
|
463
|
+
*/
|
|
464
|
+
declare class ExportError extends ExportError_base<{
|
|
465
|
+
reason: string;
|
|
466
|
+
cause?: unknown;
|
|
467
|
+
}> {
|
|
468
|
+
get message(): string;
|
|
469
|
+
}
|
|
470
|
+
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 & {
|
|
471
|
+
readonly _tag: "ShutdownError";
|
|
472
|
+
} & Readonly<A>;
|
|
473
|
+
/**
|
|
474
|
+
* Error when shutting down the SDK fails
|
|
475
|
+
*/
|
|
476
|
+
declare class ShutdownError extends ShutdownError_base<{
|
|
477
|
+
reason: string;
|
|
478
|
+
cause?: unknown;
|
|
479
|
+
}> {
|
|
480
|
+
get message(): string;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* Browser configuration loader (Effect 4)
|
|
485
|
+
*
|
|
486
|
+
* Provides URI-based configuration loading:
|
|
487
|
+
* - http:// and https:// URIs through HttpClient (HTTPS only)
|
|
488
|
+
* - file:// URIs and relative paths through FileSystem when one is provided;
|
|
489
|
+
* with no FileSystem (the browser), a relative path is fetched against the page origin
|
|
240
490
|
*
|
|
241
|
-
*
|
|
242
|
-
* (No FileSystem in browser)
|
|
491
|
+
* Lived in a separate private core package until the Effect 4 port moved it here.
|
|
243
492
|
*/
|
|
244
493
|
|
|
494
|
+
/**
|
|
495
|
+
* ConfigLoader service interface
|
|
496
|
+
*/
|
|
497
|
+
interface ConfigLoaderService {
|
|
498
|
+
/**
|
|
499
|
+
* Load configuration from a URI
|
|
500
|
+
*
|
|
501
|
+
* Supports:
|
|
502
|
+
* - file:// URIs (uses FileSystem if available)
|
|
503
|
+
* - http:// and https:// URIs (uses HttpClient)
|
|
504
|
+
* - Relative paths (treated as file:// when a FileSystem is provided, http:// otherwise)
|
|
505
|
+
*
|
|
506
|
+
* @param uri - Configuration URI
|
|
507
|
+
* @returns Effect that resolves to validated configuration (NO requirements)
|
|
508
|
+
*/
|
|
509
|
+
readonly loadFromUri: (uri: string) => Effect.Effect<InstrumentationConfig, ConfigError | ConfigFileError | ConfigUrlError | ConfigValidationError>;
|
|
510
|
+
/**
|
|
511
|
+
* Load configuration from inline content (YAML, JSON, or object)
|
|
512
|
+
*
|
|
513
|
+
* @param content - YAML string, JSON string, or plain object
|
|
514
|
+
* @returns Effect that resolves to validated configuration
|
|
515
|
+
*/
|
|
516
|
+
readonly loadFromInline: (content: string | unknown) => Effect.Effect<InstrumentationConfig, ConfigError | ConfigValidationError>;
|
|
517
|
+
}
|
|
518
|
+
declare const ConfigLoader_base: Context.ServiceClass<ConfigLoader, "ConfigLoader", ConfigLoaderService>;
|
|
519
|
+
/**
|
|
520
|
+
* ConfigLoader service key
|
|
521
|
+
*/
|
|
522
|
+
declare class ConfigLoader extends ConfigLoader_base {
|
|
523
|
+
}
|
|
245
524
|
/**
|
|
246
525
|
* Complete ConfigLoader layer with browser platform dependencies
|
|
247
526
|
*
|
|
@@ -268,11 +547,75 @@ declare function loadConfig(uri: string): Promise<InstrumentationConfig>;
|
|
|
268
547
|
*/
|
|
269
548
|
declare function loadConfigFromInline(content: string | unknown): Promise<InstrumentationConfig>;
|
|
270
549
|
|
|
550
|
+
/**
|
|
551
|
+
* Pattern matching utilities
|
|
552
|
+
*
|
|
553
|
+
* Implements efficient pattern-based span filtering with caching.
|
|
554
|
+
*
|
|
555
|
+
* Matching rules:
|
|
556
|
+
* 1. Check ignore patterns first (takes precedence)
|
|
557
|
+
* 2. Check instrument patterns second
|
|
558
|
+
* 3. Default behavior: If no patterns match, span is created (fail-open)
|
|
559
|
+
*/
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* Pattern matcher with compiled regex cache
|
|
563
|
+
*/
|
|
564
|
+
declare class PatternMatcher {
|
|
565
|
+
private ignorePatterns;
|
|
566
|
+
private instrumentPatterns;
|
|
567
|
+
private enabled;
|
|
568
|
+
constructor(config: InstrumentationConfig);
|
|
569
|
+
/**
|
|
570
|
+
* Compile a pattern configuration into a RegExp
|
|
571
|
+
*/
|
|
572
|
+
private compilePattern;
|
|
573
|
+
/**
|
|
574
|
+
* Check if a span should be instrumented
|
|
575
|
+
*
|
|
576
|
+
* Returns true if the span should be created, false otherwise.
|
|
577
|
+
*
|
|
578
|
+
* Logic:
|
|
579
|
+
* 1. If instrumentation disabled globally, return false
|
|
580
|
+
* 2. Check ignore patterns - if any match, return false
|
|
581
|
+
* 3. Check instrument patterns - if any match, return true
|
|
582
|
+
* 4. Default: return true (fail-open - create span if no patterns match)
|
|
583
|
+
*/
|
|
584
|
+
shouldInstrument(spanName: string): boolean;
|
|
585
|
+
/**
|
|
586
|
+
* Get statistics about pattern matching (for debugging/monitoring)
|
|
587
|
+
*/
|
|
588
|
+
getStats(): {
|
|
589
|
+
enabled: boolean;
|
|
590
|
+
ignorePatternCount: number;
|
|
591
|
+
instrumentPatternCount: number;
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* Initialize the global pattern matcher
|
|
596
|
+
*/
|
|
597
|
+
declare function initializePatternMatcher(config: InstrumentationConfig): void;
|
|
598
|
+
/**
|
|
599
|
+
* Check if a span should be instrumented (uses global matcher)
|
|
600
|
+
*
|
|
601
|
+
* This is a convenience function for use without direct access to the matcher instance.
|
|
602
|
+
* If no matcher is initialized, defaults to true (fail-open).
|
|
603
|
+
*/
|
|
604
|
+
declare function shouldInstrumentSpan(spanName: string): boolean;
|
|
605
|
+
/**
|
|
606
|
+
* Get the global pattern matcher (for advanced use cases)
|
|
607
|
+
*/
|
|
608
|
+
declare function getPatternMatcher(): PatternMatcher | null;
|
|
609
|
+
/**
|
|
610
|
+
* Clear the global pattern matcher (useful for testing)
|
|
611
|
+
*/
|
|
612
|
+
declare function clearPatternMatcher(): void;
|
|
613
|
+
|
|
271
614
|
/**
|
|
272
615
|
* Pattern-Based Span Processor for Browser
|
|
273
616
|
*
|
|
274
617
|
* Filters spans based on patterns defined in instrumentation.yaml
|
|
275
|
-
*
|
|
618
|
+
* Uses the shared pattern matcher (./pattern-matcher.ts)
|
|
276
619
|
*/
|
|
277
620
|
|
|
278
621
|
/**
|
|
@@ -297,7 +640,7 @@ declare class PatternSpanProcessor implements SpanProcessor {
|
|
|
297
640
|
* Called when a span is started
|
|
298
641
|
* No-op for this processor
|
|
299
642
|
*/
|
|
300
|
-
onStart(_span: ReadableSpan, _parentContext: Context): void;
|
|
643
|
+
onStart(_span: ReadableSpan, _parentContext: Context$1): void;
|
|
301
644
|
/**
|
|
302
645
|
* Called when a span ends
|
|
303
646
|
* Filters out spans that don't match patterns
|
|
@@ -458,4 +801,4 @@ declare function annotateNavigation(span: Span, options: {
|
|
|
458
801
|
type?: 'client-side' | 'server-side' | 'initial';
|
|
459
802
|
}): void;
|
|
460
803
|
|
|
461
|
-
export { type OtlpExporterOptions, PatternSpanProcessor, type SdkInitializationOptions, WebConfigLoaderLive, annotateCacheOperation, annotateHttpRequest, annotateNavigation, annotateUserInteraction, createOtlpExporter, getOtlpEndpoint, getSdkInstance, initializeInstrumentation, loadConfig, loadConfigFromInline, markSpanError, markSpanSuccess, recordException, resetSdk, setSpanAttributes, shutdownSdk };
|
|
804
|
+
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 };
|