@glasstrace/sdk 0.12.4 → 0.12.5
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 +38 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +38 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -17357,6 +17357,7 @@ var GlasstraceExporter = class {
|
|
|
17357
17357
|
environment;
|
|
17358
17358
|
endpointUrl;
|
|
17359
17359
|
createDelegateFn;
|
|
17360
|
+
verbose;
|
|
17360
17361
|
delegate = null;
|
|
17361
17362
|
delegateKey = null;
|
|
17362
17363
|
pendingBatches = [];
|
|
@@ -17369,6 +17370,7 @@ var GlasstraceExporter = class {
|
|
|
17369
17370
|
this.environment = options.environment;
|
|
17370
17371
|
this.endpointUrl = options.endpointUrl;
|
|
17371
17372
|
this.createDelegateFn = options.createDelegate;
|
|
17373
|
+
this.verbose = options.verbose ?? false;
|
|
17372
17374
|
}
|
|
17373
17375
|
export(spans, resultCallback) {
|
|
17374
17376
|
const currentKey = this.getApiKey();
|
|
@@ -17377,11 +17379,16 @@ var GlasstraceExporter = class {
|
|
|
17377
17379
|
return;
|
|
17378
17380
|
}
|
|
17379
17381
|
const enrichedSpans = spans.map((span) => this.enrichSpan(span));
|
|
17382
|
+
if (this.verbose) {
|
|
17383
|
+
sdkLog("info", `[glasstrace:diag] Export batch: ${enrichedSpans.length} spans`);
|
|
17384
|
+
}
|
|
17380
17385
|
const exporter = this.ensureDelegate();
|
|
17381
17386
|
if (exporter) {
|
|
17382
17387
|
exporter.export(enrichedSpans, (result) => {
|
|
17383
17388
|
if (result.code !== 0) {
|
|
17384
17389
|
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`);
|
|
17385
17392
|
}
|
|
17386
17393
|
resultCallback(result);
|
|
17387
17394
|
});
|
|
@@ -17474,6 +17481,21 @@ var GlasstraceExporter = class {
|
|
|
17474
17481
|
if (statusCode !== void 0) {
|
|
17475
17482
|
extra[ATTR.HTTP_STATUS_CODE] = statusCode;
|
|
17476
17483
|
}
|
|
17484
|
+
if (method && span.status?.code === SpanStatusCode.ERROR) {
|
|
17485
|
+
if (statusCode === void 0 || statusCode === 0 || statusCode === 200) {
|
|
17486
|
+
const httpErrorType = attrs["error.type"];
|
|
17487
|
+
if (typeof httpErrorType === "string") {
|
|
17488
|
+
const parsed = parseInt(httpErrorType, 10);
|
|
17489
|
+
if (!isNaN(parsed) && parsed >= 400 && parsed <= 599) {
|
|
17490
|
+
extra[ATTR.HTTP_STATUS_CODE] = parsed;
|
|
17491
|
+
} else {
|
|
17492
|
+
extra[ATTR.HTTP_STATUS_CODE] = 500;
|
|
17493
|
+
}
|
|
17494
|
+
} else {
|
|
17495
|
+
extra[ATTR.HTTP_STATUS_CODE] = 500;
|
|
17496
|
+
}
|
|
17497
|
+
}
|
|
17498
|
+
}
|
|
17477
17499
|
if (span.startTime && span.endTime) {
|
|
17478
17500
|
const [startSec, startNano] = span.startTime;
|
|
17479
17501
|
const [endSec, endNano] = span.endTime;
|
|
@@ -17553,11 +17575,17 @@ var GlasstraceExporter = class {
|
|
|
17553
17575
|
bufferSpans(spans, resultCallback) {
|
|
17554
17576
|
this.pendingBatches.push({ spans, resultCallback });
|
|
17555
17577
|
this.pendingSpanCount += spans.length;
|
|
17578
|
+
if (this.verbose) {
|
|
17579
|
+
sdkLog("info", `[glasstrace:diag] Buffering ${spans.length} spans (key pending, total: ${this.pendingSpanCount})`);
|
|
17580
|
+
}
|
|
17556
17581
|
while (this.pendingSpanCount > MAX_PENDING_SPANS && this.pendingBatches.length > 1) {
|
|
17557
17582
|
const evicted = this.pendingBatches.shift();
|
|
17558
17583
|
this.pendingSpanCount -= evicted.spans.length;
|
|
17559
17584
|
recordSpansDropped(evicted.spans.length);
|
|
17560
17585
|
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
|
+
}
|
|
17561
17589
|
if (!this.overflowLogged) {
|
|
17562
17590
|
this.overflowLogged = true;
|
|
17563
17591
|
console.warn(
|
|
@@ -17596,6 +17624,8 @@ var GlasstraceExporter = class {
|
|
|
17596
17624
|
exporter.export(enriched, (result) => {
|
|
17597
17625
|
if (result.code !== 0) {
|
|
17598
17626
|
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`);
|
|
17599
17629
|
}
|
|
17600
17630
|
batch.resultCallback(result);
|
|
17601
17631
|
});
|
|
@@ -20395,7 +20425,8 @@ async function configureOtel(config2, sessionManager) {
|
|
|
20395
20425
|
getConfig: () => getActiveConfig(),
|
|
20396
20426
|
environment: config2.environment,
|
|
20397
20427
|
endpointUrl: exporterUrl,
|
|
20398
|
-
createDelegate: createOtlpExporter
|
|
20428
|
+
createDelegate: createOtlpExporter,
|
|
20429
|
+
verbose: config2.verbose
|
|
20399
20430
|
});
|
|
20400
20431
|
_activeExporter = glasstraceExporter;
|
|
20401
20432
|
const vercelOtel = await tryImport("@vercel/otel");
|
|
@@ -20438,6 +20469,9 @@ async function configureOtel(config2, sessionManager) {
|
|
|
20438
20469
|
const processor = new BatchSpanProcessor(glasstraceExporter, {
|
|
20439
20470
|
scheduledDelayMillis: 1e3
|
|
20440
20471
|
});
|
|
20472
|
+
if (config2.verbose) {
|
|
20473
|
+
sdkLog("info", "[glasstrace:diag] BatchSpanProcessor configured: scheduledDelayMillis=1000");
|
|
20474
|
+
}
|
|
20441
20475
|
const provider = new BasicTracerProvider({
|
|
20442
20476
|
spanProcessors: [processor]
|
|
20443
20477
|
});
|
|
@@ -20705,8 +20739,8 @@ async function backgroundInit(config2, anonKeyForInit, generation) {
|
|
|
20705
20739
|
if (config2.verbose) {
|
|
20706
20740
|
console.info("[glasstrace] Background init firing.");
|
|
20707
20741
|
}
|
|
20708
|
-
const healthReport = collectHealthReport("0.12.
|
|
20709
|
-
const initResult = await performInit(config2, anonKeyForInit, "0.12.
|
|
20742
|
+
const healthReport = collectHealthReport("0.12.5");
|
|
20743
|
+
const initResult = await performInit(config2, anonKeyForInit, "0.12.5", healthReport);
|
|
20710
20744
|
if (generation !== registrationGeneration) return;
|
|
20711
20745
|
if (initResult?.claimResult) {
|
|
20712
20746
|
setResolvedApiKey(initResult.claimResult.newApiKey);
|
|
@@ -20714,7 +20748,7 @@ async function backgroundInit(config2, anonKeyForInit, generation) {
|
|
|
20714
20748
|
}
|
|
20715
20749
|
maybeInstallConsoleCapture();
|
|
20716
20750
|
if (didLastInitSucceed()) {
|
|
20717
|
-
startHeartbeat(config2, anonKeyForInit, "0.12.
|
|
20751
|
+
startHeartbeat(config2, anonKeyForInit, "0.12.5", generation, (newApiKey) => {
|
|
20718
20752
|
setResolvedApiKey(newApiKey);
|
|
20719
20753
|
notifyApiKeyResolved();
|
|
20720
20754
|
});
|