@mastra/observability 1.18.2 → 1.18.3-alpha.0
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 +32 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +32 -3
- package/dist/index.js.map +1 -1
- package/dist/metrics/pricing-data.jsonl +1269 -613
- package/dist/recorded.d.ts.map +1 -1
- package/dist/spans/default.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -3223,6 +3223,30 @@ var BaseSpan = class BaseSpan {
|
|
|
3223
3223
|
};
|
|
3224
3224
|
//#endregion
|
|
3225
3225
|
//#region src/spans/default.ts
|
|
3226
|
+
/** Every AI SDK `APICallError` (v4, v5 and v6) carries this shared marker symbol. */
|
|
3227
|
+
const API_CALL_ERROR_MARKER = Symbol.for("vercel.ai.error.AI_APICallError");
|
|
3228
|
+
function isApiCallError(value) {
|
|
3229
|
+
return typeof value === "object" && value !== null && value[API_CALL_ERROR_MARKER] === true;
|
|
3230
|
+
}
|
|
3231
|
+
/**
|
|
3232
|
+
* HTTP facts of a provider call failure, read from an AI SDK `APICallError` or
|
|
3233
|
+
* from the one a wrapper (MastraError, durable transport) carries as `cause`.
|
|
3234
|
+
* Without them a span only says "Service Unavailable", with no status or URL.
|
|
3235
|
+
*/
|
|
3236
|
+
function apiCallErrorDetails(error) {
|
|
3237
|
+
const apiError = isApiCallError(error) ? error : isApiCallError(error.cause) ? error.cause : void 0;
|
|
3238
|
+
if (!apiError) return void 0;
|
|
3239
|
+
const details = {};
|
|
3240
|
+
if (apiError.statusCode !== void 0) details.statusCode = apiError.statusCode;
|
|
3241
|
+
if (apiError.url !== void 0) details.url = apiError.url.split("?")[0];
|
|
3242
|
+
if (apiError.isRetryable !== void 0) details.isRetryable = apiError.isRetryable;
|
|
3243
|
+
if (apiError.responseBody !== void 0) try {
|
|
3244
|
+
details.responseBody = JSON.parse(apiError.responseBody);
|
|
3245
|
+
} catch {
|
|
3246
|
+
details.responseBody = apiError.responseBody;
|
|
3247
|
+
}
|
|
3248
|
+
return details;
|
|
3249
|
+
}
|
|
3226
3250
|
var DefaultSpan = class extends BaseSpan {
|
|
3227
3251
|
id;
|
|
3228
3252
|
traceId;
|
|
@@ -3284,9 +3308,13 @@ var DefaultSpan = class extends BaseSpan {
|
|
|
3284
3308
|
...deepClean(this.prepareSpanMetadata(metadata), this.deepCleanOptions)
|
|
3285
3309
|
};
|
|
3286
3310
|
if (!this.isExcluded) {
|
|
3311
|
+
const apiDetails = apiCallErrorDetails(error);
|
|
3287
3312
|
this.errorInfo = deepClean(error instanceof MastraError ? {
|
|
3288
3313
|
id: error.id,
|
|
3289
|
-
details:
|
|
3314
|
+
details: apiDetails ? {
|
|
3315
|
+
...error.details,
|
|
3316
|
+
...apiDetails
|
|
3317
|
+
} : error.details,
|
|
3290
3318
|
category: error.category,
|
|
3291
3319
|
domain: error.domain,
|
|
3292
3320
|
message: error.message,
|
|
@@ -3295,7 +3323,8 @@ var DefaultSpan = class extends BaseSpan {
|
|
|
3295
3323
|
} : {
|
|
3296
3324
|
message: error.message,
|
|
3297
3325
|
name: error.name,
|
|
3298
|
-
stack: error.stack
|
|
3326
|
+
stack: error.stack,
|
|
3327
|
+
...apiDetails && { details: apiDetails }
|
|
3299
3328
|
}, this.deepCleanOptions);
|
|
3300
3329
|
if (attributes) this.attributes = {
|
|
3301
3330
|
...this.attributes,
|
|
@@ -9119,7 +9148,7 @@ var RecordedTraceImpl = class {
|
|
|
9119
9148
|
};
|
|
9120
9149
|
function findRootSpan(spans) {
|
|
9121
9150
|
const spanIds = new Set(spans.map((span) => span.spanId));
|
|
9122
|
-
return spans.find((span) => !span.parentSpanId
|
|
9151
|
+
return spans.find((span) => !span.parentSpanId) ?? spans.find((span) => !spanIds.has(span.parentSpanId)) ?? spans[0];
|
|
9123
9152
|
}
|
|
9124
9153
|
function hydrateRecordedTrace(args) {
|
|
9125
9154
|
const { trace, emitRecordedEvent, canEmitRecordedEvent = () => true, debugRecordedAnnotationUnavailable = () => {} } = args;
|