@glasstrace/sdk 1.9.0 → 1.9.1

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.
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  tracedRequestMiddleware
3
- } from "./chunk-QHV7NFON.js";
3
+ } from "./chunk-QOHKZOKB.js";
4
4
  import {
5
5
  withAsyncCausality
6
- } from "./chunk-RQ5BIWDT.js";
6
+ } from "./chunk-QEXRCXSY.js";
7
7
  import {
8
8
  GlasstraceSpanProcessor,
9
9
  SdkError,
package/dist/index.cjs CHANGED
@@ -23523,11 +23523,11 @@ function registerGlasstrace(options) {
23523
23523
  setCoreState(CoreState.REGISTERING);
23524
23524
  maybeWarnStaleAgentInstructions({
23525
23525
  projectRoot: process.cwd(),
23526
- sdkVersion: "1.9.0"
23526
+ sdkVersion: "1.9.1"
23527
23527
  });
23528
23528
  startRuntimeStateWriter({
23529
23529
  projectRoot: process.cwd(),
23530
- sdkVersion: "1.9.0"
23530
+ sdkVersion: "1.9.1"
23531
23531
  });
23532
23532
  const config2 = resolveConfig(options);
23533
23533
  if (config2.verbose) {
@@ -23694,8 +23694,8 @@ async function backgroundInit(config2, anonKeyForInit, generation) {
23694
23694
  if (config2.verbose) {
23695
23695
  console.info("[glasstrace] Background init firing.");
23696
23696
  }
23697
- const healthReport = collectHealthReport("1.9.0");
23698
- const initResult = await performInit(config2, anonKeyForInit, "1.9.0", healthReport);
23697
+ const healthReport = collectHealthReport("1.9.1");
23698
+ const initResult = await performInit(config2, anonKeyForInit, "1.9.1", healthReport);
23699
23699
  if (generation !== registrationGeneration) return;
23700
23700
  const currentState = getCoreState();
23701
23701
  if (currentState === CoreState.SHUTTING_DOWN || currentState === CoreState.SHUTDOWN) {
@@ -23718,7 +23718,7 @@ async function backgroundInit(config2, anonKeyForInit, generation) {
23718
23718
  }
23719
23719
  maybeInstallConsoleCapture();
23720
23720
  if (didLastInitSucceed()) {
23721
- startHeartbeat(config2, anonKeyForInit, "1.9.0", generation, (newApiKey, accountId) => {
23721
+ startHeartbeat(config2, anonKeyForInit, "1.9.1", generation, (newApiKey, accountId) => {
23722
23722
  setAuthState(AuthState.CLAIMING);
23723
23723
  emitLifecycleEvent("auth:claim_started", { accountId });
23724
23724
  setResolvedApiKey(newApiKey);
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  registerGlasstrace,
13
13
  waitForReady,
14
14
  withGlasstraceConfig
15
- } from "./chunk-XEPC4NFL.js";
15
+ } from "./chunk-2F2MGFLO.js";
16
16
  import {
17
17
  GlasstraceSpanProcessor,
18
18
  SdkError,
@@ -14942,49 +14942,58 @@ function tracedRequestMiddleware(options, handler) {
14942
14942
  }
14943
14943
  const wrapped = ((req, ...rest) => {
14944
14944
  const tracer = trace.getTracer(TRACER_NAME);
14945
- return tracer.startActiveSpan(options.name, (span) => {
14946
- if (isNoopSpan(span)) {
14947
- if (!_skippedUninstalledEmitted) {
14948
- _skippedUninstalledEmitted = true;
14949
- tryEmitLifecycleEvent("middleware:skipped_uninstalled", {});
14945
+ let callbackInvoked = false;
14946
+ try {
14947
+ return tracer.startActiveSpan(options.name, (span) => {
14948
+ callbackInvoked = true;
14949
+ if (isNoopSpan(span)) {
14950
+ if (!_skippedUninstalledEmitted) {
14951
+ _skippedUninstalledEmitted = true;
14952
+ tryEmitLifecycleEvent("middleware:skipped_uninstalled", {});
14953
+ }
14954
+ endSpanSafely(span);
14955
+ return handler(req, ...rest);
14950
14956
  }
14951
- endSpanSafely(span);
14952
- return handler(req, ...rest);
14953
- }
14954
- try {
14955
- if (options.attributes) {
14956
- span.setAttributes(options.attributes);
14957
+ try {
14958
+ if (options.attributes) {
14959
+ span.setAttributes(options.attributes);
14960
+ }
14961
+ const path = extractRequestPath(req);
14962
+ if (path !== void 0) {
14963
+ span.setAttribute(ATTR.CAUSAL_MIDDLEWARE_FOR_REQUEST, path);
14964
+ }
14965
+ } catch {
14957
14966
  }
14958
- const path = extractRequestPath(req);
14959
- if (path !== void 0) {
14960
- span.setAttribute(ATTR.CAUSAL_MIDDLEWARE_FOR_REQUEST, path);
14967
+ let result;
14968
+ try {
14969
+ result = handler(req, ...rest);
14970
+ } catch (error48) {
14971
+ recordSpanError(span, error48);
14972
+ endSpanSafely(span);
14973
+ throw error48;
14974
+ }
14975
+ if (result !== null && typeof result === "object" && typeof result.then === "function") {
14976
+ return result.then(
14977
+ (value) => {
14978
+ endSpanSafely(span);
14979
+ return value;
14980
+ },
14981
+ (error48) => {
14982
+ recordSpanError(span, error48);
14983
+ endSpanSafely(span);
14984
+ throw error48;
14985
+ }
14986
+ );
14961
14987
  }
14962
- } catch {
14963
- }
14964
- let result;
14965
- try {
14966
- result = handler(req, ...rest);
14967
- } catch (error48) {
14968
- recordSpanError(span, error48);
14969
14988
  endSpanSafely(span);
14970
- throw error48;
14971
- }
14972
- if (result !== null && typeof result === "object" && typeof result.then === "function") {
14973
- return result.then(
14974
- (value) => {
14975
- endSpanSafely(span);
14976
- return value;
14977
- },
14978
- (error48) => {
14979
- recordSpanError(span, error48);
14980
- endSpanSafely(span);
14981
- throw error48;
14982
- }
14983
- );
14989
+ return result;
14990
+ });
14991
+ } catch (err) {
14992
+ if (callbackInvoked) {
14993
+ throw err;
14984
14994
  }
14985
- endSpanSafely(span);
14986
- return result;
14987
- });
14995
+ return handler(req, ...rest);
14996
+ }
14988
14997
  });
14989
14998
  return wrapped;
14990
14999
  }