@glasstrace/sdk 1.9.1 → 1.10.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/dist/async-context/index.cjs +44 -0
- package/dist/async-context/index.cjs.map +1 -1
- package/dist/async-context/index.js +2 -2
- package/dist/{chunk-JHUNLPSS.js → chunk-6RKS3DNA.js} +45 -1
- package/dist/{chunk-JHUNLPSS.js.map → chunk-6RKS3DNA.js.map} +1 -1
- package/dist/{chunk-HD6JIFKN.js → chunk-BSVWJSVX.js} +2 -2
- package/dist/{chunk-QOHKZOKB.js → chunk-D54FMQHF.js} +2 -2
- package/dist/chunk-I2DVVSKW.js +419 -0
- package/dist/chunk-I2DVVSKW.js.map +1 -0
- package/dist/{chunk-H6WJ63X2.js → chunk-M5GO2SSO.js} +2 -2
- package/dist/{chunk-2F2MGFLO.js → chunk-OXA4IHQX.js} +39 -405
- package/dist/chunk-OXA4IHQX.js.map +1 -0
- package/dist/{chunk-QEXRCXSY.js → chunk-OXM2BZMF.js} +2 -2
- package/dist/{chunk-M6EWJCAT.js → chunk-QVTONMVZ.js} +2 -2
- package/dist/{chunk-DKV53A2C.js → chunk-RL43PU2X.js} +2 -2
- package/dist/{chunk-GWIEUBFR.js → chunk-UMGZJYC4.js} +3 -3
- package/dist/{chunk-QXITSNYM.js → chunk-XG6WR2KS.js} +3 -3
- package/dist/cli/init.cjs +4 -4
- package/dist/cli/init.cjs.map +1 -1
- package/dist/cli/init.js +7 -7
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/mcp-add.cjs +1 -1
- package/dist/cli/mcp-add.cjs.map +1 -1
- package/dist/cli/mcp-add.js +3 -3
- package/dist/cli/mcp-add.js.map +1 -1
- package/dist/cli/uninit.js +3 -3
- package/dist/cli/upgrade-instructions.cjs +1 -1
- package/dist/cli/upgrade-instructions.cjs.map +1 -1
- package/dist/cli/upgrade-instructions.js +3 -3
- package/dist/cli/upgrade-instructions.js.map +1 -1
- package/dist/cli/validate.cjs.map +1 -1
- package/dist/cli/validate.js +2 -2
- package/dist/edge-entry.cjs +44 -0
- package/dist/edge-entry.cjs.map +1 -1
- package/dist/edge-entry.js +4 -4
- package/dist/index.cjs +58 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -8
- package/dist/index.js.map +1 -1
- package/dist/middleware/index.cjs +44 -0
- package/dist/middleware/index.cjs.map +1 -1
- package/dist/middleware/index.js +2 -2
- package/dist/node-entry.cjs +58 -5
- package/dist/node-entry.cjs.map +1 -1
- package/dist/node-entry.js +12 -10
- package/dist/node-subpath.cjs.map +1 -1
- package/dist/node-subpath.js +3 -3
- package/dist/{source-map-uploader-MMJ2WCL4.js → source-map-uploader-CLYCE2TZ.js} +3 -3
- package/dist/trpc/index.cjs +15164 -503
- package/dist/trpc/index.cjs.map +1 -1
- package/dist/trpc/index.d.cts +62 -1
- package/dist/trpc/index.d.ts +62 -1
- package/dist/trpc/index.js +200 -1
- package/dist/trpc/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-2F2MGFLO.js.map +0 -1
- /package/dist/{chunk-HD6JIFKN.js.map → chunk-BSVWJSVX.js.map} +0 -0
- /package/dist/{chunk-QOHKZOKB.js.map → chunk-D54FMQHF.js.map} +0 -0
- /package/dist/{chunk-H6WJ63X2.js.map → chunk-M5GO2SSO.js.map} +0 -0
- /package/dist/{chunk-QEXRCXSY.js.map → chunk-OXM2BZMF.js.map} +0 -0
- /package/dist/{chunk-M6EWJCAT.js.map → chunk-QVTONMVZ.js.map} +0 -0
- /package/dist/{chunk-DKV53A2C.js.map → chunk-RL43PU2X.js.map} +0 -0
- /package/dist/{chunk-GWIEUBFR.js.map → chunk-UMGZJYC4.js.map} +0 -0
- /package/dist/{chunk-QXITSNYM.js.map → chunk-XG6WR2KS.js.map} +0 -0
- /package/dist/{source-map-uploader-MMJ2WCL4.js.map → source-map-uploader-CLYCE2TZ.js.map} +0 -0
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
AuthState,
|
|
3
|
+
CoreState,
|
|
4
|
+
OtelState,
|
|
5
|
+
clearDegradationSource,
|
|
6
|
+
emitLifecycleEvent,
|
|
7
|
+
executeShutdown,
|
|
8
|
+
getCoreState,
|
|
9
|
+
getSdkState,
|
|
10
|
+
initAuthState,
|
|
11
|
+
initLifecycle,
|
|
12
|
+
onLifecycleEvent,
|
|
13
|
+
pushDegradationSource,
|
|
14
|
+
registerBeforeExitTrigger,
|
|
15
|
+
registerShutdownHook,
|
|
16
|
+
registerSignalHandlers,
|
|
17
|
+
setAuthState,
|
|
18
|
+
setCoexistenceState,
|
|
19
|
+
setCoreState,
|
|
20
|
+
setOtelState
|
|
21
|
+
} from "./chunk-I2DVVSKW.js";
|
|
4
22
|
import {
|
|
5
23
|
DiagLogLevel,
|
|
6
24
|
INVALID_SPAN_CONTEXT,
|
|
@@ -36,7 +54,7 @@ import {
|
|
|
36
54
|
performInit,
|
|
37
55
|
recordSpansDropped,
|
|
38
56
|
recordSpansExported
|
|
39
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-XG6WR2KS.js";
|
|
40
58
|
import {
|
|
41
59
|
isAnonymousMode,
|
|
42
60
|
isProductionDisabled,
|
|
@@ -47,11 +65,11 @@ import {
|
|
|
47
65
|
getOrCreateAnonKey,
|
|
48
66
|
isSyncFsAvailable,
|
|
49
67
|
readAnonKey
|
|
50
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-RL43PU2X.js";
|
|
51
69
|
import {
|
|
52
70
|
GLASSTRACE_ATTRIBUTE_NAMES,
|
|
53
71
|
deriveSessionId
|
|
54
|
-
} from "./chunk-
|
|
72
|
+
} from "./chunk-6RKS3DNA.js";
|
|
55
73
|
import {
|
|
56
74
|
isEndMarkerLine,
|
|
57
75
|
parseStartMarkerLine
|
|
@@ -146,396 +164,6 @@ function classifyFetchTarget(url) {
|
|
|
146
164
|
return "unknown";
|
|
147
165
|
}
|
|
148
166
|
|
|
149
|
-
// src/lifecycle.ts
|
|
150
|
-
import { EventEmitter } from "node:events";
|
|
151
|
-
|
|
152
|
-
// src/signal-handler.ts
|
|
153
|
-
var coexistenceState = "unknown";
|
|
154
|
-
function setCoexistenceState(s) {
|
|
155
|
-
coexistenceState = s;
|
|
156
|
-
}
|
|
157
|
-
function getCoexistenceState() {
|
|
158
|
-
return coexistenceState;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// src/lifecycle.ts
|
|
162
|
-
var CoreState = {
|
|
163
|
-
IDLE: "IDLE",
|
|
164
|
-
REGISTERING: "REGISTERING",
|
|
165
|
-
KEY_PENDING: "KEY_PENDING",
|
|
166
|
-
KEY_RESOLVED: "KEY_RESOLVED",
|
|
167
|
-
ACTIVE: "ACTIVE",
|
|
168
|
-
ACTIVE_DEGRADED: "ACTIVE_DEGRADED",
|
|
169
|
-
SHUTTING_DOWN: "SHUTTING_DOWN",
|
|
170
|
-
SHUTDOWN: "SHUTDOWN",
|
|
171
|
-
PRODUCTION_DISABLED: "PRODUCTION_DISABLED",
|
|
172
|
-
REGISTRATION_FAILED: "REGISTRATION_FAILED"
|
|
173
|
-
};
|
|
174
|
-
var AuthState = {
|
|
175
|
-
ANONYMOUS: "ANONYMOUS",
|
|
176
|
-
AUTHENTICATED: "AUTHENTICATED",
|
|
177
|
-
CLAIMING: "CLAIMING",
|
|
178
|
-
CLAIMED: "CLAIMED"
|
|
179
|
-
};
|
|
180
|
-
var OtelState = {
|
|
181
|
-
UNCONFIGURED: "UNCONFIGURED",
|
|
182
|
-
CONFIGURING: "CONFIGURING",
|
|
183
|
-
OWNS_PROVIDER: "OWNS_PROVIDER",
|
|
184
|
-
AUTO_ATTACHED: "AUTO_ATTACHED",
|
|
185
|
-
PROCESSOR_PRESENT: "PROCESSOR_PRESENT",
|
|
186
|
-
COEXISTENCE_FAILED: "COEXISTENCE_FAILED"
|
|
187
|
-
};
|
|
188
|
-
var VALID_CORE_TRANSITIONS = {
|
|
189
|
-
[CoreState.IDLE]: [CoreState.REGISTERING, CoreState.REGISTRATION_FAILED, CoreState.SHUTTING_DOWN],
|
|
190
|
-
[CoreState.REGISTERING]: [
|
|
191
|
-
CoreState.KEY_PENDING,
|
|
192
|
-
CoreState.PRODUCTION_DISABLED,
|
|
193
|
-
CoreState.REGISTRATION_FAILED,
|
|
194
|
-
CoreState.SHUTTING_DOWN
|
|
195
|
-
],
|
|
196
|
-
[CoreState.KEY_PENDING]: [
|
|
197
|
-
CoreState.KEY_RESOLVED,
|
|
198
|
-
CoreState.REGISTRATION_FAILED,
|
|
199
|
-
CoreState.SHUTTING_DOWN
|
|
200
|
-
],
|
|
201
|
-
[CoreState.KEY_RESOLVED]: [
|
|
202
|
-
CoreState.ACTIVE,
|
|
203
|
-
CoreState.ACTIVE_DEGRADED,
|
|
204
|
-
CoreState.SHUTTING_DOWN
|
|
205
|
-
],
|
|
206
|
-
[CoreState.ACTIVE]: [
|
|
207
|
-
CoreState.ACTIVE_DEGRADED,
|
|
208
|
-
CoreState.SHUTTING_DOWN
|
|
209
|
-
],
|
|
210
|
-
[CoreState.ACTIVE_DEGRADED]: [
|
|
211
|
-
CoreState.ACTIVE,
|
|
212
|
-
CoreState.SHUTTING_DOWN
|
|
213
|
-
],
|
|
214
|
-
[CoreState.SHUTTING_DOWN]: [CoreState.SHUTDOWN],
|
|
215
|
-
[CoreState.SHUTDOWN]: [],
|
|
216
|
-
[CoreState.PRODUCTION_DISABLED]: [],
|
|
217
|
-
[CoreState.REGISTRATION_FAILED]: []
|
|
218
|
-
};
|
|
219
|
-
var VALID_AUTH_TRANSITIONS = {
|
|
220
|
-
[AuthState.ANONYMOUS]: [AuthState.CLAIMING],
|
|
221
|
-
[AuthState.AUTHENTICATED]: [AuthState.CLAIMING],
|
|
222
|
-
[AuthState.CLAIMING]: [AuthState.CLAIMED],
|
|
223
|
-
[AuthState.CLAIMED]: [AuthState.CLAIMING]
|
|
224
|
-
};
|
|
225
|
-
var VALID_OTEL_TRANSITIONS = {
|
|
226
|
-
[OtelState.UNCONFIGURED]: [OtelState.CONFIGURING],
|
|
227
|
-
[OtelState.CONFIGURING]: [
|
|
228
|
-
OtelState.OWNS_PROVIDER,
|
|
229
|
-
OtelState.AUTO_ATTACHED,
|
|
230
|
-
OtelState.PROCESSOR_PRESENT,
|
|
231
|
-
OtelState.COEXISTENCE_FAILED
|
|
232
|
-
],
|
|
233
|
-
[OtelState.OWNS_PROVIDER]: [],
|
|
234
|
-
[OtelState.AUTO_ATTACHED]: [],
|
|
235
|
-
[OtelState.PROCESSOR_PRESENT]: [],
|
|
236
|
-
[OtelState.COEXISTENCE_FAILED]: []
|
|
237
|
-
};
|
|
238
|
-
var _coreState = CoreState.IDLE;
|
|
239
|
-
var _authState = AuthState.ANONYMOUS;
|
|
240
|
-
var _otelState = OtelState.UNCONFIGURED;
|
|
241
|
-
var _emitter = new EventEmitter();
|
|
242
|
-
var _logger = null;
|
|
243
|
-
var _initialized = false;
|
|
244
|
-
var _initWarned = false;
|
|
245
|
-
var _coreReadyEmitted = false;
|
|
246
|
-
var _authInitialized = false;
|
|
247
|
-
var _emitting = false;
|
|
248
|
-
function initLifecycle(options) {
|
|
249
|
-
if (_initialized) {
|
|
250
|
-
options.logger("warn", "[glasstrace] initLifecycle() called twice \u2014 ignored.");
|
|
251
|
-
return;
|
|
252
|
-
}
|
|
253
|
-
_logger = options.logger;
|
|
254
|
-
_initialized = true;
|
|
255
|
-
_registerLifecycleEmitForBridge((event, payload) => {
|
|
256
|
-
emitLifecycleEvent(
|
|
257
|
-
event,
|
|
258
|
-
payload
|
|
259
|
-
);
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
function warnIfNotInitialized() {
|
|
263
|
-
if (!_initialized && !_initWarned) {
|
|
264
|
-
_initWarned = true;
|
|
265
|
-
console.warn(
|
|
266
|
-
"[glasstrace] Lifecycle state changed before initLifecycle() was called. Logger not available \u2014 errors will be silent."
|
|
267
|
-
);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
function setCoreState(to) {
|
|
271
|
-
warnIfNotInitialized();
|
|
272
|
-
const from = _coreState;
|
|
273
|
-
if (from === to) return;
|
|
274
|
-
const valid = VALID_CORE_TRANSITIONS[from];
|
|
275
|
-
if (!valid.includes(to)) {
|
|
276
|
-
_logger?.(
|
|
277
|
-
"warn",
|
|
278
|
-
`[glasstrace] Invalid core state transition: ${from} \u2192 ${to}. Ignored.`
|
|
279
|
-
);
|
|
280
|
-
return;
|
|
281
|
-
}
|
|
282
|
-
_coreState = to;
|
|
283
|
-
if (_emitting) return;
|
|
284
|
-
_emitting = true;
|
|
285
|
-
try {
|
|
286
|
-
emitSafe("core:state_changed", { from, to });
|
|
287
|
-
const current = _coreState;
|
|
288
|
-
if (!_coreReadyEmitted && (current === CoreState.ACTIVE || current === CoreState.ACTIVE_DEGRADED)) {
|
|
289
|
-
_coreReadyEmitted = true;
|
|
290
|
-
emitSafe("core:ready", {});
|
|
291
|
-
}
|
|
292
|
-
if (current === CoreState.SHUTTING_DOWN) {
|
|
293
|
-
emitSafe("core:shutdown_started", {});
|
|
294
|
-
}
|
|
295
|
-
if (current === CoreState.SHUTDOWN) {
|
|
296
|
-
emitSafe("core:shutdown_completed", {});
|
|
297
|
-
}
|
|
298
|
-
} finally {
|
|
299
|
-
_emitting = false;
|
|
300
|
-
}
|
|
301
|
-
if (to === CoreState.ACTIVE && _degradationSources.size > 0) {
|
|
302
|
-
recomputeCoreFromDegradationSources();
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
function initAuthState(state) {
|
|
306
|
-
if (_authInitialized) {
|
|
307
|
-
_logger?.(
|
|
308
|
-
"warn",
|
|
309
|
-
"[glasstrace] initAuthState() called after auth state already initialized. Ignored."
|
|
310
|
-
);
|
|
311
|
-
return;
|
|
312
|
-
}
|
|
313
|
-
_authInitialized = true;
|
|
314
|
-
_authState = state;
|
|
315
|
-
}
|
|
316
|
-
function setAuthState(to) {
|
|
317
|
-
warnIfNotInitialized();
|
|
318
|
-
const from = _authState;
|
|
319
|
-
if (from === to) return;
|
|
320
|
-
const valid = VALID_AUTH_TRANSITIONS[from];
|
|
321
|
-
if (!valid.includes(to)) {
|
|
322
|
-
_logger?.(
|
|
323
|
-
"warn",
|
|
324
|
-
`[glasstrace] Invalid auth state transition: ${from} \u2192 ${to}. Ignored.`
|
|
325
|
-
);
|
|
326
|
-
return;
|
|
327
|
-
}
|
|
328
|
-
_authState = to;
|
|
329
|
-
}
|
|
330
|
-
function setOtelState(to) {
|
|
331
|
-
warnIfNotInitialized();
|
|
332
|
-
const from = _otelState;
|
|
333
|
-
if (from === to) return;
|
|
334
|
-
const valid = VALID_OTEL_TRANSITIONS[from];
|
|
335
|
-
if (!valid.includes(to)) {
|
|
336
|
-
_logger?.(
|
|
337
|
-
"warn",
|
|
338
|
-
`[glasstrace] Invalid OTel state transition: ${from} \u2192 ${to}. Ignored.`
|
|
339
|
-
);
|
|
340
|
-
return;
|
|
341
|
-
}
|
|
342
|
-
_otelState = to;
|
|
343
|
-
}
|
|
344
|
-
var _degradationSources = /* @__PURE__ */ new Set();
|
|
345
|
-
function pushDegradationSource(key) {
|
|
346
|
-
_degradationSources.add(key);
|
|
347
|
-
recomputeCoreFromDegradationSources();
|
|
348
|
-
}
|
|
349
|
-
function clearDegradationSource(key) {
|
|
350
|
-
_degradationSources.delete(key);
|
|
351
|
-
recomputeCoreFromDegradationSources();
|
|
352
|
-
}
|
|
353
|
-
function recomputeCoreFromDegradationSources() {
|
|
354
|
-
const hasDegradation = _degradationSources.size > 0;
|
|
355
|
-
if (hasDegradation && _coreState === CoreState.ACTIVE) {
|
|
356
|
-
setCoreState(CoreState.ACTIVE_DEGRADED);
|
|
357
|
-
return;
|
|
358
|
-
}
|
|
359
|
-
if (!hasDegradation && _coreState === CoreState.ACTIVE_DEGRADED) {
|
|
360
|
-
setCoreState(CoreState.ACTIVE);
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
function getCoreState() {
|
|
364
|
-
return _coreState;
|
|
365
|
-
}
|
|
366
|
-
function getSdkState() {
|
|
367
|
-
return {
|
|
368
|
-
core: _coreState,
|
|
369
|
-
auth: _authState,
|
|
370
|
-
otel: _otelState
|
|
371
|
-
};
|
|
372
|
-
}
|
|
373
|
-
function onLifecycleEvent(event, listener) {
|
|
374
|
-
_emitter.on(event, listener);
|
|
375
|
-
}
|
|
376
|
-
function emitLifecycleEvent(event, payload) {
|
|
377
|
-
emitSafe(event, payload);
|
|
378
|
-
}
|
|
379
|
-
function offLifecycleEvent(event, listener) {
|
|
380
|
-
_emitter.off(event, listener);
|
|
381
|
-
}
|
|
382
|
-
function emitSafe(event, payload) {
|
|
383
|
-
const listeners = _emitter.listeners(event);
|
|
384
|
-
for (const listener of listeners) {
|
|
385
|
-
try {
|
|
386
|
-
const result = listener(payload);
|
|
387
|
-
if (result && typeof result.catch === "function") {
|
|
388
|
-
result.catch((err) => {
|
|
389
|
-
_logger?.(
|
|
390
|
-
"error",
|
|
391
|
-
`[glasstrace] Async error in lifecycle event listener for "${event}": ${err instanceof Error ? err.message : String(err)}`
|
|
392
|
-
);
|
|
393
|
-
});
|
|
394
|
-
}
|
|
395
|
-
} catch (err) {
|
|
396
|
-
_logger?.(
|
|
397
|
-
"error",
|
|
398
|
-
`[glasstrace] Error in lifecycle event listener for "${event}": ${err instanceof Error ? err.message : String(err)}`
|
|
399
|
-
);
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
function isReady() {
|
|
404
|
-
return _coreState === CoreState.ACTIVE || _coreState === CoreState.ACTIVE_DEGRADED;
|
|
405
|
-
}
|
|
406
|
-
function waitForReady(timeoutMs = 3e4) {
|
|
407
|
-
if (isReady()) {
|
|
408
|
-
return Promise.resolve();
|
|
409
|
-
}
|
|
410
|
-
if (_coreState === CoreState.PRODUCTION_DISABLED || _coreState === CoreState.REGISTRATION_FAILED || _coreState === CoreState.SHUTTING_DOWN || _coreState === CoreState.SHUTDOWN) {
|
|
411
|
-
return Promise.reject(new Error(`SDK is in terminal state: ${_coreState}`));
|
|
412
|
-
}
|
|
413
|
-
return new Promise((resolve2, reject) => {
|
|
414
|
-
let settled = false;
|
|
415
|
-
const listener = ({ to }) => {
|
|
416
|
-
if (settled) return;
|
|
417
|
-
if (to === CoreState.ACTIVE || to === CoreState.ACTIVE_DEGRADED) {
|
|
418
|
-
settled = true;
|
|
419
|
-
offLifecycleEvent("core:state_changed", listener);
|
|
420
|
-
resolve2();
|
|
421
|
-
} else if (to === CoreState.PRODUCTION_DISABLED || to === CoreState.REGISTRATION_FAILED || to === CoreState.SHUTTING_DOWN || to === CoreState.SHUTDOWN) {
|
|
422
|
-
settled = true;
|
|
423
|
-
offLifecycleEvent("core:state_changed", listener);
|
|
424
|
-
reject(new Error(`SDK reached terminal state: ${to}`));
|
|
425
|
-
}
|
|
426
|
-
};
|
|
427
|
-
onLifecycleEvent("core:state_changed", listener);
|
|
428
|
-
if (timeoutMs > 0) {
|
|
429
|
-
const timer = setTimeout(() => {
|
|
430
|
-
if (settled) return;
|
|
431
|
-
settled = true;
|
|
432
|
-
offLifecycleEvent("core:state_changed", listener);
|
|
433
|
-
reject(new Error(`waitForReady timed out after ${timeoutMs}ms (state: ${_coreState})`));
|
|
434
|
-
}, timeoutMs);
|
|
435
|
-
if (typeof timer === "object" && "unref" in timer) {
|
|
436
|
-
timer.unref();
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
});
|
|
440
|
-
}
|
|
441
|
-
function getStatus() {
|
|
442
|
-
let mode;
|
|
443
|
-
if (_coreState === CoreState.PRODUCTION_DISABLED) {
|
|
444
|
-
mode = "disabled";
|
|
445
|
-
} else if (_authState === AuthState.CLAIMING || _authState === AuthState.CLAIMED) {
|
|
446
|
-
mode = "claiming";
|
|
447
|
-
} else if (_authState === AuthState.AUTHENTICATED) {
|
|
448
|
-
mode = "authenticated";
|
|
449
|
-
} else {
|
|
450
|
-
mode = "anonymous";
|
|
451
|
-
}
|
|
452
|
-
let tracing;
|
|
453
|
-
if (_otelState === OtelState.COEXISTENCE_FAILED || _otelState === OtelState.UNCONFIGURED || _otelState === OtelState.CONFIGURING) {
|
|
454
|
-
tracing = "not-configured";
|
|
455
|
-
} else if (_coreState === CoreState.ACTIVE_DEGRADED) {
|
|
456
|
-
tracing = "degraded";
|
|
457
|
-
} else if (_otelState === OtelState.AUTO_ATTACHED || _otelState === OtelState.PROCESSOR_PRESENT) {
|
|
458
|
-
tracing = "coexistence";
|
|
459
|
-
} else {
|
|
460
|
-
tracing = "active";
|
|
461
|
-
}
|
|
462
|
-
return {
|
|
463
|
-
ready: isReady(),
|
|
464
|
-
mode,
|
|
465
|
-
tracing
|
|
466
|
-
};
|
|
467
|
-
}
|
|
468
|
-
var _shutdownHooks = [];
|
|
469
|
-
var _signalHandlersRegistered = false;
|
|
470
|
-
var _signalHandler = null;
|
|
471
|
-
var _beforeExitRegistered = false;
|
|
472
|
-
var _beforeExitHandler = null;
|
|
473
|
-
var _shutdownExecuted = false;
|
|
474
|
-
function registerShutdownHook(hook) {
|
|
475
|
-
_shutdownHooks.push(hook);
|
|
476
|
-
_shutdownHooks.sort((a, b) => a.priority - b.priority);
|
|
477
|
-
}
|
|
478
|
-
async function executeShutdown(timeoutMs = 5e3) {
|
|
479
|
-
if (_shutdownExecuted) return;
|
|
480
|
-
_shutdownExecuted = true;
|
|
481
|
-
setCoreState(CoreState.SHUTTING_DOWN);
|
|
482
|
-
for (const hook of _shutdownHooks) {
|
|
483
|
-
try {
|
|
484
|
-
const hookPromise = hook.fn();
|
|
485
|
-
hookPromise.catch(() => {
|
|
486
|
-
});
|
|
487
|
-
await Promise.race([
|
|
488
|
-
hookPromise,
|
|
489
|
-
new Promise((_, reject) => {
|
|
490
|
-
const timer = setTimeout(() => reject(new Error(`Shutdown hook "${hook.name}" timed out`)), timeoutMs);
|
|
491
|
-
if (typeof timer === "object" && "unref" in timer) {
|
|
492
|
-
timer.unref();
|
|
493
|
-
}
|
|
494
|
-
})
|
|
495
|
-
]);
|
|
496
|
-
} catch (err) {
|
|
497
|
-
_logger?.(
|
|
498
|
-
"warn",
|
|
499
|
-
`[glasstrace] Shutdown hook "${hook.name}" failed: ${err instanceof Error ? err.message : String(err)}`
|
|
500
|
-
);
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
setCoreState(CoreState.SHUTDOWN);
|
|
504
|
-
}
|
|
505
|
-
function registerSignalHandlers() {
|
|
506
|
-
if (_signalHandlersRegistered) return;
|
|
507
|
-
if (typeof process === "undefined" || typeof process.once !== "function") return;
|
|
508
|
-
_signalHandlersRegistered = true;
|
|
509
|
-
const otherSigtermListeners = process.listenerCount("SIGTERM");
|
|
510
|
-
const otherSigintListeners = process.listenerCount("SIGINT");
|
|
511
|
-
const handler = (signal) => {
|
|
512
|
-
void executeShutdown().finally(() => {
|
|
513
|
-
if (_signalHandler) {
|
|
514
|
-
process.removeListener("SIGTERM", _signalHandler);
|
|
515
|
-
process.removeListener("SIGINT", _signalHandler);
|
|
516
|
-
}
|
|
517
|
-
const otherListeners = signal === "SIGTERM" ? otherSigtermListeners : otherSigintListeners;
|
|
518
|
-
const otherProviderOwnsSignal = getCoexistenceState() === "coexisting" && otherListeners > 0;
|
|
519
|
-
if (!otherProviderOwnsSignal) {
|
|
520
|
-
process.kill(process.pid, signal);
|
|
521
|
-
}
|
|
522
|
-
});
|
|
523
|
-
};
|
|
524
|
-
_signalHandler = handler;
|
|
525
|
-
process.once("SIGTERM", handler);
|
|
526
|
-
process.once("SIGINT", handler);
|
|
527
|
-
}
|
|
528
|
-
function registerBeforeExitTrigger() {
|
|
529
|
-
if (_beforeExitRegistered) return;
|
|
530
|
-
if (typeof process === "undefined" || typeof process.once !== "function") return;
|
|
531
|
-
_beforeExitRegistered = true;
|
|
532
|
-
const handler = () => {
|
|
533
|
-
void executeShutdown();
|
|
534
|
-
};
|
|
535
|
-
_beforeExitHandler = handler;
|
|
536
|
-
process.once("beforeExit", handler);
|
|
537
|
-
}
|
|
538
|
-
|
|
539
167
|
// src/error-response-body.ts
|
|
540
168
|
var ERROR_RESPONSE_BODY_MAX_BYTES = 4096;
|
|
541
169
|
var ERROR_RESPONSE_BODY_TRUNCATION_MARKER = "...[truncated]";
|
|
@@ -1255,6 +883,15 @@ var GlasstraceExporter = class {
|
|
|
1255
883
|
} else {
|
|
1256
884
|
extra[ATTR.HTTP_STATUS_CODE] = 500;
|
|
1257
885
|
}
|
|
886
|
+
extra[ATTR.HTTP_BOUNDARY_MASKED] = true;
|
|
887
|
+
const inferredStatus = extra[ATTR.HTTP_STATUS_CODE];
|
|
888
|
+
const eventDetails2 = getExceptionEventDetails(span);
|
|
889
|
+
const exceptionMessage = eventDetails2.message ?? (typeof attrs["exception.message"] === "string" ? attrs["exception.message"] : void 0);
|
|
890
|
+
emitLifecycleEvent("core:error_boundary_detected", {
|
|
891
|
+
spanId: span.spanContext().spanId,
|
|
892
|
+
inferredStatus,
|
|
893
|
+
...exceptionMessage !== void 0 ? { exceptionMessage: exceptionMessage.slice(0, 256) } : {}
|
|
894
|
+
});
|
|
1258
895
|
if (this.verbose) {
|
|
1259
896
|
sdkLog(
|
|
1260
897
|
"info",
|
|
@@ -4977,11 +4614,11 @@ function registerGlasstrace(options) {
|
|
|
4977
4614
|
setCoreState(CoreState.REGISTERING);
|
|
4978
4615
|
maybeWarnStaleAgentInstructions({
|
|
4979
4616
|
projectRoot: process.cwd(),
|
|
4980
|
-
sdkVersion: "1.
|
|
4617
|
+
sdkVersion: "1.10.0"
|
|
4981
4618
|
});
|
|
4982
4619
|
startRuntimeStateWriter({
|
|
4983
4620
|
projectRoot: process.cwd(),
|
|
4984
|
-
sdkVersion: "1.
|
|
4621
|
+
sdkVersion: "1.10.0"
|
|
4985
4622
|
});
|
|
4986
4623
|
const config = resolveConfig(options);
|
|
4987
4624
|
if (config.verbose) {
|
|
@@ -5148,8 +4785,8 @@ async function backgroundInit(config, anonKeyForInit, generation) {
|
|
|
5148
4785
|
if (config.verbose) {
|
|
5149
4786
|
console.info("[glasstrace] Background init firing.");
|
|
5150
4787
|
}
|
|
5151
|
-
const healthReport = collectHealthReport("1.
|
|
5152
|
-
const initResult = await performInit(config, anonKeyForInit, "1.
|
|
4788
|
+
const healthReport = collectHealthReport("1.10.0");
|
|
4789
|
+
const initResult = await performInit(config, anonKeyForInit, "1.10.0", healthReport);
|
|
5153
4790
|
if (generation !== registrationGeneration) return;
|
|
5154
4791
|
const currentState = getCoreState();
|
|
5155
4792
|
if (currentState === CoreState.SHUTTING_DOWN || currentState === CoreState.SHUTDOWN) {
|
|
@@ -5172,7 +4809,7 @@ async function backgroundInit(config, anonKeyForInit, generation) {
|
|
|
5172
4809
|
}
|
|
5173
4810
|
maybeInstallConsoleCapture();
|
|
5174
4811
|
if (didLastInitSucceed()) {
|
|
5175
|
-
startHeartbeat(config, anonKeyForInit, "1.
|
|
4812
|
+
startHeartbeat(config, anonKeyForInit, "1.10.0", generation, (newApiKey, accountId) => {
|
|
5176
4813
|
setAuthState(AuthState.CLAIMING);
|
|
5177
4814
|
emitLifecycleEvent("auth:claim_started", { accountId });
|
|
5178
4815
|
setResolvedApiKey(newApiKey);
|
|
@@ -5469,7 +5106,7 @@ async function handleSourceMapUpload(distDir) {
|
|
|
5469
5106
|
);
|
|
5470
5107
|
return;
|
|
5471
5108
|
}
|
|
5472
|
-
const { discoverSourceMapFiles, computeBuildHash, uploadSourceMaps } = await import("./source-map-uploader-
|
|
5109
|
+
const { discoverSourceMapFiles, computeBuildHash, uploadSourceMaps } = await import("./source-map-uploader-CLYCE2TZ.js");
|
|
5473
5110
|
const files = await discoverSourceMapFiles(distDir);
|
|
5474
5111
|
if (files.length === 0) {
|
|
5475
5112
|
console.info("[glasstrace] No source map files found. Skipping upload.");
|
|
@@ -5562,9 +5199,6 @@ export {
|
|
|
5562
5199
|
getDateString,
|
|
5563
5200
|
SessionManager,
|
|
5564
5201
|
classifyFetchTarget,
|
|
5565
|
-
isReady,
|
|
5566
|
-
waitForReady,
|
|
5567
|
-
getStatus,
|
|
5568
5202
|
GlasstraceExporter,
|
|
5569
5203
|
createGlasstraceSpanProcessor,
|
|
5570
5204
|
registerGlasstrace,
|
|
@@ -5572,4 +5206,4 @@ export {
|
|
|
5572
5206
|
withGlasstraceConfig,
|
|
5573
5207
|
captureError
|
|
5574
5208
|
};
|
|
5575
|
-
//# sourceMappingURL=chunk-
|
|
5209
|
+
//# sourceMappingURL=chunk-OXA4IHQX.js.map
|