@squide/firefly 14.0.0 → 15.0.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.
- package/CHANGELOG.md +28 -0
- package/dist/honeycomb/initializeHoneycomb.d.ts +2 -1
- package/dist/honeycomb/initializeHoneycomb.js +5 -9
- package/dist/honeycomb/initializeHoneycomb.js.map +1 -1
- package/dist/honeycomb/registerHoneycombInstrumentation.d.ts +3 -2
- package/dist/honeycomb/registerHoneycombInstrumentation.js +146 -73
- package/dist/honeycomb/registerHoneycombInstrumentation.js.map +1 -1
- package/dist/initializeFirefly.d.ts +2 -0
- package/dist/initializeFirefly.js +2 -2
- package/dist/initializeFirefly.js.map +1 -1
- package/package.json +18 -17
- package/src/honeycomb/initializeHoneycomb.ts +6 -6
- package/src/honeycomb/registerHoneycombInstrumentation.ts +213 -76
- package/src/initializeFirefly.ts +4 -1
- package/dist/honeycomb/canRegisterHoneycombInstrumentation.d.ts +0 -1
- package/dist/honeycomb/canRegisterHoneycombInstrumentation.js +0 -12
- package/dist/honeycomb/canRegisterHoneycombInstrumentation.js.map +0 -1
- package/src/honeycomb/canRegisterHoneycombInstrumentation.ts +0 -6
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { Span } from "@opentelemetry/api";
|
|
2
2
|
import {
|
|
3
|
+
type AddListenerOptions,
|
|
4
|
+
type EventCallbackFunction,
|
|
5
|
+
type EventName,
|
|
3
6
|
LocalModuleDeferredRegistrationFailedEvent,
|
|
4
7
|
LocalModuleDeferredRegistrationUpdateFailedEvent,
|
|
5
8
|
LocalModuleRegistrationFailedEvent,
|
|
@@ -37,6 +40,7 @@ import {
|
|
|
37
40
|
RemoteModulesRegistrationStartedEvent,
|
|
38
41
|
type RemoteModulesRegistrationStartedEventPayload
|
|
39
42
|
} from "@squide/module-federation";
|
|
43
|
+
import type { HoneycombInstrumentationPartialClient } from "@workleap-telemetry/core";
|
|
40
44
|
import { ApplicationBoostrappedEvent, type AppRouterWaitState, ModulesReadyEvent, ModulesRegisteredEvent, MswReadyEvent, ProtectedDataReadyEvent, PublicDataReadyEvent } from "../AppRouterReducer.ts";
|
|
41
45
|
import type { FireflyRuntime } from "../FireflyRuntime.tsx";
|
|
42
46
|
import { ApplicationBootstrappingStartedEvent } from "../initializeFirefly.ts";
|
|
@@ -49,6 +53,25 @@ import { endActiveSpan, startActiveChildSpan, startChildSpan, startSpan, traceEr
|
|
|
49
53
|
// TIPS:
|
|
50
54
|
// To query those traces in Honeycomb, use the following query filter: "root.name = squide-bootstrapping".
|
|
51
55
|
|
|
56
|
+
interface AddProtectedListenerOptions extends AddListenerOptions {
|
|
57
|
+
onError?: (error: unknown) => void;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function addProtectedListener(runtime: FireflyRuntime, eventName: EventName, callback: EventCallbackFunction, options?: AddProtectedListenerOptions) {
|
|
61
|
+
const protectedCallback = (...args: unknown[]) => {
|
|
62
|
+
try {
|
|
63
|
+
callback(...args);
|
|
64
|
+
} catch (error: unknown) {
|
|
65
|
+
runtime.logger
|
|
66
|
+
.withText(`[squide] An unmanaged error occurred while handling event "${eventName.toString()}" for Honeycomb instrumentation:`)
|
|
67
|
+
.withError(error as Error)
|
|
68
|
+
.error();
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
runtime.eventBus.addListener(eventName, protectedCallback, options);
|
|
73
|
+
}
|
|
74
|
+
|
|
52
75
|
type DataFetchState = "none" | "fetching-data" | "public-data-ready" | "protected-data-ready" | "data-ready" | "data-fetch-failed";
|
|
53
76
|
|
|
54
77
|
export function reduceDataFetchEvents(
|
|
@@ -59,20 +82,24 @@ export function reduceDataFetchEvents(
|
|
|
59
82
|
onPublicDataReady: () => void,
|
|
60
83
|
onProtectedDataFetchStarted: () => void,
|
|
61
84
|
onProtectedDataReady: () => void,
|
|
62
|
-
onDataFetchFailed: (queriesErrors: Error[]) => void
|
|
85
|
+
onDataFetchFailed: (queriesErrors: Error[]) => void,
|
|
86
|
+
onUnmanagedError: (error: unknown) => void
|
|
63
87
|
) {
|
|
64
88
|
let dataFetchState: DataFetchState = "none";
|
|
65
89
|
|
|
66
|
-
runtime
|
|
90
|
+
addProtectedListener(runtime, PublicDataFetchStartedEvent, () => {
|
|
67
91
|
if (dataFetchState === "none") {
|
|
68
92
|
dataFetchState = "fetching-data";
|
|
69
93
|
onDataFetchStarted();
|
|
70
94
|
}
|
|
71
95
|
|
|
72
96
|
onPublicDataFetchStarted();
|
|
73
|
-
}, {
|
|
97
|
+
}, {
|
|
98
|
+
once: true,
|
|
99
|
+
onError: onUnmanagedError
|
|
100
|
+
});
|
|
74
101
|
|
|
75
|
-
runtime
|
|
102
|
+
addProtectedListener(runtime, PublicDataReadyEvent, payload => {
|
|
76
103
|
onPublicDataReady();
|
|
77
104
|
|
|
78
105
|
if (dataFetchState === "fetching-data") {
|
|
@@ -86,18 +113,24 @@ export function reduceDataFetchEvents(
|
|
|
86
113
|
dataFetchState = "data-ready";
|
|
87
114
|
onDataReady();
|
|
88
115
|
}
|
|
89
|
-
}, {
|
|
116
|
+
}, {
|
|
117
|
+
once: true,
|
|
118
|
+
onError: onUnmanagedError
|
|
119
|
+
});
|
|
90
120
|
|
|
91
|
-
runtime
|
|
121
|
+
addProtectedListener(runtime, ProtectedDataFetchStartedEvent, () => {
|
|
92
122
|
if (dataFetchState === "none") {
|
|
93
123
|
dataFetchState = "fetching-data";
|
|
94
124
|
onDataFetchStarted();
|
|
95
125
|
}
|
|
96
126
|
|
|
97
127
|
onProtectedDataFetchStarted();
|
|
98
|
-
}, {
|
|
128
|
+
}, {
|
|
129
|
+
once: true,
|
|
130
|
+
onError: onUnmanagedError
|
|
131
|
+
});
|
|
99
132
|
|
|
100
|
-
runtime
|
|
133
|
+
addProtectedListener(runtime, ProtectedDataReadyEvent, payload => {
|
|
101
134
|
onProtectedDataReady();
|
|
102
135
|
|
|
103
136
|
if (dataFetchState === "fetching-data") {
|
|
@@ -111,7 +144,10 @@ export function reduceDataFetchEvents(
|
|
|
111
144
|
dataFetchState = "data-ready";
|
|
112
145
|
onDataReady();
|
|
113
146
|
}
|
|
114
|
-
}, {
|
|
147
|
+
}, {
|
|
148
|
+
once: true,
|
|
149
|
+
onError: onUnmanagedError
|
|
150
|
+
});
|
|
115
151
|
|
|
116
152
|
const handleDataFetchFailed = (payload: unknown) => {
|
|
117
153
|
if (dataFetchState !== "data-fetch-failed") {
|
|
@@ -121,12 +157,20 @@ export function reduceDataFetchEvents(
|
|
|
121
157
|
}
|
|
122
158
|
};
|
|
123
159
|
|
|
124
|
-
runtime
|
|
125
|
-
|
|
160
|
+
addProtectedListener(runtime, PublicDataFetchFailedEvent, handleDataFetchFailed, {
|
|
161
|
+
once: true,
|
|
162
|
+
onError: onUnmanagedError
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
addProtectedListener(runtime, ProtectedDataFetchFailedEvent, handleDataFetchFailed, {
|
|
166
|
+
once: true,
|
|
167
|
+
onError: onUnmanagedError
|
|
168
|
+
});
|
|
126
169
|
}
|
|
127
170
|
|
|
128
171
|
function registerTrackingListeners(runtime: FireflyRuntime) {
|
|
129
172
|
let bootstrappingSpan: Span;
|
|
173
|
+
let bootstrappingSpanHasEnded: boolean = false;
|
|
130
174
|
let localModuleRegistrationSpan: Span;
|
|
131
175
|
let localModuleDeferredRegistrationSpan: Span;
|
|
132
176
|
let remoteModuleRegistrationSpan: Span;
|
|
@@ -136,23 +180,74 @@ function registerTrackingListeners(runtime: FireflyRuntime) {
|
|
|
136
180
|
let localModuleDeferredRegistrationsUpdateSpan: ActiveSpan;
|
|
137
181
|
let remoteModuleDeferredRegistrationsUpdateSpan: ActiveSpan;
|
|
138
182
|
|
|
139
|
-
|
|
183
|
+
const handleUnmanagedError = (error: unknown) => {
|
|
184
|
+
if (bootstrappingSpan && !bootstrappingSpanHasEnded) {
|
|
185
|
+
traceError(bootstrappingSpan, error as Error);
|
|
186
|
+
|
|
187
|
+
bootstrappingSpan.end();
|
|
188
|
+
bootstrappingSpanHasEnded = true;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (localModuleRegistrationSpan) {
|
|
192
|
+
localModuleRegistrationSpan.end();
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (localModuleDeferredRegistrationSpan) {
|
|
196
|
+
localModuleDeferredRegistrationSpan.end();
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (remoteModuleRegistrationSpan) {
|
|
200
|
+
remoteModuleRegistrationSpan.end();
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (remoteModuleDeferredRegistrationSpan) {
|
|
204
|
+
remoteModuleDeferredRegistrationSpan.end();
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (dataFetchSpan) {
|
|
208
|
+
dataFetchSpan.instance.end();
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (deferredRegistrationsUpdateSpan) {
|
|
212
|
+
deferredRegistrationsUpdateSpan.end();
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (localModuleDeferredRegistrationsUpdateSpan) {
|
|
216
|
+
localModuleDeferredRegistrationsUpdateSpan.instance.end();
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (remoteModuleDeferredRegistrationsUpdateSpan) {
|
|
220
|
+
remoteModuleDeferredRegistrationsUpdateSpan.instance.end();
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
addProtectedListener(runtime, ApplicationBootstrappingStartedEvent, () => {
|
|
140
225
|
bootstrappingSpan = startSpan((options, context) => getTracer().startSpan("squide-bootstrapping", options, context));
|
|
141
|
-
}, {
|
|
226
|
+
}, {
|
|
227
|
+
once: true,
|
|
228
|
+
onError: handleUnmanagedError
|
|
229
|
+
});
|
|
142
230
|
|
|
143
|
-
runtime
|
|
231
|
+
addProtectedListener(runtime, ApplicationBoostrappedEvent, () => {
|
|
144
232
|
if (bootstrappingSpan) {
|
|
145
233
|
bootstrappingSpan.end();
|
|
234
|
+
bootstrappingSpanHasEnded = true;
|
|
146
235
|
}
|
|
147
|
-
}, {
|
|
236
|
+
}, {
|
|
237
|
+
once: true,
|
|
238
|
+
onError: handleUnmanagedError
|
|
239
|
+
});
|
|
148
240
|
|
|
149
|
-
runtime
|
|
241
|
+
addProtectedListener(runtime, MswReadyEvent, () => {
|
|
150
242
|
if (bootstrappingSpan) {
|
|
151
243
|
bootstrappingSpan.addEvent("msw-ready");
|
|
152
244
|
}
|
|
153
|
-
}, {
|
|
245
|
+
}, {
|
|
246
|
+
once: true,
|
|
247
|
+
onError: handleUnmanagedError
|
|
248
|
+
});
|
|
154
249
|
|
|
155
|
-
runtime
|
|
250
|
+
addProtectedListener(runtime, LocalModulesRegistrationStartedEvent, (payload: unknown) => {
|
|
156
251
|
const attributes = {
|
|
157
252
|
"app.squide.module_count": (payload as LocalModulesRegistrationStartedEventPayload).moduleCount
|
|
158
253
|
};
|
|
@@ -164,9 +259,12 @@ function registerTrackingListeners(runtime: FireflyRuntime) {
|
|
|
164
259
|
localModuleRegistrationSpan = startChildSpan(bootstrappingSpan, (options, context) => {
|
|
165
260
|
return getTracer().startSpan("local-module-registration", { ...options, attributes }, context);
|
|
166
261
|
});
|
|
167
|
-
}, {
|
|
262
|
+
}, {
|
|
263
|
+
once: true,
|
|
264
|
+
onError: handleUnmanagedError
|
|
265
|
+
});
|
|
168
266
|
|
|
169
|
-
runtime
|
|
267
|
+
addProtectedListener(runtime, LocalModulesRegistrationCompletedEvent, (payload: unknown) => {
|
|
170
268
|
if (bootstrappingSpan) {
|
|
171
269
|
bootstrappingSpan.addEvent("local-module-registration-completed", {
|
|
172
270
|
"app.squide.module_count": (payload as LocalModulesRegistrationCompletedEventPayload).moduleCount
|
|
@@ -176,18 +274,23 @@ function registerTrackingListeners(runtime: FireflyRuntime) {
|
|
|
176
274
|
if (localModuleRegistrationSpan) {
|
|
177
275
|
localModuleRegistrationSpan.end();
|
|
178
276
|
}
|
|
179
|
-
}, {
|
|
277
|
+
}, {
|
|
278
|
+
once: true,
|
|
279
|
+
onError: handleUnmanagedError
|
|
280
|
+
});
|
|
180
281
|
|
|
181
282
|
// Can occur multiple times.
|
|
182
|
-
runtime
|
|
283
|
+
addProtectedListener(runtime, LocalModuleRegistrationFailedEvent, (payload: unknown) => {
|
|
183
284
|
const registrationError = payload as ModuleRegistrationError;
|
|
184
285
|
|
|
185
286
|
if (localModuleRegistrationSpan) {
|
|
186
287
|
traceError(localModuleRegistrationSpan, registrationError);
|
|
187
288
|
}
|
|
289
|
+
}, {
|
|
290
|
+
onError: handleUnmanagedError
|
|
188
291
|
});
|
|
189
292
|
|
|
190
|
-
runtime
|
|
293
|
+
addProtectedListener(runtime, LocalModulesDeferredRegistrationStartedEvent, (payload: unknown) => {
|
|
191
294
|
const attributes = {
|
|
192
295
|
"app.squide.registration_count": (payload as LocalModulesDeferredRegistrationStartedEventPayload).registrationCount
|
|
193
296
|
};
|
|
@@ -199,9 +302,12 @@ function registerTrackingListeners(runtime: FireflyRuntime) {
|
|
|
199
302
|
localModuleDeferredRegistrationSpan = startChildSpan(bootstrappingSpan, (options, context) => {
|
|
200
303
|
return getTracer().startSpan("local-module-deferred-registration", { ...options, attributes }, context);
|
|
201
304
|
});
|
|
202
|
-
}, {
|
|
305
|
+
}, {
|
|
306
|
+
once: true,
|
|
307
|
+
onError: handleUnmanagedError
|
|
308
|
+
});
|
|
203
309
|
|
|
204
|
-
runtime
|
|
310
|
+
addProtectedListener(runtime, LocalModulesDeferredRegistrationCompletedEvent, (payload: unknown) => {
|
|
205
311
|
if (bootstrappingSpan) {
|
|
206
312
|
bootstrappingSpan.addEvent("local-module-deferred-registration-completed", {
|
|
207
313
|
"app.squide.registration_count": (payload as LocalModulesDeferredRegistrationCompletedEventPayload).registrationCount
|
|
@@ -211,18 +317,23 @@ function registerTrackingListeners(runtime: FireflyRuntime) {
|
|
|
211
317
|
if (localModuleDeferredRegistrationSpan) {
|
|
212
318
|
localModuleDeferredRegistrationSpan.end();
|
|
213
319
|
}
|
|
214
|
-
}, {
|
|
320
|
+
}, {
|
|
321
|
+
once: true,
|
|
322
|
+
onError: handleUnmanagedError
|
|
323
|
+
});
|
|
215
324
|
|
|
216
325
|
// Can occur multiple times.
|
|
217
|
-
runtime
|
|
326
|
+
addProtectedListener(runtime, LocalModuleDeferredRegistrationFailedEvent, (payload: unknown) => {
|
|
218
327
|
const registrationError = payload as ModuleRegistrationError;
|
|
219
328
|
|
|
220
329
|
if (localModuleDeferredRegistrationSpan) {
|
|
221
330
|
traceError(localModuleRegistrationSpan, registrationError);
|
|
222
331
|
}
|
|
332
|
+
}, {
|
|
333
|
+
onError: handleUnmanagedError
|
|
223
334
|
});
|
|
224
335
|
|
|
225
|
-
runtime
|
|
336
|
+
addProtectedListener(runtime, RemoteModulesRegistrationStartedEvent, (payload: unknown) => {
|
|
226
337
|
const attributes = {
|
|
227
338
|
"app.squide.remote_count": (payload as RemoteModulesRegistrationStartedEventPayload).remoteCount
|
|
228
339
|
};
|
|
@@ -234,9 +345,12 @@ function registerTrackingListeners(runtime: FireflyRuntime) {
|
|
|
234
345
|
remoteModuleRegistrationSpan = startChildSpan(bootstrappingSpan, (options, context) => {
|
|
235
346
|
return getTracer().startSpan("remote-module-registration", { ...options, attributes }, context);
|
|
236
347
|
});
|
|
237
|
-
}, {
|
|
348
|
+
}, {
|
|
349
|
+
once: true,
|
|
350
|
+
onError: handleUnmanagedError
|
|
351
|
+
});
|
|
238
352
|
|
|
239
|
-
runtime
|
|
353
|
+
addProtectedListener(runtime, RemoteModulesRegistrationCompletedEvent, (payload: unknown) => {
|
|
240
354
|
if (bootstrappingSpan) {
|
|
241
355
|
bootstrappingSpan.addEvent("remote-module-registration-completed", {
|
|
242
356
|
"app.squide.remote_count": (payload as RemoteModulesRegistrationCompletedEventPayload).remoteCount
|
|
@@ -246,18 +360,23 @@ function registerTrackingListeners(runtime: FireflyRuntime) {
|
|
|
246
360
|
if (remoteModuleRegistrationSpan) {
|
|
247
361
|
remoteModuleRegistrationSpan.end();
|
|
248
362
|
}
|
|
249
|
-
}, {
|
|
363
|
+
}, {
|
|
364
|
+
once: true,
|
|
365
|
+
onError: handleUnmanagedError
|
|
366
|
+
});
|
|
250
367
|
|
|
251
368
|
// Can occur multiple times.
|
|
252
|
-
runtime
|
|
369
|
+
addProtectedListener(runtime, RemoteModuleRegistrationFailedEvent, (payload: unknown) => {
|
|
253
370
|
const registrationError = payload as RemoteModuleRegistrationError;
|
|
254
371
|
|
|
255
372
|
if (remoteModuleRegistrationSpan) {
|
|
256
373
|
traceError(remoteModuleRegistrationSpan, registrationError);
|
|
257
374
|
}
|
|
375
|
+
}, {
|
|
376
|
+
onError: handleUnmanagedError
|
|
258
377
|
});
|
|
259
378
|
|
|
260
|
-
runtime
|
|
379
|
+
addProtectedListener(runtime, RemoteModulesDeferredRegistrationStartedEvent, (payload: unknown) => {
|
|
261
380
|
const attributes = {
|
|
262
381
|
"app.squide.registration_count": (payload as RemoteModulesDeferredRegistrationStartedEventPayload).registrationCount
|
|
263
382
|
};
|
|
@@ -269,9 +388,12 @@ function registerTrackingListeners(runtime: FireflyRuntime) {
|
|
|
269
388
|
remoteModuleDeferredRegistrationSpan = startChildSpan(bootstrappingSpan, (options, context) => {
|
|
270
389
|
return getTracer().startSpan("remote-module-deferred-registration", { ...options, attributes }, context);
|
|
271
390
|
});
|
|
272
|
-
}, {
|
|
391
|
+
}, {
|
|
392
|
+
once: true,
|
|
393
|
+
onError: handleUnmanagedError
|
|
394
|
+
});
|
|
273
395
|
|
|
274
|
-
runtime
|
|
396
|
+
addProtectedListener(runtime, RemoteModulesDeferredRegistrationCompletedEvent, (payload: unknown) => {
|
|
275
397
|
if (bootstrappingSpan) {
|
|
276
398
|
bootstrappingSpan.addEvent("remote-module-deferred-registration-completed", {
|
|
277
399
|
"app.squide.registration_count": (payload as RemoteModulesDeferredRegistrationCompletedEventPayload).registrationCount
|
|
@@ -281,15 +403,20 @@ function registerTrackingListeners(runtime: FireflyRuntime) {
|
|
|
281
403
|
if (remoteModuleDeferredRegistrationSpan) {
|
|
282
404
|
remoteModuleDeferredRegistrationSpan.end();
|
|
283
405
|
}
|
|
284
|
-
}, {
|
|
406
|
+
}, {
|
|
407
|
+
once: true,
|
|
408
|
+
onError: handleUnmanagedError
|
|
409
|
+
});
|
|
285
410
|
|
|
286
411
|
// Can occur multiple times.
|
|
287
|
-
runtime
|
|
412
|
+
addProtectedListener(runtime, RemoteModuleDeferredRegistrationFailedEvent, (payload: unknown) => {
|
|
288
413
|
const registrationError = payload as RemoteModuleRegistrationError;
|
|
289
414
|
|
|
290
415
|
if (remoteModuleDeferredRegistrationSpan) {
|
|
291
416
|
traceError(remoteModuleDeferredRegistrationSpan, registrationError);
|
|
292
417
|
}
|
|
418
|
+
}, {
|
|
419
|
+
onError: handleUnmanagedError
|
|
293
420
|
});
|
|
294
421
|
|
|
295
422
|
const handleFetchDataStarted = () => {
|
|
@@ -346,6 +473,7 @@ function registerTrackingListeners(runtime: FireflyRuntime) {
|
|
|
346
473
|
// will be aborted and a react-router error boundary will be rendered.
|
|
347
474
|
if (bootstrappingSpan) {
|
|
348
475
|
bootstrappingSpan.end();
|
|
476
|
+
bootstrappingSpanHasEnded = true;
|
|
349
477
|
}
|
|
350
478
|
}
|
|
351
479
|
};
|
|
@@ -358,35 +486,46 @@ function registerTrackingListeners(runtime: FireflyRuntime) {
|
|
|
358
486
|
handlePublicDataReady,
|
|
359
487
|
handleProtectedDataFetchStarted,
|
|
360
488
|
handleProtectedDataReady,
|
|
361
|
-
handleDataFetchFailed
|
|
489
|
+
handleDataFetchFailed,
|
|
490
|
+
handleUnmanagedError
|
|
362
491
|
);
|
|
363
492
|
|
|
364
|
-
runtime
|
|
493
|
+
addProtectedListener(runtime, ModulesRegisteredEvent, () => {
|
|
365
494
|
if (bootstrappingSpan) {
|
|
366
495
|
bootstrappingSpan.addEvent("modules-registered");
|
|
367
496
|
}
|
|
368
|
-
}, {
|
|
497
|
+
}, {
|
|
498
|
+
once: true,
|
|
499
|
+
onError: handleUnmanagedError
|
|
500
|
+
});
|
|
369
501
|
|
|
370
|
-
runtime
|
|
502
|
+
addProtectedListener(runtime, ModulesReadyEvent, () => {
|
|
371
503
|
if (bootstrappingSpan) {
|
|
372
504
|
bootstrappingSpan.addEvent("modules-ready");
|
|
373
505
|
}
|
|
374
|
-
}, {
|
|
506
|
+
}, {
|
|
507
|
+
once: true,
|
|
508
|
+
onError: handleUnmanagedError
|
|
509
|
+
});
|
|
375
510
|
|
|
376
511
|
// Can occur multiple times.
|
|
377
|
-
runtime
|
|
512
|
+
addProtectedListener(runtime, DeferredRegistrationsUpdateStartedEvent, () => {
|
|
378
513
|
deferredRegistrationsUpdateSpan = startSpan((options, context) => getTracer().startSpan("squide-deferred-registrations-update", options, context));
|
|
514
|
+
}, {
|
|
515
|
+
onError: handleUnmanagedError
|
|
379
516
|
});
|
|
380
517
|
|
|
381
518
|
// Can occur multiple times.
|
|
382
|
-
runtime
|
|
519
|
+
addProtectedListener(runtime, DeferredRegistrationsUpdateCompletedEvent, () => {
|
|
383
520
|
if (deferredRegistrationsUpdateSpan) {
|
|
384
521
|
deferredRegistrationsUpdateSpan.end();
|
|
385
522
|
}
|
|
523
|
+
}, {
|
|
524
|
+
onError: handleUnmanagedError
|
|
386
525
|
});
|
|
387
526
|
|
|
388
527
|
// Can occur multiple times.
|
|
389
|
-
runtime
|
|
528
|
+
addProtectedListener(runtime, LocalModulesDeferredRegistrationsUpdateStartedEvent, (payload: unknown) => {
|
|
390
529
|
const attributes = {
|
|
391
530
|
"app.squide.registration_count": (payload as LocalModulesDeferredRegistrationsUpdateStartedEventPayload).registrationCount
|
|
392
531
|
};
|
|
@@ -408,10 +547,12 @@ function registerTrackingListeners(runtime: FireflyRuntime) {
|
|
|
408
547
|
span
|
|
409
548
|
};
|
|
410
549
|
});
|
|
550
|
+
}, {
|
|
551
|
+
onError: handleUnmanagedError
|
|
411
552
|
});
|
|
412
553
|
|
|
413
554
|
// Can occur multiple times.
|
|
414
|
-
runtime
|
|
555
|
+
addProtectedListener(runtime, LocalModulesDeferredRegistrationsUpdateCompletedEvent, (payload: unknown) => {
|
|
415
556
|
if (deferredRegistrationsUpdateSpan) {
|
|
416
557
|
deferredRegistrationsUpdateSpan.addEvent("local-module-deferred-registrations-update-completed", {
|
|
417
558
|
"app.squide.registration_count": (payload as LocalModulesDeferredRegistrationsUpdateCompletedEventPayload).registrationCount
|
|
@@ -421,19 +562,23 @@ function registerTrackingListeners(runtime: FireflyRuntime) {
|
|
|
421
562
|
if (localModuleDeferredRegistrationsUpdateSpan) {
|
|
422
563
|
endActiveSpan(localModuleDeferredRegistrationsUpdateSpan);
|
|
423
564
|
}
|
|
565
|
+
}, {
|
|
566
|
+
onError: handleUnmanagedError
|
|
424
567
|
});
|
|
425
568
|
|
|
426
569
|
// Can occur multiple times.
|
|
427
|
-
runtime
|
|
570
|
+
addProtectedListener(runtime, LocalModuleDeferredRegistrationUpdateFailedEvent, (payload: unknown) => {
|
|
428
571
|
const registrationError = payload as ModuleRegistrationError;
|
|
429
572
|
|
|
430
573
|
if (localModuleDeferredRegistrationsUpdateSpan) {
|
|
431
574
|
traceError(localModuleDeferredRegistrationsUpdateSpan.instance, registrationError);
|
|
432
575
|
}
|
|
576
|
+
}, {
|
|
577
|
+
onError: handleUnmanagedError
|
|
433
578
|
});
|
|
434
579
|
|
|
435
580
|
// Can occur multiple times.
|
|
436
|
-
runtime
|
|
581
|
+
addProtectedListener(runtime, RemoteModulesDeferredRegistrationsUpdateStartedEvent, (payload: unknown) => {
|
|
437
582
|
const attributes = {
|
|
438
583
|
"app.squide.registration_count": (payload as RemoteModulesDeferredRegistrationsUpdateStartedEventPayload).registrationCount
|
|
439
584
|
};
|
|
@@ -455,10 +600,12 @@ function registerTrackingListeners(runtime: FireflyRuntime) {
|
|
|
455
600
|
span
|
|
456
601
|
};
|
|
457
602
|
});
|
|
603
|
+
}, {
|
|
604
|
+
onError: handleUnmanagedError
|
|
458
605
|
});
|
|
459
606
|
|
|
460
607
|
// Can occur multiple times.
|
|
461
|
-
runtime
|
|
608
|
+
addProtectedListener(runtime, RemoteModulesDeferredRegistrationsUpdateCompletedEvent, (payload: unknown) => {
|
|
462
609
|
if (deferredRegistrationsUpdateSpan) {
|
|
463
610
|
deferredRegistrationsUpdateSpan.addEvent("remote-module-deferred-registrations-update-completed", {
|
|
464
611
|
"app.squide.registration_count": (payload as RemoteModulesDeferredRegistrationsUpdateCompletedEventPayload).registrationCount
|
|
@@ -468,47 +615,37 @@ function registerTrackingListeners(runtime: FireflyRuntime) {
|
|
|
468
615
|
if (remoteModuleDeferredRegistrationsUpdateSpan) {
|
|
469
616
|
endActiveSpan(remoteModuleDeferredRegistrationsUpdateSpan);
|
|
470
617
|
}
|
|
618
|
+
}, {
|
|
619
|
+
onError: handleUnmanagedError
|
|
471
620
|
});
|
|
472
621
|
|
|
473
622
|
// Can occur multiple times.
|
|
474
|
-
runtime
|
|
623
|
+
addProtectedListener(runtime, RemoteModuleDeferredRegistrationUpdateFailedEvent, (payload: unknown) => {
|
|
475
624
|
const registrationError = payload as RemoteModuleRegistrationError;
|
|
476
625
|
|
|
477
626
|
if (remoteModuleDeferredRegistrationsUpdateSpan) {
|
|
478
627
|
traceError(remoteModuleDeferredRegistrationsUpdateSpan.instance, registrationError);
|
|
479
628
|
}
|
|
629
|
+
}, {
|
|
630
|
+
onError: handleUnmanagedError
|
|
480
631
|
});
|
|
481
632
|
}
|
|
482
633
|
|
|
483
|
-
function
|
|
484
|
-
|
|
485
|
-
// @ts-ignore
|
|
486
|
-
if (globalThis.__WLP_HONEYCOMB_REGISTER_DYNAMIC_FETCH_REQUEST_HOOK__) {
|
|
487
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
488
|
-
// @ts-ignore
|
|
489
|
-
return globalThis.__WLP_HONEYCOMB_REGISTER_DYNAMIC_FETCH_REQUEST_HOOK__;
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
// Fallback to fix an error. Will remove soon.
|
|
493
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
494
|
-
// @ts-ignore
|
|
495
|
-
return globalThis.__WLP_HONEYCOMB_REGISTER_DYNAMIC_FETCH_REQUEST_HOOK;
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
export function registerHoneycombInstrumentation(runtime: FireflyRuntime) {
|
|
499
|
-
const registerFetchRequestHookFunction = getRegisterFetchRequestHookFunction();
|
|
500
|
-
|
|
501
|
-
if (registerFetchRequestHookFunction) {
|
|
634
|
+
export function registerHoneycombInstrumentation(runtime: FireflyRuntime, honeycombInstrumentationClient: HoneycombInstrumentationPartialClient) {
|
|
635
|
+
try {
|
|
502
636
|
registerActiveSpanStack();
|
|
503
637
|
|
|
504
|
-
const activeSpanOverrideFunction = createOverrideFetchRequestSpanWithActiveSpanContext(runtime.logger);
|
|
505
|
-
|
|
506
638
|
// Dynamically registering this request hook function to nest the HTTP requests
|
|
507
639
|
// of squide bootstrapping under the appropriate Honeycomb span.
|
|
508
|
-
|
|
509
|
-
} else {
|
|
510
|
-
runtime.logger.warning("[squide] Cannot register Honeycomb fetch request hook because \"globalThis.__WLP_HONEYCOMB_REGISTER_DYNAMIC_FETCH_REQUEST_HOOK__\" is not available. Honeycomb instrumentation is still functional but in degraded mode.");
|
|
511
|
-
}
|
|
640
|
+
honeycombInstrumentationClient.registerFetchRequestHook(createOverrideFetchRequestSpanWithActiveSpanContext(runtime.logger));
|
|
512
641
|
|
|
513
|
-
|
|
642
|
+
registerTrackingListeners(runtime);
|
|
643
|
+
|
|
644
|
+
runtime.logger.information("[squide] Honeycomb instrumentation is registered.");
|
|
645
|
+
} catch (error: unknown) {
|
|
646
|
+
runtime.logger
|
|
647
|
+
.withText("[squide] An error occurred while registering Honeycomb instrumentation:")
|
|
648
|
+
.withError(error as Error)
|
|
649
|
+
.error();
|
|
650
|
+
}
|
|
514
651
|
}
|
package/src/initializeFirefly.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isFunction, registerLocalModules, type ModuleRegisterFunction, type RegisterModulesOptions } from "@squide/core";
|
|
2
2
|
import { registerRemoteModules, type RemoteDefinition } from "@squide/module-federation";
|
|
3
3
|
import { setMswAsReady } from "@squide/msw";
|
|
4
|
+
import type { HoneycombInstrumentationPartialClient } from "@workleap-telemetry/core";
|
|
4
5
|
import { FireflyRuntime, type FireflyRuntimeOptions } from "./FireflyRuntime.tsx";
|
|
5
6
|
import { initializeHoneycomb } from "./honeycomb/initializeHoneycomb.ts";
|
|
6
7
|
|
|
@@ -13,6 +14,7 @@ export type StartMswFunction<TRuntime = FireflyRuntime> = (runtime: TRuntime) =>
|
|
|
13
14
|
export interface InitializeFireflyOptions<TRuntime extends FireflyRuntime, TContext = unknown, TData = unknown> extends RegisterModulesOptions<TContext>, FireflyRuntimeOptions {
|
|
14
15
|
localModules?: ModuleRegisterFunction<TRuntime, TContext, TData>[];
|
|
15
16
|
remotes?: RemoteDefinition[];
|
|
17
|
+
honeycombInstrumentationClient?: HoneycombInstrumentationPartialClient;
|
|
16
18
|
startMsw?: StartMswFunction<FireflyRuntime>;
|
|
17
19
|
onError?: OnInitializationErrorFunction;
|
|
18
20
|
}
|
|
@@ -74,6 +76,7 @@ export function initializeFirefly<TContext = unknown, TData = unknown>(options:
|
|
|
74
76
|
useMsw,
|
|
75
77
|
loggers,
|
|
76
78
|
plugins,
|
|
79
|
+
honeycombInstrumentationClient,
|
|
77
80
|
onError
|
|
78
81
|
} = options;
|
|
79
82
|
|
|
@@ -90,7 +93,7 @@ export function initializeFirefly<TContext = unknown, TData = unknown>(options:
|
|
|
90
93
|
plugins
|
|
91
94
|
});
|
|
92
95
|
|
|
93
|
-
initializeHoneycomb(runtime)
|
|
96
|
+
initializeHoneycomb(runtime, honeycombInstrumentationClient)
|
|
94
97
|
.catch((error: unknown) => {
|
|
95
98
|
if (onError) {
|
|
96
99
|
onError(error);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function canRegisterHoneycombInstrumentation(): boolean;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
;// CONCATENATED MODULE: ./src/honeycomb/canRegisterHoneycombInstrumentation.ts
|
|
3
|
-
function canRegisterHoneycombInstrumentation() {
|
|
4
|
-
// The second one is due to an error. Will be able to remove soon.
|
|
5
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
6
|
-
// @ts-ignore
|
|
7
|
-
return globalThis.__WLP_HONEYCOMB_INSTRUMENTATION_IS_REGISTERED__ === true || globalThis.__WLP_HONEYCOMB_INSTRUMENTATION_IS_REGISTERED === true;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export { canRegisterHoneycombInstrumentation };
|
|
11
|
-
|
|
12
|
-
//# sourceMappingURL=canRegisterHoneycombInstrumentation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"honeycomb/canRegisterHoneycombInstrumentation.js","sources":["webpack://@squide/firefly/./src/honeycomb/canRegisterHoneycombInstrumentation.ts"],"sourcesContent":["export function canRegisterHoneycombInstrumentation() {\n // The second one is due to an error. Will be able to remove soon.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return globalThis.__WLP_HONEYCOMB_INSTRUMENTATION_IS_REGISTERED__ === true || globalThis.__WLP_HONEYCOMB_INSTRUMENTATION_IS_REGISTERED === true;\n}\n"],"names":["canRegisterHoneycombInstrumentation","globalThis"],"mappings":";;AAAO,SAASA;IACZ,kEAAkE;IAClE,6DAA6D;IAC7D,aAAa;IACb,OAAOC,WAAW,+CAA+C,KAAK,QAAQA,WAAW,6CAA6C,KAAK;AAC/I"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export function canRegisterHoneycombInstrumentation() {
|
|
2
|
-
// The second one is due to an error. Will be able to remove soon.
|
|
3
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
4
|
-
// @ts-ignore
|
|
5
|
-
return globalThis.__WLP_HONEYCOMB_INSTRUMENTATION_IS_REGISTERED__ === true || globalThis.__WLP_HONEYCOMB_INSTRUMENTATION_IS_REGISTERED === true;
|
|
6
|
-
}
|