@glasstrace/sdk 0.12.2 → 0.12.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.d.cts CHANGED
@@ -394,6 +394,10 @@ declare class GlasstraceExporter implements SpanExporter {
394
394
  */
395
395
  notifyKeyResolved(): void;
396
396
  shutdown(): Promise<void>;
397
+ /**
398
+ * Flushes any pending buffered spans (if the API key has resolved) and
399
+ * delegates to the underlying exporter's forceFlush to drain its queue.
400
+ */
397
401
  forceFlush(): Promise<void>;
398
402
  /**
399
403
  * Enriches a ReadableSpan with all glasstrace.* attributes.
package/dist/index.d.ts CHANGED
@@ -394,6 +394,10 @@ declare class GlasstraceExporter implements SpanExporter {
394
394
  */
395
395
  notifyKeyResolved(): void;
396
396
  shutdown(): Promise<void>;
397
+ /**
398
+ * Flushes any pending buffered spans (if the API key has resolved) and
399
+ * delegates to the underlying exporter's forceFlush to drain its queue.
400
+ */
397
401
  forceFlush(): Promise<void>;
398
402
  /**
399
403
  * Enriches a ReadableSpan with all glasstrace.* attributes.
package/dist/index.js CHANGED
@@ -9,10 +9,11 @@ import {
9
9
  maybeShowMcpNudge,
10
10
  readEnvVars,
11
11
  resolveConfig,
12
+ sdkLog,
12
13
  uploadSourceMaps,
13
14
  uploadSourceMapsAuto,
14
15
  uploadSourceMapsPresigned
15
- } from "./chunk-MSMOH6IH.js";
16
+ } from "./chunk-J576N5MN.js";
16
17
  import {
17
18
  buildImportGraph,
18
19
  discoverTestFiles,
@@ -30,6 +31,7 @@ import {
30
31
  SessionIdSchema
31
32
  } from "./chunk-OKIP4SRG.js";
32
33
  import {
34
+ DiagLogLevel,
33
35
  INVALID_SPAN_CONTEXT,
34
36
  SamplingDecision,
35
37
  SpanKind,
@@ -585,7 +587,12 @@ var GlasstraceExporter = class {
585
587
  const enrichedSpans = spans.map((span) => this.enrichSpan(span));
586
588
  const exporter = this.ensureDelegate();
587
589
  if (exporter) {
588
- exporter.export(enrichedSpans, resultCallback);
590
+ exporter.export(enrichedSpans, (result) => {
591
+ if (result.code !== 0) {
592
+ sdkLog("warn", `[glasstrace] Span export failed: ${result.error?.message ?? "unknown error"}`);
593
+ }
594
+ resultCallback(result);
595
+ });
589
596
  recordSpansExported(enrichedSpans.length);
590
597
  } else {
591
598
  recordSpansDropped(enrichedSpans.length);
@@ -618,7 +625,14 @@ var GlasstraceExporter = class {
618
625
  return this.delegate.shutdown();
619
626
  }
620
627
  }
628
+ /**
629
+ * Flushes any pending buffered spans (if the API key has resolved) and
630
+ * delegates to the underlying exporter's forceFlush to drain its queue.
631
+ */
621
632
  forceFlush() {
633
+ if (this.getApiKey() !== API_KEY_PENDING && this.pendingBatches.length > 0) {
634
+ this.flushPending();
635
+ }
622
636
  if (this.delegate?.forceFlush) {
623
637
  return this.delegate.forceFlush();
624
638
  }
@@ -787,7 +801,12 @@ var GlasstraceExporter = class {
787
801
  this.pendingSpanCount = 0;
788
802
  for (const batch of batches) {
789
803
  const enriched = batch.spans.map((span) => this.enrichSpan(span));
790
- exporter.export(enriched, batch.resultCallback);
804
+ exporter.export(enriched, (result) => {
805
+ if (result.code !== 0) {
806
+ sdkLog("warn", `[glasstrace] Span export failed: ${result.error?.message ?? "unknown error"}`);
807
+ }
808
+ batch.resultCallback(result);
809
+ });
791
810
  recordSpansExported(enriched.length);
792
811
  }
793
812
  }
@@ -3578,7 +3597,21 @@ async function configureOtel(config, sessionManager) {
3578
3597
  _activeExporter = null;
3579
3598
  return;
3580
3599
  }
3581
- const processor = new BatchSpanProcessor(glasstraceExporter);
3600
+ if (config.verbose) {
3601
+ diag.setLogger(
3602
+ {
3603
+ verbose: (msg) => sdkLog("info", `[otel] ${msg}`),
3604
+ debug: (msg) => sdkLog("info", `[otel] ${msg}`),
3605
+ info: (msg) => sdkLog("info", `[otel] ${msg}`),
3606
+ warn: (msg) => sdkLog("warn", `[otel] ${msg}`),
3607
+ error: (msg) => sdkLog("error", `[otel] ${msg}`)
3608
+ },
3609
+ DiagLogLevel.WARN
3610
+ );
3611
+ }
3612
+ const processor = new BatchSpanProcessor(glasstraceExporter, {
3613
+ scheduledDelayMillis: 1e3
3614
+ });
3582
3615
  const provider = new BasicTracerProvider({
3583
3616
  spanProcessors: [processor]
3584
3617
  });
@@ -3739,8 +3772,8 @@ async function backgroundInit(config, anonKeyForInit, generation) {
3739
3772
  if (config.verbose) {
3740
3773
  console.info("[glasstrace] Background init firing.");
3741
3774
  }
3742
- const healthReport = collectHealthReport("0.12.2");
3743
- const initResult = await performInit(config, anonKeyForInit, "0.12.2", healthReport);
3775
+ const healthReport = collectHealthReport("0.12.3");
3776
+ const initResult = await performInit(config, anonKeyForInit, "0.12.3", healthReport);
3744
3777
  if (generation !== registrationGeneration) return;
3745
3778
  if (initResult?.claimResult) {
3746
3779
  setResolvedApiKey(initResult.claimResult.newApiKey);
@@ -3814,7 +3847,7 @@ async function handleSourceMapUpload(distDir) {
3814
3847
  );
3815
3848
  return;
3816
3849
  }
3817
- const { discoverSourceMapFiles: discoverSourceMapFiles2, computeBuildHash: computeBuildHash2, uploadSourceMaps: uploadSourceMaps2 } = await import("./source-map-uploader-ZFCYOURS.js");
3850
+ const { discoverSourceMapFiles: discoverSourceMapFiles2, computeBuildHash: computeBuildHash2, uploadSourceMaps: uploadSourceMaps2 } = await import("./source-map-uploader-ZHD654EG.js");
3818
3851
  const files = await discoverSourceMapFiles2(distDir);
3819
3852
  if (files.length === 0) {
3820
3853
  console.info("[glasstrace] No source map files found. Skipping upload.");