@mastra/observability 1.0.0-beta.9 → 1.0.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/README.md CHANGED
@@ -1,99 +1,54 @@
1
1
  # Mastra Observability
2
2
 
3
- A comprehensive observability system for AI operations in Mastra, providing type-safe span tracking, event-driven exports, and flexible tracing configuration.
3
+ Tracing and monitoring for AI operations in Mastra.
4
4
 
5
- ## Overview
5
+ ## Installation
6
6
 
7
- The Mastra Observability system enables detailed observability for AI-driven applications by tracking operations through spans that capture metadata, timing, and context. It's designed to work seamlessly with Mastra's architecture while providing flexible configuration and export options.
8
-
9
- ## Key Features
10
-
11
- - **Type-Safe Spans**: Strongly typed metadata based on span type prevents runtime errors
12
- - **Event-Driven Architecture**: Real-time tracing events for immediate observability
13
- - **OpenTelemetry Compatible**: Uses standard trace and span ID formats for integration
14
- - **Flexible Sampling**: Multiple sampling strategies with custom sampler support
15
- - **Pluggable Processors**: Modify or filter span fields before export
16
- - **Pluggable Exporters**: Multiple export formats and destinations
17
- - **Automatic Lifecycle Management**: Spans automatically emit events without manual intervention
18
-
19
- ## Quick Start
20
-
21
- ### Manual Tracing
22
-
23
- ```typescript
24
- import { DefaultObservabilityInstance, SpanType } from '@mastra/observability';
25
-
26
- // Create observability instance
27
- const observability = new DefaultObservabilityInstance({
28
- name: 'my-app',
29
- serviceName: 'my-app',
30
- });
31
-
32
- // Start an agent span
33
- const agentSpan = observability.startSpan({
34
- type: SpanType.AGENT_RUN,
35
- name: 'customer-support-agent',
36
- attributes: {
37
- agentId: 'agent-123',
38
- instructions: 'Help with customer support',
39
- maxSteps: 10,
40
- },
41
- });
42
-
43
- // Create child spans for nested operations
44
- const llmSpan = agentSpan.createChildSpan({
45
- type: SpanType.MODEL_GENERATION,
46
- name: 'gpt-4-response',
47
- attributes: {
48
- model: 'gpt-4',
49
- provider: 'openai',
50
- streaming: false,
51
- },
52
- });
53
-
54
- // End spans with results
55
- llmSpan.end({
56
- output: 'Generated response',
57
- attributes: { usage: { totalTokens: 180 } },
58
- });
59
- agentSpan.end();
7
+ ```bash
8
+ npm install @mastra/observability
60
9
  ```
61
10
 
62
- ### Span Types
63
-
64
- - **`WORKFLOW_RUN`**: Root span for entire workflow execution
65
- - **`WORKFLOW_STEP`**: Individual step execution within a workflow
66
- - **`AGENT_RUN`**: Agent processing (supports tools, memory, multi-step)
67
- - **`MODEL_GENERATION`**: Individual model API calls with token usage
68
- - **`TOOL_CALL`**: Function/tool execution
69
- - **`MCP_TOOL_CALL`**: Model Context Protocol tool execution
70
- - **`PROCESSOR_RUN`**: Input/output processor execution
71
- - **`GENERIC`**: Custom spans for other operations
72
-
73
- ### Basic Configuration
74
-
75
- Enable observability in your Mastra instance:
11
+ ## Quick Start
76
12
 
77
13
  ```typescript
78
14
  import { Mastra } from '@mastra/core';
79
- import { Observability } from '@mastra/observability';
15
+ import { Observability, DefaultExporter, CloudExporter, SensitiveDataFilter } from '@mastra/observability';
80
16
 
81
17
  export const mastra = new Mastra({
82
- // ... other config
83
18
  observability: new Observability({
84
- default: { enabled: true },
19
+ configs: {
20
+ default: {
21
+ serviceName: 'my-app',
22
+ exporters: [
23
+ new DefaultExporter(), // Persists traces for Mastra Studio
24
+ new CloudExporter(), // Sends to Mastra Cloud
25
+ ],
26
+ spanOutputProcessors: [new SensitiveDataFilter()],
27
+ },
28
+ },
85
29
  }),
86
30
  });
87
31
  ```
88
32
 
89
- This enables the `DefaultExporter` and `CloudExporter`, with the `SensitiveDataFilter` span output processor, and `always` sampling.
33
+ ## Features
34
+
35
+ - **Auto-instrumentation** - Traces agent runs, LLM calls, tool executions, and workflows
36
+ - **Pluggable Exporters** - Exporters for Studio and Cloud, plus integrations for Arize, Braintrust, Langfuse, LangSmith, and OpenTelemetry
37
+ - **Sampling Strategies** - Always, ratio-based, or custom sampling
38
+ - **Span Processors** - Transform or filter span data before export
39
+ - **OpenTelemetry Compatible** - Standard trace/span ID formats for integration
90
40
 
91
- ## Performance Considerations
41
+ ## Span Types
92
42
 
93
- ### Current Implementation
43
+ - `WORKFLOW_RUN` - Workflow execution
44
+ - `WORKFLOW_STEP` - Individual workflow step
45
+ - `AGENT_RUN` - Agent processing
46
+ - `MODEL_GENERATION` - LLM API calls
47
+ - `TOOL_CALL` - Tool execution
48
+ - `MCP_TOOL_CALL` - MCP tool execution
49
+ - `PROCESSOR_RUN` - Processor execution
50
+ - `GENERIC` - Custom operations
94
51
 
95
- The current implementation prioritizes correctness and ease of use:
52
+ ## Documentation
96
53
 
97
- - **Automatic Lifecycle Management**: All spans automatically emit events through method wrapping
98
- - **Real-time Export**: Events are exported immediately when they occur
99
- - **Memory Overhead**: Each span maintains references to tracing instance
54
+ For configuration options, exporters, sampling strategies, and more, see the [full documentation](https://mastra.ai/docs/v1/observability/overview).
package/dist/config.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * including tracing configs, sampling strategies, and registry setup.
6
6
  */
7
7
  import type { RequestContext } from '@mastra/core/di';
8
- import type { ObservabilityInstance, ObservabilityExporter, ObservabilityBridge, SpanOutputProcessor, ConfigSelector } from '@mastra/core/observability';
8
+ import type { ObservabilityInstance, ObservabilityExporter, ObservabilityBridge, SpanOutputProcessor, ConfigSelector, SerializationOptions } from '@mastra/core/observability';
9
9
  import { z } from 'zod';
10
10
  /**
11
11
  * Sampling strategy types
@@ -61,12 +61,21 @@ export interface ObservabilityInstanceConfig {
61
61
  * Supports dot notation for nested values.
62
62
  */
63
63
  requestContextKeys?: string[];
64
+ /**
65
+ * Options for controlling serialization of span data (input/output/attributes).
66
+ * Use these to customize truncation limits for large payloads.
67
+ */
68
+ serializationOptions?: SerializationOptions;
64
69
  }
65
70
  /**
66
71
  * Complete Observability registry configuration
67
72
  */
68
73
  export interface ObservabilityRegistryConfig {
69
- /** Enables default exporters, with sampling: always, and sensitive data filtering */
74
+ /**
75
+ * Enables default exporters, with sampling: always, and sensitive data filtering
76
+ * @deprecated Use explicit `configs` with DefaultExporter, CloudExporter, and SensitiveDataFilter instead.
77
+ * This option will be removed in a future version.
78
+ */
70
79
  default?: {
71
80
  enabled?: boolean;
72
81
  };
@@ -109,6 +118,25 @@ export declare const samplingStrategySchema: z.ZodDiscriminatedUnion<"type", [z.
109
118
  type: SamplingStrategyType.CUSTOM;
110
119
  sampler: (args_0: any, ...args: unknown[]) => boolean;
111
120
  }>]>;
121
+ /**
122
+ * Zod schema for SerializationOptions
123
+ */
124
+ export declare const serializationOptionsSchema: z.ZodOptional<z.ZodObject<{
125
+ maxStringLength: z.ZodOptional<z.ZodNumber>;
126
+ maxDepth: z.ZodOptional<z.ZodNumber>;
127
+ maxArrayLength: z.ZodOptional<z.ZodNumber>;
128
+ maxObjectKeys: z.ZodOptional<z.ZodNumber>;
129
+ }, "strip", z.ZodTypeAny, {
130
+ maxStringLength?: number | undefined;
131
+ maxDepth?: number | undefined;
132
+ maxArrayLength?: number | undefined;
133
+ maxObjectKeys?: number | undefined;
134
+ }, {
135
+ maxStringLength?: number | undefined;
136
+ maxDepth?: number | undefined;
137
+ maxArrayLength?: number | undefined;
138
+ maxObjectKeys?: number | undefined;
139
+ }>>;
112
140
  /**
113
141
  * Zod schema for ObservabilityInstanceConfig
114
142
  * Note: exporters, spanOutputProcessors, bridge, and configSelector are validated as any
@@ -153,6 +181,22 @@ export declare const observabilityInstanceConfigSchema: z.ZodEffects<z.ZodObject
153
181
  spanOutputProcessors: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
154
182
  includeInternalSpans: z.ZodOptional<z.ZodBoolean>;
155
183
  requestContextKeys: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
184
+ serializationOptions: z.ZodOptional<z.ZodObject<{
185
+ maxStringLength: z.ZodOptional<z.ZodNumber>;
186
+ maxDepth: z.ZodOptional<z.ZodNumber>;
187
+ maxArrayLength: z.ZodOptional<z.ZodNumber>;
188
+ maxObjectKeys: z.ZodOptional<z.ZodNumber>;
189
+ }, "strip", z.ZodTypeAny, {
190
+ maxStringLength?: number | undefined;
191
+ maxDepth?: number | undefined;
192
+ maxArrayLength?: number | undefined;
193
+ maxObjectKeys?: number | undefined;
194
+ }, {
195
+ maxStringLength?: number | undefined;
196
+ maxDepth?: number | undefined;
197
+ maxArrayLength?: number | undefined;
198
+ maxObjectKeys?: number | undefined;
199
+ }>>;
156
200
  }, "strip", z.ZodTypeAny, {
157
201
  name: string;
158
202
  serviceName: string;
@@ -172,6 +216,12 @@ export declare const observabilityInstanceConfigSchema: z.ZodEffects<z.ZodObject
172
216
  spanOutputProcessors?: any[] | undefined;
173
217
  includeInternalSpans?: boolean | undefined;
174
218
  requestContextKeys?: string[] | undefined;
219
+ serializationOptions?: {
220
+ maxStringLength?: number | undefined;
221
+ maxDepth?: number | undefined;
222
+ maxArrayLength?: number | undefined;
223
+ maxObjectKeys?: number | undefined;
224
+ } | undefined;
175
225
  }, {
176
226
  name: string;
177
227
  serviceName: string;
@@ -191,6 +241,12 @@ export declare const observabilityInstanceConfigSchema: z.ZodEffects<z.ZodObject
191
241
  spanOutputProcessors?: any[] | undefined;
192
242
  includeInternalSpans?: boolean | undefined;
193
243
  requestContextKeys?: string[] | undefined;
244
+ serializationOptions?: {
245
+ maxStringLength?: number | undefined;
246
+ maxDepth?: number | undefined;
247
+ maxArrayLength?: number | undefined;
248
+ maxObjectKeys?: number | undefined;
249
+ } | undefined;
194
250
  }>, {
195
251
  name: string;
196
252
  serviceName: string;
@@ -210,6 +266,12 @@ export declare const observabilityInstanceConfigSchema: z.ZodEffects<z.ZodObject
210
266
  spanOutputProcessors?: any[] | undefined;
211
267
  includeInternalSpans?: boolean | undefined;
212
268
  requestContextKeys?: string[] | undefined;
269
+ serializationOptions?: {
270
+ maxStringLength?: number | undefined;
271
+ maxDepth?: number | undefined;
272
+ maxArrayLength?: number | undefined;
273
+ maxObjectKeys?: number | undefined;
274
+ } | undefined;
213
275
  }, {
214
276
  name: string;
215
277
  serviceName: string;
@@ -229,6 +291,12 @@ export declare const observabilityInstanceConfigSchema: z.ZodEffects<z.ZodObject
229
291
  spanOutputProcessors?: any[] | undefined;
230
292
  includeInternalSpans?: boolean | undefined;
231
293
  requestContextKeys?: string[] | undefined;
294
+ serializationOptions?: {
295
+ maxStringLength?: number | undefined;
296
+ maxDepth?: number | undefined;
297
+ maxArrayLength?: number | undefined;
298
+ maxObjectKeys?: number | undefined;
299
+ } | undefined;
232
300
  }>;
233
301
  /**
234
302
  * Zod schema for config values in the configs map
@@ -272,6 +340,22 @@ export declare const observabilityConfigValueSchema: z.ZodEffects<z.ZodObject<{
272
340
  spanOutputProcessors: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
273
341
  includeInternalSpans: z.ZodOptional<z.ZodBoolean>;
274
342
  requestContextKeys: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
343
+ serializationOptions: z.ZodOptional<z.ZodObject<{
344
+ maxStringLength: z.ZodOptional<z.ZodNumber>;
345
+ maxDepth: z.ZodOptional<z.ZodNumber>;
346
+ maxArrayLength: z.ZodOptional<z.ZodNumber>;
347
+ maxObjectKeys: z.ZodOptional<z.ZodNumber>;
348
+ }, "strip", z.ZodTypeAny, {
349
+ maxStringLength?: number | undefined;
350
+ maxDepth?: number | undefined;
351
+ maxArrayLength?: number | undefined;
352
+ maxObjectKeys?: number | undefined;
353
+ }, {
354
+ maxStringLength?: number | undefined;
355
+ maxDepth?: number | undefined;
356
+ maxArrayLength?: number | undefined;
357
+ maxObjectKeys?: number | undefined;
358
+ }>>;
275
359
  }, "strip", z.ZodTypeAny, {
276
360
  serviceName: string;
277
361
  sampling?: {
@@ -290,6 +374,12 @@ export declare const observabilityConfigValueSchema: z.ZodEffects<z.ZodObject<{
290
374
  spanOutputProcessors?: any[] | undefined;
291
375
  includeInternalSpans?: boolean | undefined;
292
376
  requestContextKeys?: string[] | undefined;
377
+ serializationOptions?: {
378
+ maxStringLength?: number | undefined;
379
+ maxDepth?: number | undefined;
380
+ maxArrayLength?: number | undefined;
381
+ maxObjectKeys?: number | undefined;
382
+ } | undefined;
293
383
  }, {
294
384
  serviceName: string;
295
385
  sampling?: {
@@ -308,6 +398,12 @@ export declare const observabilityConfigValueSchema: z.ZodEffects<z.ZodObject<{
308
398
  spanOutputProcessors?: any[] | undefined;
309
399
  includeInternalSpans?: boolean | undefined;
310
400
  requestContextKeys?: string[] | undefined;
401
+ serializationOptions?: {
402
+ maxStringLength?: number | undefined;
403
+ maxDepth?: number | undefined;
404
+ maxArrayLength?: number | undefined;
405
+ maxObjectKeys?: number | undefined;
406
+ } | undefined;
311
407
  }>, {
312
408
  serviceName: string;
313
409
  sampling?: {
@@ -326,6 +422,12 @@ export declare const observabilityConfigValueSchema: z.ZodEffects<z.ZodObject<{
326
422
  spanOutputProcessors?: any[] | undefined;
327
423
  includeInternalSpans?: boolean | undefined;
328
424
  requestContextKeys?: string[] | undefined;
425
+ serializationOptions?: {
426
+ maxStringLength?: number | undefined;
427
+ maxDepth?: number | undefined;
428
+ maxArrayLength?: number | undefined;
429
+ maxObjectKeys?: number | undefined;
430
+ } | undefined;
329
431
  }, {
330
432
  serviceName: string;
331
433
  sampling?: {
@@ -344,6 +446,12 @@ export declare const observabilityConfigValueSchema: z.ZodEffects<z.ZodObject<{
344
446
  spanOutputProcessors?: any[] | undefined;
345
447
  includeInternalSpans?: boolean | undefined;
346
448
  requestContextKeys?: string[] | undefined;
449
+ serializationOptions?: {
450
+ maxStringLength?: number | undefined;
451
+ maxDepth?: number | undefined;
452
+ maxArrayLength?: number | undefined;
453
+ maxObjectKeys?: number | undefined;
454
+ } | undefined;
347
455
  }>;
348
456
  /**
349
457
  * Zod schema for ObservabilityRegistryConfig
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB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ACzD,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,EACtB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAA+B,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAezF,qBAAa,aAAc,SAAQ,UAAW,YAAW,uBAAuB;;gBAGlE,MAAM,EAAE,2BAA2B;IA4F/C,gBAAgB,CAAC,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAuBnD,SAAS,CAAC,OAAO,EAAE;QAAE,MAAM,EAAE,aAAa,CAAA;KAAE,GAAG,IAAI;IAOnD,mBAAmB,CAAC,OAAO,EAAE,qBAAqB,GAAG,qBAAqB,GAAG,SAAS;IAItF;;OAEG;IAEH,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,qBAAqB,EAAE,SAAS,UAAQ,GAAG,IAAI;IAIxF,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,qBAAqB,GAAG,SAAS;IAI5D,kBAAkB,IAAI,qBAAqB,GAAG,SAAS;IAIvD,aAAa,IAAI,WAAW,CAAC,MAAM,EAAE,qBAAqB,CAAC;IAI3D,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIzC,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIlC,iBAAiB,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI;IAIjD,KAAK,IAAI,IAAI;IAIP,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAGhC"}
@@ -8,7 +8,7 @@
8
8
  */
9
9
  import { LogLevel } from '@mastra/core/logger';
10
10
  import type { IMastraLogger } from '@mastra/core/logger';
11
- import type { TracingEvent, ObservabilityExporter, InitExporterOptions } from '@mastra/core/observability';
11
+ import type { TracingEvent, ObservabilityExporter, InitExporterOptions, CustomSpanFormatter } from '@mastra/core/observability';
12
12
  /**
13
13
  * Base configuration that all exporters should support
14
14
  */
@@ -17,6 +17,31 @@ export interface BaseExporterConfig {
17
17
  logger?: IMastraLogger;
18
18
  /** Log level for the exporter (defaults to INFO) - accepts both enum and string */
19
19
  logLevel?: LogLevel | 'debug' | 'info' | 'warn' | 'error';
20
+ /**
21
+ * Custom span formatter function to transform exported spans before they are
22
+ * processed by the exporter. This allows customization of how spans appear
23
+ * in vendor-specific observability platforms.
24
+ *
25
+ * Use cases:
26
+ * - Extract plain text from structured AI SDK messages for better readability
27
+ * - Transform input/output format for specific vendor requirements
28
+ * - Add or remove fields based on the target platform
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * const exporter = new BraintrustExporter({
33
+ * customSpanFormatter: (span) => {
34
+ * // Extract plain text user message for AGENT_RUN spans
35
+ * if (span.type === SpanType.AGENT_RUN && Array.isArray(span.input)) {
36
+ * const userMsg = span.input.find(m => m.role === 'user');
37
+ * return { ...span, input: userMsg?.content ?? span.input };
38
+ * }
39
+ * return span;
40
+ * },
41
+ * });
42
+ * ```
43
+ */
44
+ customSpanFormatter?: CustomSpanFormatter;
20
45
  }
21
46
  /**
22
47
  * Abstract base class for observability exporters
@@ -49,12 +74,15 @@ export interface BaseExporterConfig {
49
74
  * ```
50
75
  */
51
76
  export declare abstract class BaseExporter implements ObservabilityExporter {
77
+ #private;
52
78
  /** Exporter name - must be implemented by subclasses */
53
79
  abstract name: string;
54
80
  /** Mastra logger instance */
55
81
  protected logger: IMastraLogger;
56
- /** Whether this exporter is disabled */
57
- protected isDisabled: boolean;
82
+ /** Base configuration (accessible by subclasses) */
83
+ protected readonly baseConfig: BaseExporterConfig;
84
+ /** Public getter for disabled state */
85
+ get isDisabled(): boolean;
58
86
  /**
59
87
  * Initialize the base exporter with logger
60
88
  */
@@ -73,11 +101,23 @@ export declare abstract class BaseExporter implements ObservabilityExporter {
73
101
  * @param reason - Reason why the exporter is disabled
74
102
  */
75
103
  protected setDisabled(reason: string): void;
104
+ /**
105
+ * Apply the customSpanFormatter if configured.
106
+ * This is called automatically by exportTracingEvent before _exportTracingEvent.
107
+ *
108
+ * Supports both synchronous and asynchronous formatters. If the formatter
109
+ * returns a Promise, it will be awaited.
110
+ *
111
+ * @param event - The incoming tracing event
112
+ * @returns The (possibly modified) event to process
113
+ */
114
+ protected applySpanFormatter(event: TracingEvent): Promise<TracingEvent>;
76
115
  /**
77
116
  * Export a tracing event
78
117
  *
79
- * This method checks if the exporter is disabled before calling _exportEvent.
80
- * Subclasses should implement _exportEvent instead of overriding this method.
118
+ * This method checks if the exporter is disabled, applies the customSpanFormatter,
119
+ * then calls _exportTracingEvent.
120
+ * Subclasses should implement _exportTracingEvent instead of overriding this method.
81
121
  */
82
122
  exportTracingEvent(event: TracingEvent): Promise<void>;
83
123
  /**
@@ -101,6 +141,16 @@ export declare abstract class BaseExporter implements ObservabilityExporter {
101
141
  scorerName: string;
102
142
  metadata?: Record<string, any>;
103
143
  }): Promise<void>;
144
+ /**
145
+ * Force flush any buffered/queued spans without shutting down the exporter.
146
+ *
147
+ * This is useful in serverless environments where you need to ensure spans
148
+ * are exported before the runtime instance is terminated, while keeping
149
+ * the exporter active for future requests.
150
+ *
151
+ * Default implementation is a no-op. Override to add flush logic.
152
+ */
153
+ flush(): Promise<void>;
104
154
  /**
105
155
  * Shutdown the exporter and clean up resources
106
156
  *
@@ -1 +1 @@
1
- {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/exporters/base.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAiB,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAE3G;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,sCAAsC;IACtC,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,mFAAmF;IACnF,QAAQ,CAAC,EAAE,QAAQ,GAAG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AAC;IAQ5D;;;;OAIG;IACH,SAAS,CAAC,QAAQ,CAAC,mBAAmB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAE1E;;OAEG;IACH,IAAI,CAAC,CAAC,QAAQ,EAAE,mBAAmB,GAAG,IAAI;IAE1C;;OAEG;IACH,eAAe,CAAC,CAAC,KAAK,EAAE;QACtB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,MAAM,CAAC;QACnB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KAChC,GAAG,OAAO,CAAC,IAAI,CAAC;IAEjB;;;;;;;;OAQG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B;;;;OAIG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAGhC"}
@@ -10,7 +10,7 @@ export interface CloudExporterConfig extends BaseExporterConfig {
10
10
  }
11
11
  export declare class CloudExporter extends BaseExporter {
12
12
  name: string;
13
- private config;
13
+ private cloudConfig;
14
14
  private buffer;
15
15
  private flushTimer;
16
16
  constructor(config?: CloudExporterConfig);
@@ -19,12 +19,18 @@ export declare class CloudExporter extends BaseExporter {
19
19
  private formatSpan;
20
20
  private shouldFlush;
21
21
  private scheduleFlush;
22
- private flush;
22
+ private flushBuffer;
23
23
  /**
24
24
  * Uploads spans to cloud API using fetchWithRetry for all retry logic
25
25
  */
26
26
  private batchUpload;
27
27
  private resetBuffer;
28
+ /**
29
+ * Force flush any buffered spans without shutting down the exporter.
30
+ * This is useful in serverless environments where you need to ensure spans
31
+ * are exported before the runtime instance is terminated.
32
+ */
33
+ flush(): Promise<void>;
28
34
  shutdown(): Promise<void>;
29
35
  }
30
36
  //# sourceMappingURL=cloud.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cloud.d.ts","sourceRoot":"","sources":["../../src/exporters/cloud.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAmB,MAAM,4BAA4B,CAAC;AAEhF,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAEjD,MAAM,WAAW,mBAAoB,SAAQ,kBAAkB;IAC7D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IAGpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AA0BD,qBAAa,aAAc,SAAQ,YAAY;IAC7C,IAAI,SAAyC;IAE7C,OAAO,CAAC,MAAM,CAAgC;IAC9C,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,UAAU,CAA+B;gBAErC,MAAM,GAAE,mBAAwB;cA8B5B,mBAAmB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBvE,OAAO,CAAC,WAAW;IAWnB,OAAO,CAAC,UAAU;IAsBlB,OAAO,CAAC,WAAW;IAiBnB,OAAO,CAAC,aAAa;YAoBP,KAAK;IA8CnB;;OAEG;YACW,WAAW;IAezB,OAAO,CAAC,WAAW;IAMb,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAuChC"}
1
+ {"version":3,"file":"cloud.d.ts","sourceRoot":"","sources":["../../src/exporters/cloud.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAmB,MAAM,4BAA4B,CAAC;AAEhF,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAEjD,MAAM,WAAW,mBAAoB,SAAQ,kBAAkB;IAC7D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IAGpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAgCD,qBAAa,aAAc,SAAQ,YAAY;IAC7C,IAAI,SAAyC;IAE7C,OAAO,CAAC,WAAW,CAAsB;IACzC,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,UAAU,CAA+B;gBAErC,MAAM,GAAE,mBAAwB;cA2B5B,mBAAmB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBvE,OAAO,CAAC,WAAW;IAWnB,OAAO,CAAC,UAAU;IAsBlB,OAAO,CAAC,WAAW;IAiBnB,OAAO,CAAC,aAAa;YAoBP,WAAW;IA8CzB;;OAEG;YACW,WAAW;IAezB,OAAO,CAAC,WAAW;IAMnB;;;;OAIG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IActB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAkChC"}
@@ -76,14 +76,20 @@ export declare class DefaultExporter extends BaseExporter {
76
76
  */
77
77
  private calculateRetryDelay;
78
78
  /**
79
- * Flushes the current buffer to storage with retry logic
79
+ * Flushes the current buffer to storage with retry logic (internal implementation)
80
80
  */
81
- private flush;
81
+ private flushBuffer;
82
82
  /**
83
83
  * Attempts to flush with exponential backoff retry logic
84
84
  */
85
85
  private flushWithRetries;
86
86
  _exportTracingEvent(event: TracingEvent): Promise<void>;
87
+ /**
88
+ * Force flush any buffered spans without shutting down the exporter.
89
+ * This is useful in serverless environments where you need to ensure spans
90
+ * are exported before the runtime instance is terminated.
91
+ */
92
+ flush(): Promise<void>;
87
93
  shutdown(): Promise<void>;
88
94
  }
89
95
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../src/exporters/default.ts"],"names":[],"mappings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;OAEG;IACH,OAAO,CAAC,WAAW;IAgFnB;;OAEG;IACH,OAAO,CAAC,WAAW;IAsBnB;;OAEG;IACH,OAAO,CAAC,WAAW;IAiBnB;;OAEG;IACH,OAAO,CAAC,aAAa;IAarB;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IAiC3B,OAAO,CAAC,iBAAiB;IAgDzB,OAAO,CAAC,iBAAiB;IAczB;;OAEG;YACW,mBAAmB;IAyCjC;;OAEG;IACH,OAAO,CAAC,2BAA2B;IAgBnC;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAoB7B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAI3B;;OAEG;YACW,WAAW;IAsDzB;;OAEG;YACW,gBAAgB;IA+DxB,mBAAmB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAyB7D;;;;OAIG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAStB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAYhC"}
@@ -2,8 +2,9 @@
2
2
  * Mastra Tracing Exporters
3
3
  */
4
4
  export * from './base.js';
5
- export { CloudExporter } from './cloud.js';
6
- export type { CloudExporterConfig } from './cloud.js';
5
+ export * from './tracking.js';
6
+ export * from './span-formatters.js';
7
+ export * from './cloud.js';
7
8
  export * from './console.js';
8
9
  export * from './default.js';
9
10
  export * from './test.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/exporters/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,cAAc,QAAQ,CAAC;AAGvB,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AACnD,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/exporters/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAG3B,cAAc,mBAAmB,CAAC;AAGlC,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Utility functions for working with custom span formatters.
3
+ */
4
+ import type { CustomSpanFormatter } from '@mastra/core/observability';
5
+ /**
6
+ * Chains multiple span formatters into a single formatter.
7
+ *
8
+ * Formatters are applied in order, with each receiving the output of the previous.
9
+ * Supports both synchronous and asynchronous formatters - if any formatter returns
10
+ * a Promise, the entire chain will return a Promise.
11
+ *
12
+ * @param formatters - Array of formatters to chain (can be sync or async)
13
+ * @returns A single formatter that applies all formatters in sequence
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * // Chain sync formatters
18
+ * const chainedFormatter = chainFormatters([
19
+ * myPlainTextFormatter,
20
+ * myRedactionFormatter,
21
+ * ]);
22
+ *
23
+ * // Chain mixed sync and async formatters
24
+ * const asyncChainedFormatter = chainFormatters([
25
+ * myPlainTextFormatter, // sync
26
+ * myAsyncEnrichmentFormatter, // async
27
+ * ]);
28
+ *
29
+ * const exporter = new BraintrustExporter({
30
+ * customSpanFormatter: chainedFormatter,
31
+ * });
32
+ * ```
33
+ */
34
+ export declare function chainFormatters(formatters: CustomSpanFormatter[]): CustomSpanFormatter;
35
+ //# sourceMappingURL=span-formatters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"span-formatters.d.ts","sourceRoot":"","sources":["../../src/exporters/span-formatters.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAmB,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEvF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,mBAAmB,EAAE,GAAG,mBAAmB,CAQtF"}