@glasstrace/sdk 0.13.2 → 0.13.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/dist/index.cjs +29 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +28 -25
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -20456,32 +20456,35 @@ async function configureOtel(config2, sessionManager) {
|
|
|
20456
20456
|
const provider = new BasicTracerProvider({
|
|
20457
20457
|
spanProcessors: [processor]
|
|
20458
20458
|
});
|
|
20459
|
-
const asyncHooks = await tryImport("node:async_hooks");
|
|
20460
|
-
if (!asyncHooks) {
|
|
20461
|
-
trace.setGlobalTracerProvider(provider);
|
|
20462
|
-
registerShutdownHooks(provider);
|
|
20463
|
-
return;
|
|
20464
|
-
}
|
|
20465
|
-
const { AsyncLocalStorage } = asyncHooks;
|
|
20466
|
-
const als = new AsyncLocalStorage();
|
|
20467
|
-
const contextManager = {
|
|
20468
|
-
active: () => als.getStore() ?? ROOT_CONTEXT,
|
|
20469
|
-
with: (context2, fn, thisArg, ...args) => als.run(context2, () => fn.apply(thisArg, args)),
|
|
20470
|
-
bind: (context2, target) => {
|
|
20471
|
-
if (typeof target === "function") {
|
|
20472
|
-
const bound = (...args) => als.run(context2, () => target(...args));
|
|
20473
|
-
return bound;
|
|
20474
|
-
}
|
|
20475
|
-
return target;
|
|
20476
|
-
},
|
|
20477
|
-
enable: () => contextManager,
|
|
20478
|
-
disable: () => contextManager
|
|
20479
|
-
};
|
|
20480
|
-
context.setGlobalContextManager(contextManager);
|
|
20481
20459
|
trace.setGlobalTracerProvider(provider);
|
|
20482
20460
|
registerShutdownHooks(provider);
|
|
20483
20461
|
}
|
|
20484
20462
|
|
|
20463
|
+
// src/context-manager.ts
|
|
20464
|
+
init_esm();
|
|
20465
|
+
function installContextManager() {
|
|
20466
|
+
try {
|
|
20467
|
+
const req = Function("id", "return require(id)");
|
|
20468
|
+
const asyncHooks = req("node:async_hooks");
|
|
20469
|
+
const als = new asyncHooks.AsyncLocalStorage();
|
|
20470
|
+
const contextManager = {
|
|
20471
|
+
active: () => als.getStore() ?? ROOT_CONTEXT,
|
|
20472
|
+
with: (context2, fn, thisArg, ...args) => als.run(context2, () => fn.apply(thisArg, args)),
|
|
20473
|
+
bind: (context2, target) => {
|
|
20474
|
+
if (typeof target === "function") {
|
|
20475
|
+
const bound = (...fnArgs) => als.run(context2, () => target(...fnArgs));
|
|
20476
|
+
return bound;
|
|
20477
|
+
}
|
|
20478
|
+
return target;
|
|
20479
|
+
},
|
|
20480
|
+
enable: () => contextManager,
|
|
20481
|
+
disable: () => contextManager
|
|
20482
|
+
};
|
|
20483
|
+
context.setGlobalContextManager(contextManager);
|
|
20484
|
+
} catch {
|
|
20485
|
+
}
|
|
20486
|
+
}
|
|
20487
|
+
|
|
20485
20488
|
// src/register.ts
|
|
20486
20489
|
init_console_capture();
|
|
20487
20490
|
|
|
@@ -20643,6 +20646,7 @@ function registerGlasstrace(options) {
|
|
|
20643
20646
|
}
|
|
20644
20647
|
isRegistered = true;
|
|
20645
20648
|
const currentGeneration = registrationGeneration;
|
|
20649
|
+
installContextManager();
|
|
20646
20650
|
void configureOtel(config2, sessionManager).then(
|
|
20647
20651
|
() => {
|
|
20648
20652
|
maybeInstallConsoleCapture();
|
|
@@ -20742,8 +20746,8 @@ async function backgroundInit(config2, anonKeyForInit, generation) {
|
|
|
20742
20746
|
if (config2.verbose) {
|
|
20743
20747
|
console.info("[glasstrace] Background init firing.");
|
|
20744
20748
|
}
|
|
20745
|
-
const healthReport = collectHealthReport("0.13.
|
|
20746
|
-
const initResult = await performInit(config2, anonKeyForInit, "0.13.
|
|
20749
|
+
const healthReport = collectHealthReport("0.13.3");
|
|
20750
|
+
const initResult = await performInit(config2, anonKeyForInit, "0.13.3", healthReport);
|
|
20747
20751
|
if (generation !== registrationGeneration) return;
|
|
20748
20752
|
if (initResult?.claimResult) {
|
|
20749
20753
|
setResolvedApiKey(initResult.claimResult.newApiKey);
|
|
@@ -20751,7 +20755,7 @@ async function backgroundInit(config2, anonKeyForInit, generation) {
|
|
|
20751
20755
|
}
|
|
20752
20756
|
maybeInstallConsoleCapture();
|
|
20753
20757
|
if (didLastInitSucceed()) {
|
|
20754
|
-
startHeartbeat(config2, anonKeyForInit, "0.13.
|
|
20758
|
+
startHeartbeat(config2, anonKeyForInit, "0.13.3", generation, (newApiKey) => {
|
|
20755
20759
|
setResolvedApiKey(newApiKey);
|
|
20756
20760
|
notifyApiKeyResolved();
|
|
20757
20761
|
});
|