@glasstrace/sdk 0.12.5 → 0.13.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.
package/dist/index.cjs CHANGED
@@ -17378,17 +17378,21 @@ var GlasstraceExporter = class {
17378
17378
  this.bufferSpans(spans, resultCallback);
17379
17379
  return;
17380
17380
  }
17381
- const enrichedSpans = spans.map((span) => this.enrichSpan(span));
17382
17381
  if (this.verbose) {
17383
- sdkLog("info", `[glasstrace:diag] Export batch: ${enrichedSpans.length} spans`);
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
+ }
17384
17389
  }
17390
+ const enrichedSpans = spans.map((span) => this.enrichSpan(span));
17385
17391
  const exporter = this.ensureDelegate();
17386
17392
  if (exporter) {
17387
17393
  exporter.export(enrichedSpans, (result) => {
17388
17394
  if (result.code !== 0) {
17389
17395
  sdkLog("warn", `[glasstrace] Span export failed: ${result.error?.message ?? "unknown error"}`);
17390
- } else if (this.verbose) {
17391
- sdkLog("info", `[glasstrace:diag] Export success: ${enrichedSpans.length} spans delivered`);
17392
17396
  }
17393
17397
  resultCallback(result);
17394
17398
  });
@@ -17575,17 +17579,11 @@ var GlasstraceExporter = class {
17575
17579
  bufferSpans(spans, resultCallback) {
17576
17580
  this.pendingBatches.push({ spans, resultCallback });
17577
17581
  this.pendingSpanCount += spans.length;
17578
- if (this.verbose) {
17579
- sdkLog("info", `[glasstrace:diag] Buffering ${spans.length} spans (key pending, total: ${this.pendingSpanCount})`);
17580
- }
17581
17582
  while (this.pendingSpanCount > MAX_PENDING_SPANS && this.pendingBatches.length > 1) {
17582
17583
  const evicted = this.pendingBatches.shift();
17583
17584
  this.pendingSpanCount -= evicted.spans.length;
17584
17585
  recordSpansDropped(evicted.spans.length);
17585
17586
  evicted.resultCallback({ code: 0 });
17586
- if (this.verbose) {
17587
- sdkLog("info", `[glasstrace:diag] Buffer overflow: evicted ${evicted.spans.length} spans (total pending: ${this.pendingSpanCount})`);
17588
- }
17589
17587
  if (!this.overflowLogged) {
17590
17588
  this.overflowLogged = true;
17591
17589
  console.warn(
@@ -17620,12 +17618,19 @@ var GlasstraceExporter = class {
17620
17618
  this.pendingBatches = [];
17621
17619
  this.pendingSpanCount = 0;
17622
17620
  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
+ }
17623
17630
  const enriched = batch.spans.map((span) => this.enrichSpan(span));
17624
17631
  exporter.export(enriched, (result) => {
17625
17632
  if (result.code !== 0) {
17626
17633
  sdkLog("warn", `[glasstrace] Span export failed: ${result.error?.message ?? "unknown error"}`);
17627
- } else if (this.verbose) {
17628
- sdkLog("info", `[glasstrace:diag] Flush export success: ${enriched.length} spans delivered`);
17629
17634
  }
17630
17635
  batch.resultCallback(result);
17631
17636
  });
@@ -20469,9 +20474,6 @@ async function configureOtel(config2, sessionManager) {
20469
20474
  const processor = new BatchSpanProcessor(glasstraceExporter, {
20470
20475
  scheduledDelayMillis: 1e3
20471
20476
  });
20472
- if (config2.verbose) {
20473
- sdkLog("info", "[glasstrace:diag] BatchSpanProcessor configured: scheduledDelayMillis=1000");
20474
- }
20475
20477
  const provider = new BasicTracerProvider({
20476
20478
  spanProcessors: [processor]
20477
20479
  });
@@ -20739,8 +20741,8 @@ async function backgroundInit(config2, anonKeyForInit, generation) {
20739
20741
  if (config2.verbose) {
20740
20742
  console.info("[glasstrace] Background init firing.");
20741
20743
  }
20742
- const healthReport = collectHealthReport("0.12.5");
20743
- const initResult = await performInit(config2, anonKeyForInit, "0.12.5", healthReport);
20744
+ const healthReport = collectHealthReport("0.13.1");
20745
+ const initResult = await performInit(config2, anonKeyForInit, "0.13.1", healthReport);
20744
20746
  if (generation !== registrationGeneration) return;
20745
20747
  if (initResult?.claimResult) {
20746
20748
  setResolvedApiKey(initResult.claimResult.newApiKey);
@@ -20748,7 +20750,7 @@ async function backgroundInit(config2, anonKeyForInit, generation) {
20748
20750
  }
20749
20751
  maybeInstallConsoleCapture();
20750
20752
  if (didLastInitSucceed()) {
20751
- startHeartbeat(config2, anonKeyForInit, "0.12.5", generation, (newApiKey) => {
20753
+ startHeartbeat(config2, anonKeyForInit, "0.13.1", generation, (newApiKey) => {
20752
20754
  setResolvedApiKey(newApiKey);
20753
20755
  notifyApiKeyResolved();
20754
20756
  });