@atrim/instrument-web 0.5.1 → 0.5.4-dev.5f953c6.20251221220614
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/package.json +11 -3
- package/target/dist/index.d.ts +23 -0
- package/target/dist/index.js +34 -4
- package/target/dist/index.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atrim/instrument-web",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4-dev.5f953c6.20251221220614",
|
|
4
4
|
"description": "OpenTelemetry instrumentation for browsers with centralized YAML configuration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -52,7 +52,6 @@
|
|
|
52
52
|
"effect": "^3.19.0",
|
|
53
53
|
"@opentelemetry/api": "^1.9.0",
|
|
54
54
|
"@opentelemetry/auto-instrumentations-web": "^0.54.0",
|
|
55
|
-
"@opentelemetry/context-zone": "^2.2.0",
|
|
56
55
|
"@opentelemetry/exporter-trace-otlp-http": "^0.208.0",
|
|
57
56
|
"@opentelemetry/instrumentation": "^0.208.0",
|
|
58
57
|
"@opentelemetry/resources": "^2.2.0",
|
|
@@ -60,9 +59,18 @@
|
|
|
60
59
|
"@opentelemetry/sdk-trace-web": "^2.2.0",
|
|
61
60
|
"yaml": "^2.8.1"
|
|
62
61
|
},
|
|
62
|
+
"peerDependencies": {
|
|
63
|
+
"@opentelemetry/context-zone": "^2.0.0"
|
|
64
|
+
},
|
|
65
|
+
"peerDependenciesMeta": {
|
|
66
|
+
"@opentelemetry/context-zone": {
|
|
67
|
+
"optional": true
|
|
68
|
+
}
|
|
69
|
+
},
|
|
63
70
|
"devDependencies": {
|
|
71
|
+
"@opentelemetry/context-zone": "^2.2.0",
|
|
64
72
|
"@opentelemetry/semantic-conventions": "^1.38.0",
|
|
65
|
-
"@types/node": "^
|
|
73
|
+
"@types/node": "^25.0.0",
|
|
66
74
|
"@vitest/coverage-v8": "^4.0.8",
|
|
67
75
|
"jsdom": "^24.0.0",
|
|
68
76
|
"tsup": "^8.0.1",
|
package/target/dist/index.d.ts
CHANGED
|
@@ -95,6 +95,29 @@ interface SdkInitializationOptions {
|
|
|
95
95
|
* ```
|
|
96
96
|
*/
|
|
97
97
|
propagateTraceContext?: 'all' | 'none' | 'same-origin' | string[];
|
|
98
|
+
/**
|
|
99
|
+
* Use Zone.js-based context manager for async context propagation
|
|
100
|
+
*
|
|
101
|
+
* By default, we use StackContextManager which is lightweight and doesn't
|
|
102
|
+
* interfere with application behavior. However, it has limited async context
|
|
103
|
+
* propagation.
|
|
104
|
+
*
|
|
105
|
+
* Enable this option if you need context to propagate across async boundaries
|
|
106
|
+
* (e.g., setTimeout, Promise chains). Note that Zone.js monkey-patches many
|
|
107
|
+
* browser APIs which can cause issues with some libraries:
|
|
108
|
+
*
|
|
109
|
+
* - Libraries that call preventDefault() on wheel/touch events may fail
|
|
110
|
+
* - Some React patterns may lose context
|
|
111
|
+
* - Bundle size increases due to Zone.js dependency
|
|
112
|
+
*
|
|
113
|
+
* @default false
|
|
114
|
+
*
|
|
115
|
+
* @example Enable Zone.js context (use with caution)
|
|
116
|
+
* ```typescript
|
|
117
|
+
* useZoneContext: true
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
useZoneContext?: boolean;
|
|
98
121
|
}
|
|
99
122
|
/**
|
|
100
123
|
* Get the current SDK instance
|
package/target/dist/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { WebTracerProvider } from '@opentelemetry/sdk-trace-web';
|
|
1
|
+
import { WebTracerProvider, StackContextManager } from '@opentelemetry/sdk-trace-web';
|
|
2
2
|
import { SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base';
|
|
3
3
|
import { registerInstrumentations } from '@opentelemetry/instrumentation';
|
|
4
4
|
import { getWebAutoInstrumentations } from '@opentelemetry/auto-instrumentations-web';
|
|
5
|
-
import { ZoneContextManager } from '@opentelemetry/context-zone';
|
|
6
5
|
import { Data, Context, Effect, Layer } from 'effect';
|
|
7
6
|
import { FileSystem } from '@effect/platform/FileSystem';
|
|
8
7
|
import * as HttpClient from '@effect/platform/HttpClient';
|
|
@@ -3845,7 +3844,7 @@ ZodNaN.create = (params) => {
|
|
|
3845
3844
|
...processCreateParams(params)
|
|
3846
3845
|
});
|
|
3847
3846
|
};
|
|
3848
|
-
var BRAND = Symbol("zod_brand");
|
|
3847
|
+
var BRAND = /* @__PURE__ */ Symbol("zod_brand");
|
|
3849
3848
|
var ZodBranded = class extends ZodType {
|
|
3850
3849
|
_parse(input) {
|
|
3851
3850
|
const { ctx } = this._processInputParams(input);
|
|
@@ -4120,6 +4119,13 @@ var InstrumentationConfigSchema = external_exports.object({
|
|
|
4120
4119
|
ignore_patterns: external_exports.array(PatternConfigSchema)
|
|
4121
4120
|
}),
|
|
4122
4121
|
effect: external_exports.object({
|
|
4122
|
+
// Enable/disable Effect tracing entirely
|
|
4123
|
+
// When false, EffectInstrumentationLive returns Layer.empty
|
|
4124
|
+
enabled: external_exports.boolean().default(true),
|
|
4125
|
+
// Exporter mode:
|
|
4126
|
+
// - "unified": Use global TracerProvider from Node SDK (recommended, enables filtering)
|
|
4127
|
+
// - "standalone": Use Effect's own OTLP exporter (bypasses Node SDK filtering)
|
|
4128
|
+
exporter: external_exports.enum(["unified", "standalone"]).default("unified"),
|
|
4123
4129
|
auto_extract_metadata: external_exports.boolean(),
|
|
4124
4130
|
auto_isolation: AutoIsolationConfigSchema.optional()
|
|
4125
4131
|
}).optional(),
|
|
@@ -4587,6 +4593,27 @@ function buildPropagateTraceUrls(options, config) {
|
|
|
4587
4593
|
return [];
|
|
4588
4594
|
}
|
|
4589
4595
|
}
|
|
4596
|
+
async function createContextManager(useZoneContext) {
|
|
4597
|
+
if (!useZoneContext) {
|
|
4598
|
+
return new StackContextManager();
|
|
4599
|
+
}
|
|
4600
|
+
if (typeof window !== "undefined") {
|
|
4601
|
+
window.__zone_symbol__PASSIVE_EVENTS = [];
|
|
4602
|
+
console.info(
|
|
4603
|
+
"[@atrim/instrument-web] Zone.js context enabled. Passive events disabled for wheel/touch events to prevent breaking preventDefault()."
|
|
4604
|
+
);
|
|
4605
|
+
}
|
|
4606
|
+
try {
|
|
4607
|
+
const { ZoneContextManager } = await import('@opentelemetry/context-zone');
|
|
4608
|
+
return new ZoneContextManager();
|
|
4609
|
+
} catch (error) {
|
|
4610
|
+
console.warn(
|
|
4611
|
+
"[@atrim/instrument-web] Failed to load ZoneContextManager. Falling back to StackContextManager. Make sure @opentelemetry/context-zone is installed if you need async context propagation.",
|
|
4612
|
+
error
|
|
4613
|
+
);
|
|
4614
|
+
return new StackContextManager();
|
|
4615
|
+
}
|
|
4616
|
+
}
|
|
4590
4617
|
async function initializeSdk(options) {
|
|
4591
4618
|
if (sdkInstance) {
|
|
4592
4619
|
return sdkInstance;
|
|
@@ -4641,8 +4668,11 @@ async function initializeSdk(options) {
|
|
|
4641
4668
|
const provider = new WebTracerProvider({
|
|
4642
4669
|
spanProcessors
|
|
4643
4670
|
});
|
|
4671
|
+
const contextManager = await createContextManager(
|
|
4672
|
+
options.useZoneContext ?? false
|
|
4673
|
+
);
|
|
4644
4674
|
provider.register({
|
|
4645
|
-
contextManager
|
|
4675
|
+
contextManager
|
|
4646
4676
|
});
|
|
4647
4677
|
registerInstrumentations({
|
|
4648
4678
|
instrumentations: [
|