@mastra/spanner 1.6.4 → 1.6.5-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.js
CHANGED
|
@@ -9078,19 +9078,34 @@ var ObservabilitySpanner = class ObservabilitySpanner extends ObservabilityStora
|
|
|
9078
9078
|
}
|
|
9079
9079
|
}
|
|
9080
9080
|
async batchDeleteTraces(args) {
|
|
9081
|
+
this.assertUnscopedBatchDeleteTraces(args);
|
|
9081
9082
|
try {
|
|
9082
9083
|
if (args.traceIds.length === 0) return;
|
|
9083
|
-
const tableName = quoteIdent(TABLE_SPANS, "table name");
|
|
9084
9084
|
const params = {};
|
|
9085
9085
|
const placeholders = args.traceIds.map((id, i) => {
|
|
9086
9086
|
const name = `t${i}`;
|
|
9087
9087
|
params[name] = id;
|
|
9088
9088
|
return `@${name}`;
|
|
9089
9089
|
});
|
|
9090
|
-
|
|
9091
|
-
|
|
9092
|
-
|
|
9093
|
-
|
|
9090
|
+
const traceIdFilter = `${quoteIdent("traceId", "column name")} IN (${placeholders.join(", ")})`;
|
|
9091
|
+
await this.db.runWithAbortRetry(() => this.database.runTransactionAsync(async (tx) => {
|
|
9092
|
+
try {
|
|
9093
|
+
await tx.runUpdate({
|
|
9094
|
+
sql: `DELETE FROM ${quoteIdent(TABLE_SPANS, "table name")} WHERE ${traceIdFilter}`,
|
|
9095
|
+
params
|
|
9096
|
+
});
|
|
9097
|
+
if (!this.disableMetrics) await tx.runUpdate({
|
|
9098
|
+
sql: `DELETE FROM ${quoteIdent(TABLE_AI_METRICS, "table name")} WHERE ${traceIdFilter}`,
|
|
9099
|
+
params
|
|
9100
|
+
});
|
|
9101
|
+
await tx.commit();
|
|
9102
|
+
} catch (error) {
|
|
9103
|
+
await tx.rollback().catch((rollbackError) => {
|
|
9104
|
+
throw new AggregateError([error, rollbackError], "Transaction and rollback both failed");
|
|
9105
|
+
});
|
|
9106
|
+
throw error;
|
|
9107
|
+
}
|
|
9108
|
+
}));
|
|
9094
9109
|
} catch (error) {
|
|
9095
9110
|
throw new MastraError({
|
|
9096
9111
|
id: createStorageErrorId("SPANNER", "BATCH_DELETE_TRACES", "FAILED"),
|