@glasstrace/sdk 0.13.0 → 0.13.2
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 +25 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +26 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
import {
|
|
34
34
|
DiagLogLevel,
|
|
35
35
|
INVALID_SPAN_CONTEXT,
|
|
36
|
+
ROOT_CONTEXT,
|
|
36
37
|
SamplingDecision,
|
|
37
38
|
SpanKind,
|
|
38
39
|
SpanStatusCode,
|
|
@@ -3642,6 +3643,28 @@ async function configureOtel(config, sessionManager) {
|
|
|
3642
3643
|
const provider = new BasicTracerProvider({
|
|
3643
3644
|
spanProcessors: [processor]
|
|
3644
3645
|
});
|
|
3646
|
+
const asyncHooks = await tryImport("node:async_hooks");
|
|
3647
|
+
if (!asyncHooks) {
|
|
3648
|
+
trace.setGlobalTracerProvider(provider);
|
|
3649
|
+
registerShutdownHooks(provider);
|
|
3650
|
+
return;
|
|
3651
|
+
}
|
|
3652
|
+
const { AsyncLocalStorage } = asyncHooks;
|
|
3653
|
+
const als = new AsyncLocalStorage();
|
|
3654
|
+
const contextManager = {
|
|
3655
|
+
active: () => als.getStore() ?? ROOT_CONTEXT,
|
|
3656
|
+
with: (context2, fn, thisArg, ...args) => als.run(context2, () => fn.apply(thisArg, args)),
|
|
3657
|
+
bind: (context2, target) => {
|
|
3658
|
+
if (typeof target === "function") {
|
|
3659
|
+
const bound = (...args) => als.run(context2, () => target(...args));
|
|
3660
|
+
return bound;
|
|
3661
|
+
}
|
|
3662
|
+
return target;
|
|
3663
|
+
},
|
|
3664
|
+
enable: () => contextManager,
|
|
3665
|
+
disable: () => contextManager
|
|
3666
|
+
};
|
|
3667
|
+
context.setGlobalContextManager(contextManager);
|
|
3645
3668
|
trace.setGlobalTracerProvider(provider);
|
|
3646
3669
|
registerShutdownHooks(provider);
|
|
3647
3670
|
}
|
|
@@ -3902,8 +3925,8 @@ async function backgroundInit(config, anonKeyForInit, generation) {
|
|
|
3902
3925
|
if (config.verbose) {
|
|
3903
3926
|
console.info("[glasstrace] Background init firing.");
|
|
3904
3927
|
}
|
|
3905
|
-
const healthReport = collectHealthReport("0.13.
|
|
3906
|
-
const initResult = await performInit(config, anonKeyForInit, "0.13.
|
|
3928
|
+
const healthReport = collectHealthReport("0.13.2");
|
|
3929
|
+
const initResult = await performInit(config, anonKeyForInit, "0.13.2", healthReport);
|
|
3907
3930
|
if (generation !== registrationGeneration) return;
|
|
3908
3931
|
if (initResult?.claimResult) {
|
|
3909
3932
|
setResolvedApiKey(initResult.claimResult.newApiKey);
|
|
@@ -3911,7 +3934,7 @@ async function backgroundInit(config, anonKeyForInit, generation) {
|
|
|
3911
3934
|
}
|
|
3912
3935
|
maybeInstallConsoleCapture();
|
|
3913
3936
|
if (didLastInitSucceed()) {
|
|
3914
|
-
startHeartbeat(config, anonKeyForInit, "0.13.
|
|
3937
|
+
startHeartbeat(config, anonKeyForInit, "0.13.2", generation, (newApiKey) => {
|
|
3915
3938
|
setResolvedApiKey(newApiKey);
|
|
3916
3939
|
notifyApiKeyResolved();
|
|
3917
3940
|
});
|