@mastra/observability 1.23.2-alpha.1 → 1.24.0-alpha.2

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-observability
3
3
  description: Documentation for @mastra/observability. Use when working with @mastra/observability APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/observability"
6
- version: "1.23.2-alpha.1"
6
+ version: "1.24.0-alpha.2"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.23.2-alpha.1",
2
+ "version": "1.24.0-alpha.2",
3
3
  "package": "@mastra/observability",
4
4
  "exports": {
5
5
  "BaseExporter": {
@@ -15,7 +15,7 @@
15
15
  "BaseObservabilityInstance": {
16
16
  "types": "dist/instances/base.d.ts",
17
17
  "implementation": "dist/index.js",
18
- "line": 5399
18
+ "line": 5602
19
19
  },
20
20
  "BaseSpan": {
21
21
  "types": "dist/spans/base.d.ts",
@@ -30,12 +30,12 @@
30
30
  "CloudExporter": {
31
31
  "types": "dist/exporters/cloud.d.ts",
32
32
  "implementation": "dist/index.js",
33
- "line": 7804
33
+ "line": 8007
34
34
  },
35
35
  "ConsoleExporter": {
36
36
  "types": "dist/exporters/console.d.ts",
37
37
  "implementation": "dist/index.js",
38
- "line": 8127
38
+ "line": 8330
39
39
  },
40
40
  "DEFAULT_DEEP_CLEAN_OPTIONS": {
41
41
  "types": "dist/spans/serialization.d.ts",
@@ -45,17 +45,17 @@
45
45
  "DEFAULT_LIMITS": {
46
46
  "types": "dist/client/proxy.d.ts",
47
47
  "implementation": "dist/index.js",
48
- "line": 6370
48
+ "line": 6573
49
49
  },
50
50
  "DefaultExporter": {
51
51
  "types": "dist/exporters/default.d.ts",
52
52
  "implementation": "dist/index.js",
53
- "line": 4472
53
+ "line": 4529
54
54
  },
55
55
  "DefaultObservabilityInstance": {
56
56
  "types": "dist/instances/default.d.ts",
57
57
  "implementation": "dist/index.js",
58
- "line": 9771
58
+ "line": 10157
59
59
  },
60
60
  "DefaultSpan": {
61
61
  "types": "dist/spans/default.d.ts",
@@ -65,7 +65,7 @@
65
65
  "JsonExporter": {
66
66
  "types": "dist/exporters/test.d.ts",
67
67
  "implementation": "dist/index.js",
68
- "line": 9769
68
+ "line": 10155
69
69
  },
70
70
  "LoggerContextImpl": {
71
71
  "types": "dist/context/logger.d.ts",
@@ -75,12 +75,12 @@
75
75
  "MastraPlatformExporter": {
76
76
  "types": "dist/exporters/mastra-platform.d.ts",
77
77
  "implementation": "dist/index.js",
78
- "line": 8301
78
+ "line": 8625
79
79
  },
80
80
  "MastraStorageExporter": {
81
81
  "types": "dist/exporters/mastra-storage.d.ts",
82
82
  "implementation": "dist/index.js",
83
- "line": 4920
83
+ "line": 5038
84
84
  },
85
85
  "MetricsContextImpl": {
86
86
  "types": "dist/context/metrics.d.ts",
@@ -100,12 +100,12 @@
100
100
  "OBSERVABILITY_CAPABILITIES_HEADER": {
101
101
  "types": "dist/exporters/mastra-platform.d.ts",
102
102
  "implementation": "dist/index.js",
103
- "line": 8202
103
+ "line": 8526
104
104
  },
105
105
  "Observability": {
106
106
  "types": "dist/default.d.ts",
107
107
  "implementation": "dist/index.js",
108
- "line": 10428
108
+ "line": 10814
109
109
  },
110
110
  "ObservabilityBus": {
111
111
  "types": "dist/bus/observability-bus.d.ts",
@@ -115,7 +115,7 @@
115
115
  "QUOTA_PAUSE_CAPABILITY": {
116
116
  "types": "dist/exporters/mastra-platform.d.ts",
117
117
  "implementation": "dist/index.js",
118
- "line": 8203
118
+ "line": 8527
119
119
  },
120
120
  "SamplingStrategyType": {
121
121
  "types": "dist/config.d.ts",
@@ -125,57 +125,57 @@
125
125
  "SensitiveDataFilter": {
126
126
  "types": "dist/span_processors/sensitive-data-filter.d.ts",
127
127
  "implementation": "dist/index.js",
128
- "line": 10198
128
+ "line": 10584
129
129
  },
130
130
  "TestExporter": {
131
131
  "types": "dist/exporters/test.d.ts",
132
132
  "implementation": "dist/index.js",
133
- "line": 8784
133
+ "line": 9170
134
134
  },
135
135
  "TraceData": {
136
136
  "types": "dist/exporters/tracking.d.ts",
137
137
  "implementation": "dist/index.js",
138
- "line": 6523
138
+ "line": 6726
139
139
  },
140
140
  "TrackingExporter": {
141
141
  "types": "dist/exporters/tracking.d.ts",
142
142
  "implementation": "dist/index.js",
143
- "line": 6852
143
+ "line": 7055
144
144
  },
145
145
  "buildExportedLog": {
146
146
  "types": "dist/client/otlp.d.ts",
147
147
  "implementation": "dist/index.js",
148
- "line": 6287
148
+ "line": 6490
149
149
  },
150
150
  "buildExportedSpan": {
151
151
  "types": "dist/client/otlp.d.ts",
152
152
  "implementation": "dist/index.js",
153
- "line": 6269
153
+ "line": 6472
154
154
  },
155
155
  "buildTracingOptions": {
156
156
  "types": "dist/tracing-options.d.ts",
157
157
  "implementation": "dist/index.js",
158
- "line": 10773
158
+ "line": 11159
159
159
  },
160
160
  "chainFormatters": {
161
161
  "types": "dist/exporters/span-formatters.d.ts",
162
162
  "implementation": "dist/index.js",
163
- "line": 7618
163
+ "line": 7821
164
164
  },
165
165
  "createClientObservabilityProxy": {
166
166
  "types": "dist/client/proxy.d.ts",
167
167
  "implementation": "dist/index.js",
168
- "line": 6504
168
+ "line": 6707
169
169
  },
170
170
  "decodeResourceLogs": {
171
171
  "types": "dist/client/otlp.d.ts",
172
172
  "implementation": "dist/index.js",
173
- "line": 6206
173
+ "line": 6409
174
174
  },
175
175
  "decodeResourceSpans": {
176
176
  "types": "dist/client/otlp.d.ts",
177
177
  "implementation": "dist/index.js",
178
- "line": 6169
178
+ "line": 6372
179
179
  },
180
180
  "deepClean": {
181
181
  "types": "dist/spans/serialization.d.ts",
@@ -185,12 +185,12 @@
185
185
  "formatBaggage": {
186
186
  "types": "dist/client/w3c.d.ts",
187
187
  "implementation": "dist/index.js",
188
- "line": 6360
188
+ "line": 6563
189
189
  },
190
190
  "formatTraceparent": {
191
191
  "types": "dist/client/w3c.d.ts",
192
192
  "implementation": "dist/index.js",
193
- "line": 6323
193
+ "line": 6526
194
194
  },
195
195
  "getExternalParentId": {
196
196
  "types": "dist/spans/base.d.ts",
@@ -215,7 +215,7 @@
215
215
  "observabilityFeatures": {
216
216
  "types": "dist/features.d.ts",
217
217
  "implementation": "dist/index.js",
218
- "line": 10754
218
+ "line": 11140
219
219
  },
220
220
  "observabilityInstanceConfigSchema": {
221
221
  "types": "dist/config.d.ts",
@@ -230,17 +230,17 @@
230
230
  "otlpSeverityToLogLevel": {
231
231
  "types": "dist/client/otlp.d.ts",
232
232
  "implementation": "dist/index.js",
233
- "line": 6243
233
+ "line": 6446
234
234
  },
235
235
  "parseBaggage": {
236
236
  "types": "dist/client/w3c.d.ts",
237
237
  "implementation": "dist/index.js",
238
- "line": 6333
238
+ "line": 6536
239
239
  },
240
240
  "parseTraceparent": {
241
241
  "types": "dist/client/w3c.d.ts",
242
242
  "implementation": "dist/index.js",
243
- "line": 6309
243
+ "line": 6512
244
244
  },
245
245
  "reconstructSerializedMap": {
246
246
  "types": "dist/spans/serialization.d.ts",
@@ -6,7 +6,7 @@
6
6
 
7
7
  [Arize AI](https://arize.com/?utm_source=mastra-docs\&utm_medium=partner\&utm_campaign=partner-docs\&utm_content=observability-arize) provides observability and evaluation for AI applications through [Arize Phoenix](https://arize.com/phoenix/) and [Arize AX](https://arize.com/products/ax/). Use Phoenix for a local or self-hosted open-source workflow, and use Arize AX for managed cloud or enterprise self-hosted production observability. The Arize exporter sends traces using OpenTelemetry and [OpenInference](https://github.com/Arize-ai/openinference/tree/main/spec) semantic conventions, compatible with any OpenTelemetry platform that supports OpenInference.
8
8
 
9
- For workflows that use traces to improve quality, see Arize's [agent evaluation guide](https://arize.com/guides/ai-agent-handbook/agent-evaluation/) and [LLM evaluation guide](https://arize.com/resources/llm-evaluation/).
9
+ For workflows that use traces to improve quality, see Arize's [agent evaluation guide](https://arize.com/ai-agents/agent-evaluation/) and [LLM evaluation guide](https://arize.com/resources/llm-evaluation/).
10
10
 
11
11
  ## Installation
12
12
 
@@ -30,6 +30,13 @@ interface MastraPlatformExporterConfig extends BaseExporterConfig {
30
30
  /** Maximum wait time before flushing in milliseconds. Default: 5000 */
31
31
  maxBatchWaitMs?: number
32
32
 
33
+ /** Opt into byte-triggered batches and upload concurrency control */
34
+ byteBatching?: {
35
+ maxBatchBytes?: number // Default: 8 MiB
36
+ maxConcurrentUploads?: number // Default: 2
37
+ uploadTimeoutMs?: number // Default: 30000
38
+ }
39
+
33
40
  /** Maximum retry attempts. Default: 3 */
34
41
  maxRetries?: number
35
42
 
@@ -186,6 +193,32 @@ The exporter batches tracing spans, logs, metrics, scores, and feedback for effi
186
193
  - Flushes when `maxBatchWaitMs` elapsed since the first buffered signal in the batch
187
194
  - Flushes on `shutdown()`
188
195
 
196
+ ### Byte batching
197
+
198
+ Set `byteBatching` to flush by serialized byte size and control concurrent uploads:
199
+
200
+ ```typescript
201
+ import { MastraPlatformExporter } from '@mastra/observability'
202
+
203
+ const exporter = new MastraPlatformExporter({
204
+ byteBatching: {
205
+ maxBatchBytes: 8 * 1024 * 1024,
206
+ maxConcurrentUploads: 2,
207
+ uploadTimeoutMs: 30_000,
208
+ },
209
+ })
210
+ ```
211
+
212
+ Without `byteBatching`, the exporter keeps its existing count-based batching behavior.
213
+
214
+ - `maxBatchBytes` triggers an upload when a batch reaches 8 MiB by default. Larger records are sent intact, without truncation or size-based drops.
215
+ - `maxConcurrentUploads` controls concurrent uploads across all signal types. The default is two.
216
+ - `uploadTimeoutMs` sets the upload deadline, including retries. The default is 30 seconds.
217
+
218
+ Record-count and timer-based flush triggers still apply. Queued records are retained when uploads fall behind, so queue memory can grow.
219
+
220
+ Inspect the current queue with `exporter.getByteBatchingStats()`.
221
+
189
222
  ### Error handling
190
223
 
191
224
  - Uses exponential backoff retry with `maxRetries` attempts
@@ -22,6 +22,12 @@ new MastraStorageExporter(config?: MastraStorageExporterConfig)
22
22
 
23
23
  ```typescript
24
24
  interface MastraStorageExporterConfig extends BaseExporterConfig {
25
+ /** Opt-in byte flush thresholds. Omit to keep count-based batching. */
26
+ byteBatching?: {
27
+ maxBatchBytes?: number // Default: 8 MiB
28
+ maxConcurrentWrites?: number // Default: 1
29
+ }
30
+
25
31
  /** Maximum number of spans per batch. Default: 1000 */
26
32
  maxBatchSize?: number
27
33
 
@@ -47,6 +53,26 @@ Extends `BaseExporterConfig`, which includes:
47
53
  - `logger?: IMastraLogger` - Logger instance
48
54
  - `logLevel?: LogLevel | 'debug' | 'info' | 'warn' | 'error'` - Log level (default: INFO)
49
55
 
56
+ ## Byte batching
57
+
58
+ Enable byte batching with `byteBatching: {}` or supply custom thresholds. The exporter ignores byte batching when the resolved strategy is `realtime`, which keeps its immediate, awaited writes:
59
+
60
+ ```typescript
61
+ new MastraStorageExporter({
62
+ byteBatching: {
63
+ maxBatchBytes: 8 * 1024 * 1024,
64
+ maxConcurrentWrites: 1,
65
+ },
66
+ })
67
+ ```
68
+
69
+ - `maxBatchBytes` triggers a write when buffered events reach 8 MiB by default. Larger records are sent intact, without truncation or size-based drops.
70
+ - `maxConcurrentWrites` controls concurrent storage writes. The default is one. Update-based tracing strategies always use one write at a time to preserve span ordering.
71
+
72
+ Record-count and timer-based flush triggers still apply. Queued records are retained when storage falls behind, so queue memory can grow. Without `byteBatching`, the exporter keeps its existing count-based batching behavior.
73
+
74
+ Inspect the current queue with `exporter.getByteBatchingStats()`.
75
+
50
76
  ## `TracingStorageStrategy`
51
77
 
52
78
  ```typescript
@@ -1,5 +1,6 @@
1
1
  import type { AnyExportedSpan, ObservabilityEvent } from '@mastra/core/observability';
2
2
  import type { CreateSpanRecord, ObservabilityStorageStrategy, UpdateSpanRecord } from '@mastra/core/storage';
3
+ import type { StorageByteTracker } from './storage-byte-tracker.js';
3
4
  /** Mixin interface that tracks how many times a buffered event has been retried. */
4
5
  export interface RetryCount {
5
6
  retryCount: number;
@@ -21,6 +22,7 @@ export declare class EventBuffer {
21
22
  #private;
22
23
  constructor(args: {
23
24
  maxRetries: number;
25
+ byteTracker?: StorageByteTracker;
24
26
  });
25
27
  /** Initialize with a storage strategy and replay any pre-init events. */
26
28
  init(args: {
@@ -37,6 +39,13 @@ export declare class EventBuffer {
37
39
  reAddCreates(events: BufferedEvent[]): BufferedEvent[];
38
40
  /** Re-add failed update events to the buffer, returning events that exceed max retries. */
39
41
  reAddUpdates(events: BufferedEvent[]): BufferedEvent[];
42
+ /** Alternate creates and eligible updates so either queue can make progress under load. */
43
+ takeByteBatch(maxRecords: number): {
44
+ creates: BufferedEvent[];
45
+ updates: BufferedEvent[];
46
+ };
47
+ /** Retries/deferred updates remain reserved; everything else has finished or been dropped. */
48
+ releaseByteBatch(events: BufferedEvent[]): void;
40
49
  /** Snapshot of buffered create events. */
41
50
  get creates(): BufferedEvent[];
42
51
  /** Snapshot of buffered update events. */
@@ -1 +1 @@
1
- {"version":3,"file":"event-buffer.d.ts","sourceRoot":"","sources":["../../src/exporters/event-buffer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACtF,OAAO,KAAK,EAAE,gBAAgB,EAAE,4BAA4B,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE7G,oFAAoF;AACpF,MAAM,WAAW,UAAU;IACzB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,+DAA+D;AAC/D,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;CACpC;AAED,2EAA2E;AAC3E,MAAM,MAAM,aAAa,GAAG,kBAAkB,GAAG,UAAU,CAAC;AAE5D;;;;GAIG;AACH,qBAAa,WAAW;;IAWtB,YAAY,IAAI,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,EAEvC;IAED,yEAAyE;IACzE,IAAI,CAAC,IAAI,EAAE;QAAE,QAAQ,EAAE,4BAA4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M,EAAE,aAAa,EAAE,GAAG,IAAI,CAW9C;IAED,0CAA0C;IAC1C,IAAI,OAAO,IAAI,aAAa,EAAE,CAE7B;IAED,0CAA0C;IAC1C,IAAI,OAAO,IAAI,aAAa,EAAE,CAE7B;IAED,2DAA2D;IAC3D,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,4EAA4E;IAC5E,IAAI,OAAO,IAAI,MAAM,CAKpB;IAED;;OAEG;IACH,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,eAAe;IAIvB,6FAA6F;IAC7F,eAAe,CAAC,IAAI,EAAE;QAAE,OAAO,EAAE,gBAAgB,EAAE,CAAA;KAAE,GAAG,IAAI,CAc3D;IAED,6FAA6F;IAC7F,oBAAoB,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,IAAI,CAMlD;IAED,gFAAgF;IAChF,UAAU,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAEzC;IAED,sGAAsG;IACtG,gBAAgB,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAE/C;IAED,uFAAuF;IACvF,gBAAgB,CAAC,IAAI,EAAE;QAAE,OAAO,EAAE,iBAAiB,EAAE,CAAA;KAAE,GAAG,IAAI,CAU7D;CACF"}
@@ -1,10 +1,14 @@
1
1
  import type { TracingEvent, LogEvent, MetricEvent, ScoreEvent, FeedbackEvent } from '@mastra/core/observability';
2
2
  import { BaseExporter } from './base.js';
3
3
  import type { BaseExporterConfig } from './base.js';
4
+ import type { PlatformByteBatchingConfig, PlatformByteBatchingStats } from './platform-byte-batcher.js';
5
+ export type { PlatformByteBatchingConfig, PlatformByteBatchingStats } from './platform-byte-batcher.js';
4
6
  export interface MastraPlatformExporterConfig extends BaseExporterConfig {
5
7
  maxBatchSize?: number;
6
8
  maxBatchWaitMs?: number;
7
9
  maxRetries?: number;
10
+ /** Opt into UTF-8 JSON byte flush thresholds and upload concurrency control. */
11
+ byteBatching?: PlatformByteBatchingConfig;
8
12
  accessToken?: string;
9
13
  projectId?: string;
10
14
  /**
@@ -37,6 +41,8 @@ export declare class MastraPlatformExporter extends BaseExporter {
37
41
  private quotaProbeTimer;
38
42
  private quotaProbeIntervalSeconds;
39
43
  private shuttingDown;
44
+ private byteBatcher?;
45
+ private byteUploadTimeoutMs?;
40
46
  constructor(config?: MastraPlatformExporterConfig);
41
47
  protected _exportTracingEvent(event: TracingEvent): Promise<void>;
42
48
  onLogEvent(event: LogEvent): Promise<void>;
@@ -64,6 +70,7 @@ export declare class MastraPlatformExporter extends BaseExporter {
64
70
  private buildPublishHeaders;
65
71
  private buildPublishBody;
66
72
  private batchUpload;
73
+ private uploadBody;
67
74
  /**
68
75
  * Enter the quota-exhausted paused state: drop buffered events, stop the
69
76
  * flush timer, and start probing until the collector stops rejecting with
@@ -79,6 +86,9 @@ export declare class MastraPlatformExporter extends BaseExporter {
79
86
  * captures it to keep the retry-after hint.
80
87
  */
81
88
  private probeQuotaStatus;
89
+ /** Current queued and active serialized JSON bytes; undefined in count mode. */
90
+ getByteBatchingStats(): PlatformByteBatchingStats | undefined;
91
+ private flushByteBatch;
82
92
  private flushSignalBatch;
83
93
  private resetBuffer;
84
94
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"mastra-platform.d.ts","sourceRoot":"","sources":["../../src/exporters/mastra-platform.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,YAAY,EAEZ,QAAQ,EACR,WAAW,EACX,UAAU,EACV,aAAa,EACd,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAGjD,MAAM,WAAW,4BAA6B,SAAQ,kBAAkB;IACtE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EA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,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAWnD;IAEK,eAAe,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAWzD;IAED,OAAO,CAAC,WAAW;IAYnB,OAAO,CAAC,cAAc;IAWtB,OAAO,CAAC,iBAAiB;IAWzB,OAAO,CAAC,gBAAgB;IAWxB,OAAO,CAAC,mBAAmB;IAW3B,OAAO,CAAC,eAAe;IAMvB,OAAO,CAAC,UAAU;IAelB,OAAO,CAAC,SAAS;IAMjB,OAAO,CAAC,YAAY;IAMpB,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,cAAc;YAMR,mBAAmB;IAajC,OAAO,CAAC,WAAW;IAenB,OAAO,CAAC,aAAa;YAoBP,WAAW;IA4EzB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAQ3B,OAAO,CAAC,gBAAgB;YAIV,WAAW;YAIX,UAAU;IAuDxB;;;;;OAKG;IACH,OAAO,CAAC,eAAe;IAuBvB,OAAO,CAAC,kBAAkB;IAkB1B;;;;;OAKG;YACW,gBAAgB;IAoD9B,gFAAgF;IAChF,oBAAoB,IAAI,yBAAyB,GAAG,SAAS,CAE5D;YAEa,cAAc;YAuBd,gBAAgB;IAmC9B,OAAO,CAAC,WAAW;IAUnB;;;;OAIG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CA8B3B;IAEK,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAqC9B;CACF"}
@@ -2,8 +2,11 @@ import type { TracingEvent, InitExporterOptions, MetricEvent, LogEvent, ScoreEve
2
2
  import type { TracingStorageStrategy } from '@mastra/core/storage';
3
3
  import type { BaseExporterConfig } from './base.js';
4
4
  import { BaseExporter } from './base.js';
5
+ import type { StorageByteBatchingConfig, StorageByteBatchingStats } from './storage-byte-tracker.js';
6
+ export type { StorageByteBatchingConfig, StorageByteBatchingStats } from './storage-byte-tracker.js';
5
7
  /** Configuration for the MastraStorageExporter's batching, retry, and strategy behavior. */
6
8
  export interface MastraStorageExporterConfig extends BaseExporterConfig {
9
+ byteBatching?: StorageByteBatchingConfig;
7
10
  maxBatchSize?: number;
8
11
  maxBufferSize?: number;
9
12
  maxBatchWaitMs?: number;
@@ -83,6 +86,7 @@ export declare class MastraStorageExporter extends BaseExporter {
83
86
  * Completed spans (SPAN_ENDED) are cleaned up from allCreatedSpans after success.
84
87
  */
85
88
  private flushBuffer;
89
+ getByteBatchingStats(): StorageByteBatchingStats | undefined;
86
90
  _exportTracingEvent(event: TracingEvent): Promise<void>;
87
91
  /**
88
92
  * Handle metric events — buffer for batch flush.
@@ -1 +1 @@
1
- {"version":3,"file":"mastra-storage.d.ts","sourceRoot":"","sources":["../../src/exporters/mastra-storage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,YAAY,EACZ,mBAAmB,EACnB,WAAW,EACX,QAAQ,EACR,UAAU,EACV,aAAa,EAId,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAwB,sBAAsB,EAAwB,MAAM,sBAAsB,CAAC;AAS/G,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAKtC,4FAA4F;AAC5F,MAAM,WAAW,2BAA4B,SAAQ,kBAAkB;IACrE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IAGtB,QAAQ,CAAC,EAAE,sBAAsB,GAAG,MAAM,CAAC;CAC5C;AAoCD;;;GAGG;AACH,qBAAa,qBAAsB,SAAQ,YAAY;;IACrD,IAAI,SAA6B;IAkBjC,YAAY,MAAM,GAAE,2BAAgC,EAenD;IAED;;OAEG;IACG,IAAI,CAAC,OAAO,EAAE,mBAAmB,GAA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B;;;OAGG;IACH,OAAO,CAAC,cAAc;IAuBtB;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAgCxB;;;;;;;OAOG;YACW,WAAW;IAoJzB,oBAAoB,IAAI,wBAAwB,GAAG,SAAS,CAE3D;IAEK,mBAAmB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAS5D;IAED;;OAEG;IACG,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAMrD;IAED;;OAEG;IACG,UAAU,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAM/C;IAED;;OAEG;IACG,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAMnD;IAED;;OAEG;IACG,eAAe,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAMzD;IAED;;;;OAIG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CA0C3B;IAEK,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CA6B9B;CACF"}
@@ -0,0 +1,42 @@
1
+ /** Opt-in limits for the Platform exporter's serialized upload queue. */
2
+ export interface PlatformByteBatchingConfig {
3
+ /** UTF-8 JSON byte threshold that triggers an upload. Records are never split or truncated. Default: 8 MiB. */
4
+ maxBatchBytes?: number;
5
+ /** Maximum simultaneous uploads across all signal types. Default: 2. */
6
+ maxConcurrentUploads?: number;
7
+ /** Deadline for an upload including retries, in milliseconds. Default: 30000. */
8
+ uploadTimeoutMs?: number;
9
+ }
10
+ export interface PlatformByteBatchingStats {
11
+ pendingBytes: number;
12
+ activeUploads: number;
13
+ }
14
+ export declare function resolveByteBatchingConfig(config: PlatformByteBatchingConfig): Required<PlatformByteBatchingConfig>;
15
+ /**
16
+ * Serialize each record once, before retaining it. The accounting includes open
17
+ * batches, ready batches and uploads until they settle. This tracks retained
18
+ * JSON bytes for diagnostics; queued bytes are not capped.
19
+ */
20
+ export declare class PlatformByteBatcher<TSignal extends string> {
21
+ private readonly config;
22
+ private readonly maxBatchSize;
23
+ private readonly maxBatchWaitMs;
24
+ private readonly segments;
25
+ private readonly send;
26
+ private readonly onError;
27
+ private open;
28
+ private ready;
29
+ private active;
30
+ private timer?;
31
+ private pendingBytes;
32
+ constructor(config: Required<PlatformByteBatchingConfig>, maxBatchSize: number, maxBatchWaitMs: number, segments: Record<TSignal, string>, send: (signal: TSignal, body: string, count: number) => Promise<void>, onError: (error: unknown) => void);
33
+ add(signal: TSignal, record: unknown): void;
34
+ private seal;
35
+ private sealAll;
36
+ private pump;
37
+ /** Drop unsent batches after auth/quota rejection. In-flight uploads still remain accounted for. */
38
+ clearQueued(): void;
39
+ flush(): Promise<void>;
40
+ getStats(): PlatformByteBatchingStats;
41
+ }
42
+ //# sourceMappingURL=platform-byte-batcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform-byte-batcher.d.ts","sourceRoot":"","sources":["../../src/exporters/platform-byte-batcher.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,MAAM,WAAW,0BAA0B;IACzC,+GAA+G;IAC/G,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,wEAAwE;IACxE,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,iFAAiF;IACjF,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,yBAAyB;IACxC,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;CACvB;AASD,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,0BAA0B,GAAG,QAAQ,CAAC,0BAA0B,CAAC,CAgBlH;AAED;;;;GAIG;AACH,qBAAa,mBAAmB,CAAC,OAAO,SAAS,MAAM;IAQnD,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAZ1B,OAAO,CAAC,IAAI,CAAsC;IAClD,OAAO,CAAC,KAAK,CAAwB;IACrC,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,KAAK,CAAC,CAAgC;IAC9C,OAAO,CAAC,YAAY,CAAK;IAEzB,YACmB,MAAM,EAAE,QAAQ,CAAC,0BAA0B,CAAC,EAC5C,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,MAAM,EACtB,QAAQ,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,EACjC,IAAI,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,EACrE,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,EAQnD;IAED,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CA6B1C;IAED,OAAO,CAAC,IAAI;IAQZ,OAAO,CAAC,OAAO;IAMf,OAAO,CAAC,IAAI;IAqBZ,oGAAoG;IACpG,WAAW,IAAI,IAAI,CAMlB;IAEK,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAM3B;IAED,QAAQ,IAAI,yBAAyB,CAKpC;CACF"}
@@ -0,0 +1,31 @@
1
+ import type { ObservabilityEvent } from '@mastra/core/observability';
2
+ import type { BufferedEvent } from './event-buffer.js';
3
+ export interface StorageByteBatchingConfig {
4
+ /** Serialized buffered-event byte threshold for flushing. Default: 8 MiB. Adapter encoding can add overhead. */
5
+ maxBatchBytes?: number;
6
+ /** Concurrent storage calls. Default: 1; update-based strategies always use 1 to preserve ordering. */
7
+ maxConcurrentWrites?: number;
8
+ }
9
+ export interface StorageByteBatchingStats {
10
+ pendingBytes: number;
11
+ pendingRecords: number;
12
+ activeWrites: number;
13
+ }
14
+ export declare function resolveStorageByteBatching(config: StorageByteBatchingConfig): Required<StorageByteBatchingConfig>;
15
+ /** Counts each admitted event once until persistence or a definitive drop, even across retries. */
16
+ export declare class StorageByteTracker {
17
+ readonly config: Required<StorageByteBatchingConfig>;
18
+ private sizes;
19
+ private queued;
20
+ private pendingBytes;
21
+ private pendingRecords;
22
+ queuedBytes: number;
23
+ constructor(config: Required<StorageByteBatchingConfig>);
24
+ capture(event: ObservabilityEvent): BufferedEvent;
25
+ size(event: BufferedEvent): number;
26
+ enqueue(event: BufferedEvent): void;
27
+ dequeue(event: BufferedEvent): void;
28
+ releaseIfUnqueued(event: BufferedEvent): boolean;
29
+ stats(activeWrites: number): StorageByteBatchingStats;
30
+ }
31
+ //# sourceMappingURL=storage-byte-tracker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage-byte-tracker.d.ts","sourceRoot":"","sources":["../../src/exporters/storage-byte-tracker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,MAAM,WAAW,yBAAyB;IACxC,gHAAgH;IAChH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,uGAAuG;IACvG,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,wBAAwB;IACvC,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,yBAAyB,GAAG,QAAQ,CAAC,yBAAyB,CAAC,CAUjH;AAED,mGAAmG;AACnG,qBAAa,kBAAkB;IAOjB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,yBAAyB,CAAC;IANhE,OAAO,CAAC,KAAK,CAAwC;IACrD,OAAO,CAAC,MAAM,CAAgC;IAC9C,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,cAAc,CAAK;IAC3B,WAAW,SAAK;IAEhB,YAAqB,MAAM,EAAE,QAAQ,CAAC,yBAAyB,CAAC,EAAI;IAEpE,OAAO,CAAC,KAAK,EAAE,kBAAkB,GAAG,aAAa,CAUhD;IAED,IAAI,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,CAEjC;IAED,OAAO,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAKlC;IAED,OAAO,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAElC;IAED,iBAAiB,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAQ/C;IAED,KAAK,CAAC,YAAY,EAAE,MAAM,GAAG,wBAAwB,CAMpD;CACF"}