@mastra/spanner 1.6.4-alpha.2 → 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.
@@ -3,7 +3,7 @@ name: mastra-spanner
3
3
  description: Documentation for @mastra/spanner. Use when working with @mastra/spanner APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/spanner"
6
- version: "1.6.4-alpha.2"
6
+ version: "1.6.5-alpha.0"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.6.4-alpha.2",
2
+ "version": "1.6.5-alpha.0",
3
3
  "package": "@mastra/spanner",
4
4
  "exports": {},
5
5
  "modules": {}
package/dist/index.cjs CHANGED
@@ -9079,19 +9079,34 @@ var ObservabilitySpanner = class ObservabilitySpanner extends _mastra_core_stora
9079
9079
  }
9080
9080
  }
9081
9081
  async batchDeleteTraces(args) {
9082
+ this.assertUnscopedBatchDeleteTraces(args);
9082
9083
  try {
9083
9084
  if (args.traceIds.length === 0) return;
9084
- const tableName = quoteIdent(_mastra_core_storage.TABLE_SPANS, "table name");
9085
9085
  const params = {};
9086
9086
  const placeholders = args.traceIds.map((id, i) => {
9087
9087
  const name = `t${i}`;
9088
9088
  params[name] = id;
9089
9089
  return `@${name}`;
9090
9090
  });
9091
- await this.db.runDml({
9092
- sql: `DELETE FROM ${tableName} WHERE ${quoteIdent("traceId", "column name")} IN (${placeholders.join(", ")})`,
9093
- params
9094
- });
9091
+ const traceIdFilter = `${quoteIdent("traceId", "column name")} IN (${placeholders.join(", ")})`;
9092
+ await this.db.runWithAbortRetry(() => this.database.runTransactionAsync(async (tx) => {
9093
+ try {
9094
+ await tx.runUpdate({
9095
+ sql: `DELETE FROM ${quoteIdent(_mastra_core_storage.TABLE_SPANS, "table name")} WHERE ${traceIdFilter}`,
9096
+ params
9097
+ });
9098
+ if (!this.disableMetrics) await tx.runUpdate({
9099
+ sql: `DELETE FROM ${quoteIdent(TABLE_AI_METRICS, "table name")} WHERE ${traceIdFilter}`,
9100
+ params
9101
+ });
9102
+ await tx.commit();
9103
+ } catch (error) {
9104
+ await tx.rollback().catch((rollbackError) => {
9105
+ throw new AggregateError([error, rollbackError], "Transaction and rollback both failed");
9106
+ });
9107
+ throw error;
9108
+ }
9109
+ }));
9095
9110
  } catch (error) {
9096
9111
  throw new _mastra_core_error.MastraError({
9097
9112
  id: (0, _mastra_core_storage.createStorageErrorId)("SPANNER", "BATCH_DELETE_TRACES", "FAILED"),