@glasstrace/sdk 0.13.5 → 0.13.6
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 +53 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +53 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -17498,6 +17498,7 @@ var GlasstraceExporter = class {
|
|
|
17498
17498
|
environment;
|
|
17499
17499
|
endpointUrl;
|
|
17500
17500
|
createDelegateFn;
|
|
17501
|
+
verbose;
|
|
17501
17502
|
delegate = null;
|
|
17502
17503
|
delegateKey = null;
|
|
17503
17504
|
pendingBatches = [];
|
|
@@ -17510,6 +17511,7 @@ var GlasstraceExporter = class {
|
|
|
17510
17511
|
this.environment = options.environment;
|
|
17511
17512
|
this.endpointUrl = options.endpointUrl;
|
|
17512
17513
|
this.createDelegateFn = options.createDelegate;
|
|
17514
|
+
this.verbose = options.verbose ?? false;
|
|
17513
17515
|
}
|
|
17514
17516
|
export(spans, resultCallback) {
|
|
17515
17517
|
const currentKey = this.getApiKey();
|
|
@@ -17615,7 +17617,17 @@ var GlasstraceExporter = class {
|
|
|
17615
17617
|
if (statusCode !== void 0) {
|
|
17616
17618
|
extra[ATTR.HTTP_STATUS_CODE] = statusCode;
|
|
17617
17619
|
}
|
|
17618
|
-
|
|
17620
|
+
const isErrorByStatus = span.status?.code === SpanStatusCode.ERROR;
|
|
17621
|
+
const isErrorByEvent = hasExceptionEvent(span);
|
|
17622
|
+
const isErrorByAttrs = typeof attrs["exception.type"] === "string" || typeof attrs["exception.message"] === "string";
|
|
17623
|
+
const statusNotExplicitlyOK = span.status?.code !== SpanStatusCode.OK;
|
|
17624
|
+
if (this.verbose && method) {
|
|
17625
|
+
sdkLog(
|
|
17626
|
+
"info",
|
|
17627
|
+
`[glasstrace] enrichSpan "${name}": status.code=${span.status?.code}, http.status_code=${statusCode}, isErrorByStatus=${isErrorByStatus}, isErrorByEvent=${isErrorByEvent}, isErrorByAttrs=${isErrorByAttrs}`
|
|
17628
|
+
);
|
|
17629
|
+
}
|
|
17630
|
+
if (method && statusNotExplicitlyOK && (isErrorByStatus || isErrorByEvent || isErrorByAttrs)) {
|
|
17619
17631
|
if (statusCode === void 0 || statusCode === 0 || statusCode === 200) {
|
|
17620
17632
|
const httpErrorType = attrs["error.type"];
|
|
17621
17633
|
if (typeof httpErrorType === "string") {
|
|
@@ -17628,6 +17640,12 @@ var GlasstraceExporter = class {
|
|
|
17628
17640
|
} else {
|
|
17629
17641
|
extra[ATTR.HTTP_STATUS_CODE] = 500;
|
|
17630
17642
|
}
|
|
17643
|
+
if (this.verbose) {
|
|
17644
|
+
sdkLog(
|
|
17645
|
+
"info",
|
|
17646
|
+
`[glasstrace] enrichSpan "${name}": inferred status_code=${extra[ATTR.HTTP_STATUS_CODE]} (was ${statusCode}), error.type=${attrs["error.type"]}`
|
|
17647
|
+
);
|
|
17648
|
+
}
|
|
17631
17649
|
}
|
|
17632
17650
|
}
|
|
17633
17651
|
if (span.startTime && span.endTime) {
|
|
@@ -17638,14 +17656,28 @@ var GlasstraceExporter = class {
|
|
|
17638
17656
|
extra[ATTR.HTTP_DURATION_MS] = durationMs;
|
|
17639
17657
|
}
|
|
17640
17658
|
}
|
|
17659
|
+
const eventDetails = statusNotExplicitlyOK ? getExceptionEventDetails(span) : { type: void 0, message: void 0 };
|
|
17641
17660
|
const errorMessage = attrs["exception.message"];
|
|
17642
17661
|
if (typeof errorMessage === "string") {
|
|
17643
17662
|
extra[ATTR.ERROR_MESSAGE] = errorMessage;
|
|
17663
|
+
} else if (eventDetails.message) {
|
|
17664
|
+
extra[ATTR.ERROR_MESSAGE] = eventDetails.message;
|
|
17644
17665
|
}
|
|
17645
17666
|
const errorType = attrs["exception.type"];
|
|
17646
17667
|
if (typeof errorType === "string") {
|
|
17647
17668
|
extra[ATTR.ERROR_CODE] = errorType;
|
|
17648
17669
|
extra[ATTR.ERROR_CATEGORY] = deriveErrorCategory(errorType);
|
|
17670
|
+
} else if (eventDetails.type) {
|
|
17671
|
+
extra[ATTR.ERROR_CODE] = eventDetails.type;
|
|
17672
|
+
extra[ATTR.ERROR_CATEGORY] = deriveErrorCategory(eventDetails.type);
|
|
17673
|
+
}
|
|
17674
|
+
if (this.verbose && (extra[ATTR.ERROR_MESSAGE] || extra[ATTR.ERROR_CODE])) {
|
|
17675
|
+
const msgSource = typeof errorMessage === "string" ? "attrs" : eventDetails.message ? "event" : "none";
|
|
17676
|
+
const typeSource = typeof errorType === "string" ? "attrs" : eventDetails.type ? "event" : "none";
|
|
17677
|
+
sdkLog(
|
|
17678
|
+
"info",
|
|
17679
|
+
`[glasstrace] enrichSpan "${name}": error.message source=${msgSource}, error.code source=${typeSource}`
|
|
17680
|
+
);
|
|
17649
17681
|
}
|
|
17650
17682
|
const errorField = attrs["error.field"];
|
|
17651
17683
|
if (typeof errorField === "string") {
|
|
@@ -17768,6 +17800,21 @@ function createEnrichedSpan(span, extra) {
|
|
|
17768
17800
|
}
|
|
17769
17801
|
});
|
|
17770
17802
|
}
|
|
17803
|
+
function hasExceptionEvent(span) {
|
|
17804
|
+
return span.events?.some((e) => e.name === "exception") ?? false;
|
|
17805
|
+
}
|
|
17806
|
+
function getExceptionEventDetails(span) {
|
|
17807
|
+
const event = span.events?.find((e) => e.name === "exception");
|
|
17808
|
+
if (!event?.attributes) {
|
|
17809
|
+
return { type: void 0, message: void 0 };
|
|
17810
|
+
}
|
|
17811
|
+
const type = event.attributes["exception.type"];
|
|
17812
|
+
const message = event.attributes["exception.message"];
|
|
17813
|
+
return {
|
|
17814
|
+
type: typeof type === "string" ? type : void 0,
|
|
17815
|
+
message: typeof message === "string" ? message : void 0
|
|
17816
|
+
};
|
|
17817
|
+
}
|
|
17771
17818
|
function deriveOrmProvider(instrumentationName) {
|
|
17772
17819
|
const lower = instrumentationName.toLowerCase();
|
|
17773
17820
|
if (lower.includes("prisma")) {
|
|
@@ -20692,7 +20739,8 @@ async function configureOtel(config2, sessionManager) {
|
|
|
20692
20739
|
getConfig: () => getActiveConfig(),
|
|
20693
20740
|
environment: config2.environment,
|
|
20694
20741
|
endpointUrl: exporterUrl,
|
|
20695
|
-
createDelegate: createOtlpExporter
|
|
20742
|
+
createDelegate: createOtlpExporter,
|
|
20743
|
+
verbose: config2.verbose
|
|
20696
20744
|
});
|
|
20697
20745
|
_activeExporter = glasstraceExporter;
|
|
20698
20746
|
const vercelOtel = await tryImport("@vercel/otel");
|
|
@@ -21050,8 +21098,8 @@ async function backgroundInit(config2, anonKeyForInit, generation) {
|
|
|
21050
21098
|
if (config2.verbose) {
|
|
21051
21099
|
console.info("[glasstrace] Background init firing.");
|
|
21052
21100
|
}
|
|
21053
|
-
const healthReport = collectHealthReport("0.13.
|
|
21054
|
-
const initResult = await performInit(config2, anonKeyForInit, "0.13.
|
|
21101
|
+
const healthReport = collectHealthReport("0.13.6");
|
|
21102
|
+
const initResult = await performInit(config2, anonKeyForInit, "0.13.6", healthReport);
|
|
21055
21103
|
if (generation !== registrationGeneration) return;
|
|
21056
21104
|
if (initResult?.claimResult) {
|
|
21057
21105
|
setResolvedApiKey(initResult.claimResult.newApiKey);
|
|
@@ -21059,7 +21107,7 @@ async function backgroundInit(config2, anonKeyForInit, generation) {
|
|
|
21059
21107
|
}
|
|
21060
21108
|
maybeInstallConsoleCapture();
|
|
21061
21109
|
if (didLastInitSucceed()) {
|
|
21062
|
-
startHeartbeat(config2, anonKeyForInit, "0.13.
|
|
21110
|
+
startHeartbeat(config2, anonKeyForInit, "0.13.6", generation, (newApiKey) => {
|
|
21063
21111
|
setResolvedApiKey(newApiKey);
|
|
21064
21112
|
notifyApiKeyResolved();
|
|
21065
21113
|
});
|