{"record":{"id":"67aca62f8a444a1e","repo":"mastra-ai/mastra","slug":"observability-storage-batch-create-span-not-implem","errorCode":"OBSERVABILITY_STORAGE_BATCH_CREATE_SPAN_NOT_IMPLEMENTED","errorMessage":"This storage provider does not support batch creating spans","messagePattern":"This storage provider does not support batch creating spans","errorType":"error_code","errorClass":"MastraError","httpStatus":null,"severity":"error","filePath":"packages/core/src/storage/domains/observability/base.ts","lineNumber":364,"sourceCode":"   * returns one row per root-rooted trace), each row here is a single branch\n   * anchor span, including ones nested under a different root entity -- useful\n   * for \"show me every run of agent X\" regardless of caller. Pairs with\n   * {@link getBranch} to expand a single branch into its subtree.\n   */\n  async listBranches(_args: ListBranchesArgs): Promise<ListBranchesResponse> {\n    throw new MastraError({\n      id: 'OBSERVABILITY_STORAGE_LIST_BRANCHES_NOT_IMPLEMENTED',\n      domain: ErrorDomain.MASTRA_OBSERVABILITY,\n      category: ErrorCategory.SYSTEM,\n      text: 'This storage provider does not support listing trace branches',\n    });\n  }\n\n  /**\n   * Creates multiple Spans in a single batch.\n   */\n  async batchCreateSpans(_args: BatchCreateSpansArgs): Promise<void> {\n    throw new MastraError({\n      id: 'OBSERVABILITY_STORAGE_BATCH_CREATE_SPAN_NOT_IMPLEMENTED',\n      domain: ErrorDomain.MASTRA_OBSERVABILITY,\n      category: ErrorCategory.SYSTEM,\n      text: 'This storage provider does not support batch creating spans',\n    });\n  }\n\n  /**\n   * Updates multiple Spans in a single batch.\n   */\n  async batchUpdateSpans(_args: BatchUpdateSpansArgs): Promise<void> {\n    throw new MastraError({\n      id: 'OBSERVABILITY_STORAGE_BATCH_UPDATE_SPANS_NOT_IMPLEMENTED',\n      domain: ErrorDomain.MASTRA_OBSERVABILITY,\n      category: ErrorCategory.SYSTEM,\n      text: 'This storage provider does not support batch updating spans',\n    });\n  }","sourceCodeStart":346,"sourceCodeEnd":382,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/storage/domains/observability/base.ts#L346-L382","documentation":"batchCreateSpans() inserts multiple spans in a single write. The ObservabilityStorage base class default throws, so this error means the configured storage adapter has no batch span-write implementation. Note this differs from single-span export: an adapter may support exportSpan but not the batched API.","triggerScenarios":"Calling storage.getObservability().batchCreateSpans({ spans }) — e.g. a flushing observability exporter that buffers spans and writes them in bulk — against an adapter that kept the base default.","commonSituations":"Observability exporters configured with batching enabled pointing at a storage backend without bulk inserts; custom adapters that only implement per-span export; high-throughput setups that assume batch writes for performance.","solutions":["Use a storage adapter that overrides batchCreateSpans (most SQL-backed adapters do).","In your exporter/processor, loop over spans and call the single-span create/export API per span.","Implement batchCreateSpans() in your custom adapter (bulk INSERT).","If persistence isn't required, export spans to an OTLP/telemetry endpoint instead of Mastra storage."],"exampleFix":"// before\nawait observability.batchCreateSpans({ spans: buffer });\n\n// after (fallback)\nfor (const span of buffer) {\n  await observability.exportSpan(span);\n}","handlingStrategy":"fallback","validationCode":"const supportsBatchCreate = obs.batchCreateSpans !== ObservabilityStorage.prototype.batchCreateSpans;","typeGuard":"function supportsBatchCreateSpans(o: { batchCreateSpans: unknown }): boolean {\n  return o.batchCreateSpans !== (ObservabilityStorage.prototype as any).batchCreateSpans;\n}","tryCatchPattern":"try {\n  await obs.batchCreateSpans({ spans: buffer });\n} catch (e) {\n  if ((e as MastraError).id === 'OBSERVABILITY_STORAGE_BATCH_CREATE_SPAN_NOT_IMPLEMENTED') {\n    await Promise.all(buffer.map(s => obs.exportSpan(s)));\n  } else throw e;\n}","preventionTips":["Detect batch support in the exporter and choose bulk vs per-span writes once at startup.","Implement batchCreateSpans with a bulk INSERT in custom adapters for performance.","Cover the batch-write path in adapter integration tests."],"tags":["storage","observability","tracing","batch","unsupported-operation"],"backgroundTag":"storage-provider-not-implemented","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}