@glasstrace/sdk 0.13.1 → 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 CHANGED
@@ -17357,7 +17357,6 @@ var GlasstraceExporter = class {
17357
17357
  environment;
17358
17358
  endpointUrl;
17359
17359
  createDelegateFn;
17360
- verbose;
17361
17360
  delegate = null;
17362
17361
  delegateKey = null;
17363
17362
  pendingBatches = [];
@@ -17370,7 +17369,6 @@ var GlasstraceExporter = class {
17370
17369
  this.environment = options.environment;
17371
17370
  this.endpointUrl = options.endpointUrl;
17372
17371
  this.createDelegateFn = options.createDelegate;
17373
- this.verbose = options.verbose ?? false;
17374
17372
  }
17375
17373
  export(spans, resultCallback) {
17376
17374
  const currentKey = this.getApiKey();
@@ -17378,15 +17376,6 @@ var GlasstraceExporter = class {
17378
17376
  this.bufferSpans(spans, resultCallback);
17379
17377
  return;
17380
17378
  }
17381
- if (this.verbose) {
17382
- for (const span of spans) {
17383
- const ctx = span.spanContext();
17384
- sdkLog(
17385
- "info",
17386
- `[glasstrace:span-diag] name=${span.name} traceId=${ctx.traceId} spanId=${ctx.spanId} parentSpanId=${span.parentSpanId ?? "root"}`
17387
- );
17388
- }
17389
- }
17390
17379
  const enrichedSpans = spans.map((span) => this.enrichSpan(span));
17391
17380
  const exporter = this.ensureDelegate();
17392
17381
  if (exporter) {
@@ -17618,15 +17607,6 @@ var GlasstraceExporter = class {
17618
17607
  this.pendingBatches = [];
17619
17608
  this.pendingSpanCount = 0;
17620
17609
  for (const batch of batches) {
17621
- if (this.verbose) {
17622
- for (const span of batch.spans) {
17623
- const ctx = span.spanContext();
17624
- sdkLog(
17625
- "info",
17626
- `[glasstrace:span-diag] name=${span.name} traceId=${ctx.traceId} spanId=${ctx.spanId} parentSpanId=${span.parentSpanId ?? "root"}`
17627
- );
17628
- }
17629
- }
17630
17610
  const enriched = batch.spans.map((span) => this.enrichSpan(span));
17631
17611
  exporter.export(enriched, (result) => {
17632
17612
  if (result.code !== 0) {
@@ -20430,8 +20410,7 @@ async function configureOtel(config2, sessionManager) {
20430
20410
  getConfig: () => getActiveConfig(),
20431
20411
  environment: config2.environment,
20432
20412
  endpointUrl: exporterUrl,
20433
- createDelegate: createOtlpExporter,
20434
- verbose: config2.verbose
20413
+ createDelegate: createOtlpExporter
20435
20414
  });
20436
20415
  _activeExporter = glasstraceExporter;
20437
20416
  const vercelOtel = await tryImport("@vercel/otel");
@@ -20481,6 +20460,31 @@ async function configureOtel(config2, sessionManager) {
20481
20460
  registerShutdownHooks(provider);
20482
20461
  }
20483
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
+
20484
20488
  // src/register.ts
20485
20489
  init_console_capture();
20486
20490
 
@@ -20642,6 +20646,7 @@ function registerGlasstrace(options) {
20642
20646
  }
20643
20647
  isRegistered = true;
20644
20648
  const currentGeneration = registrationGeneration;
20649
+ installContextManager();
20645
20650
  void configureOtel(config2, sessionManager).then(
20646
20651
  () => {
20647
20652
  maybeInstallConsoleCapture();
@@ -20741,8 +20746,8 @@ async function backgroundInit(config2, anonKeyForInit, generation) {
20741
20746
  if (config2.verbose) {
20742
20747
  console.info("[glasstrace] Background init firing.");
20743
20748
  }
20744
- const healthReport = collectHealthReport("0.13.1");
20745
- const initResult = await performInit(config2, anonKeyForInit, "0.13.1", healthReport);
20749
+ const healthReport = collectHealthReport("0.13.3");
20750
+ const initResult = await performInit(config2, anonKeyForInit, "0.13.3", healthReport);
20746
20751
  if (generation !== registrationGeneration) return;
20747
20752
  if (initResult?.claimResult) {
20748
20753
  setResolvedApiKey(initResult.claimResult.newApiKey);
@@ -20750,7 +20755,7 @@ async function backgroundInit(config2, anonKeyForInit, generation) {
20750
20755
  }
20751
20756
  maybeInstallConsoleCapture();
20752
20757
  if (didLastInitSucceed()) {
20753
- startHeartbeat(config2, anonKeyForInit, "0.13.1", generation, (newApiKey) => {
20758
+ startHeartbeat(config2, anonKeyForInit, "0.13.3", generation, (newApiKey) => {
20754
20759
  setResolvedApiKey(newApiKey);
20755
20760
  notifyApiKeyResolved();
20756
20761
  });