@atrim/instrument-web 0.5.1 → 0.5.3
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 +10 -2
- package/target/dist/index.d.ts +23 -0
- package/target/dist/index.js +27 -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.3",
|
|
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,7 +59,16 @@
|
|
|
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
73
|
"@types/node": "^20.10.0",
|
|
66
74
|
"@vitest/coverage-v8": "^4.0.8",
|
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);
|
|
@@ -4587,6 +4586,27 @@ function buildPropagateTraceUrls(options, config) {
|
|
|
4587
4586
|
return [];
|
|
4588
4587
|
}
|
|
4589
4588
|
}
|
|
4589
|
+
async function createContextManager(useZoneContext) {
|
|
4590
|
+
if (!useZoneContext) {
|
|
4591
|
+
return new StackContextManager();
|
|
4592
|
+
}
|
|
4593
|
+
if (typeof window !== "undefined") {
|
|
4594
|
+
window.__zone_symbol__PASSIVE_EVENTS = [];
|
|
4595
|
+
console.info(
|
|
4596
|
+
"[@atrim/instrument-web] Zone.js context enabled. Passive events disabled for wheel/touch events to prevent breaking preventDefault()."
|
|
4597
|
+
);
|
|
4598
|
+
}
|
|
4599
|
+
try {
|
|
4600
|
+
const { ZoneContextManager } = await import('@opentelemetry/context-zone');
|
|
4601
|
+
return new ZoneContextManager();
|
|
4602
|
+
} catch (error) {
|
|
4603
|
+
console.warn(
|
|
4604
|
+
"[@atrim/instrument-web] Failed to load ZoneContextManager. Falling back to StackContextManager. Make sure @opentelemetry/context-zone is installed if you need async context propagation.",
|
|
4605
|
+
error
|
|
4606
|
+
);
|
|
4607
|
+
return new StackContextManager();
|
|
4608
|
+
}
|
|
4609
|
+
}
|
|
4590
4610
|
async function initializeSdk(options) {
|
|
4591
4611
|
if (sdkInstance) {
|
|
4592
4612
|
return sdkInstance;
|
|
@@ -4641,8 +4661,11 @@ async function initializeSdk(options) {
|
|
|
4641
4661
|
const provider = new WebTracerProvider({
|
|
4642
4662
|
spanProcessors
|
|
4643
4663
|
});
|
|
4664
|
+
const contextManager = await createContextManager(
|
|
4665
|
+
options.useZoneContext ?? false
|
|
4666
|
+
);
|
|
4644
4667
|
provider.register({
|
|
4645
|
-
contextManager
|
|
4668
|
+
contextManager
|
|
4646
4669
|
});
|
|
4647
4670
|
registerInstrumentations({
|
|
4648
4671
|
instrumentations: [
|