@mastra/observability 1.0.0-beta.10 → 1.0.0-beta.12

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/CHANGELOG.md CHANGED
@@ -1,5 +1,146 @@
1
1
  # @mastra/observability
2
2
 
3
+ ## 1.0.0-beta.12
4
+
5
+ ### Patch Changes
6
+
7
+ - Added `customSpanFormatter` option to exporters for per-exporter span transformation. This allows different formatting per exporter and supports both synchronous and asynchronous operations, including async data enrichment. ([#11985](https://github.com/mastra-ai/mastra/pull/11985))
8
+
9
+ **Configuration example:**
10
+
11
+ ```ts
12
+ import { DefaultExporter } from '@mastra/observability';
13
+ import { SpanType } from '@mastra/core/observability';
14
+ import type { CustomSpanFormatter } from '@mastra/core/observability';
15
+
16
+ // Sync formatter
17
+ const plainTextFormatter: CustomSpanFormatter = span => {
18
+ if (span.type === SpanType.AGENT_RUN && Array.isArray(span.input)) {
19
+ const userMessage = span.input.find(m => m.role === 'user');
20
+ return { ...span, input: userMessage?.content ?? span.input };
21
+ }
22
+ return span;
23
+ };
24
+
25
+ // Async formatter for data enrichment
26
+ const enrichmentFormatter: CustomSpanFormatter = async span => {
27
+ const userData = await fetchUserData(span.metadata?.userId);
28
+ return { ...span, metadata: { ...span.metadata, userName: userData.name } };
29
+ };
30
+
31
+ const exporter = new DefaultExporter({
32
+ customSpanFormatter: plainTextFormatter,
33
+ });
34
+ ```
35
+
36
+ Also added `chainFormatters` utility to combine multiple formatters (supports mixed sync/async):
37
+
38
+ ```ts
39
+ import { chainFormatters } from '@mastra/observability';
40
+
41
+ const exporter = new BraintrustExporter({
42
+ customSpanFormatter: chainFormatters([syncFormatter, asyncFormatter]),
43
+ });
44
+ ```
45
+
46
+ - Updated dependencies [[`c8417b4`](https://github.com/mastra-ai/mastra/commit/c8417b41d9f3486854dc7842d977fbe5e2166264), [`dd4f34c`](https://github.com/mastra-ai/mastra/commit/dd4f34c78cbae24063463475b0619575c415f9b8)]:
47
+ - @mastra/core@1.0.0-beta.23
48
+
49
+ ## 1.0.0-beta.11
50
+
51
+ ### Major Changes
52
+
53
+ - **Breaking Change**: Convert OUTPUT generic from `OutputSchema` constraint to plain generic ([#11741](https://github.com/mastra-ai/mastra/pull/11741))
54
+
55
+ This change removes the direct dependency on Zod typings in the public API by converting all `OUTPUT extends OutputSchema` generic constraints to plain `OUTPUT` generics throughout the codebase. This is preparation for moving to a standard schema approach.
56
+ - All generic type parameters previously constrained to `OutputSchema` (e.g., `<OUTPUT extends OutputSchema = undefined>`) are now plain generics with defaults (e.g., `<OUTPUT = undefined>`)
57
+ - Affects all public APIs including `Agent`, `MastraModelOutput`, `AgentExecutionOptions`, and stream/generate methods
58
+ - `InferSchemaOutput<OUTPUT>` replaced with `OUTPUT` throughout
59
+ - `PartialSchemaOutput<OUTPUT>` replaced with `Partial<OUTPUT>`
60
+ - Schema fields now use `NonNullable<OutputSchema<OUTPUT>>` instead of `OUTPUT` directly
61
+ - Added `FullOutput<OUTPUT>` type representing complete output with all fields
62
+ - Added `AgentExecutionOptionsBase<OUTPUT>` type
63
+ - `getFullOutput()` method now returns `Promise<FullOutput<OUTPUT>>`
64
+ - `Agent` class now generic: `Agent<TAgentId, TTools, TOutput>`
65
+ - `agent.generate()` and `agent.stream()` methods have updated signatures
66
+ - `MastraModelOutput<OUTPUT>` no longer requires `OutputSchema` constraint
67
+ - Network route and streaming APIs updated to use plain OUTPUT generic
68
+
69
+ **Before:**
70
+
71
+ ```typescript
72
+ const output = await agent.generate<z.ZodType>({
73
+ messages: [...],
74
+ structuredOutput: { schema: mySchema }
75
+ });
76
+
77
+ **After:**
78
+ const output = await agent.generate<z.infer<typeof mySchema>>({
79
+ messages: [...],
80
+ structuredOutput: { schema: mySchema }
81
+ });
82
+ // Or rely on type inference:
83
+ const output = await agent.generate({
84
+ messages: [...],
85
+ structuredOutput: { schema: mySchema }
86
+ });
87
+
88
+ ```
89
+
90
+ ### Minor Changes
91
+
92
+ - Add `hideInput` and `hideOutput` options to `TracingOptions` for protecting sensitive data in traces. ([#11969](https://github.com/mastra-ai/mastra/pull/11969))
93
+
94
+ When set to `true`, these options hide input/output data from all spans in a trace, including child spans. This is useful for protecting sensitive information from being logged to observability platforms.
95
+
96
+ ```typescript
97
+ const agent = mastra.getAgent('myAgent');
98
+ await agent.generate('Process this sensitive data', {
99
+ tracingOptions: {
100
+ hideInput: true, // Input will be hidden from all spans
101
+ hideOutput: true, // Output will be hidden from all spans
102
+ },
103
+ });
104
+ ```
105
+
106
+ The options can be used independently (hide only input or only output) or together. The settings are propagated to all child spans via `TraceState`, ensuring consistent behavior across the entire trace.
107
+
108
+ Fixes #10888
109
+
110
+ - Added `TrackingExporter` base class with improved handling for: ([#11870](https://github.com/mastra-ai/mastra/pull/11870))
111
+ - **Out-of-order span processing**: Spans that arrive before their parents are now queued and processed once dependencies are available
112
+ - **Delayed cleanup**: Trace data is retained briefly after spans end to handle late-arriving updates
113
+ - **Memory management**: Configurable limits on pending and total traces to prevent memory leaks
114
+
115
+ New configuration options on `TrackingExporterConfig`:
116
+ - `earlyQueueMaxAttempts` - Max retry attempts for queued events (default: 5)
117
+ - `earlyQueueTTLMs` - TTL for queued events in ms (default: 30000)
118
+ - `traceCleanupDelayMs` - Delay before cleaning up completed traces (default: 30000)
119
+ - `maxPendingCleanupTraces` - Soft cap on traces awaiting cleanup (default: 100)
120
+ - `maxTotalTraces` - Hard cap on total traces (default: 500)
121
+
122
+ Updated @mastra/braintrust, @mastra/langfuse, @mastra/langsmith, @mastra/posthog to use the new TrackingExporter
123
+
124
+ ### Patch Changes
125
+
126
+ - feat(spans): implement entity inheritance for child spans ([#11914](https://github.com/mastra-ai/mastra/pull/11914))
127
+
128
+ Added tests to verify that child spans inherit entityId and entityName from their parent spans when not explicitly provided. Also included functionality to allow child spans to override these inherited values. This ensures proper entity identification across multiple levels of span hierarchy.
129
+
130
+ - Improved tracing by filtering infrastructure chunks from model streams and adding success attribute to tool spans. ([#11943](https://github.com/mastra-ai/mastra/pull/11943))
131
+
132
+ Added generic input/output attribute mapping for additional span types in Arize exporter.
133
+
134
+ - Real-time span export for Inngest workflow engine ([#11973](https://github.com/mastra-ai/mastra/pull/11973))
135
+ - Spans are now exported immediately when created and ended, instead of being batched at workflow completion
136
+ - Added durable span lifecycle hooks (`createStepSpan`, `endStepSpan`, `errorStepSpan`, `createChildSpan`, `endChildSpan`, `errorChildSpan`) that wrap span operations in Inngest's `step.run()` for memoization
137
+ - Added `rebuildSpan()` method to reconstruct span objects from exported data after Inngest replay
138
+ - Fixed nested workflow step spans missing output data
139
+ - Spans correctly maintain parent-child relationships across Inngest's durable execution boundaries using `tracingIds`
140
+
141
+ - Updated dependencies [[`ebae12a`](https://github.com/mastra-ai/mastra/commit/ebae12a2dd0212e75478981053b148a2c246962d), [`c61a0a5`](https://github.com/mastra-ai/mastra/commit/c61a0a5de4904c88fd8b3718bc26d1be1c2ec6e7), [`69136e7`](https://github.com/mastra-ai/mastra/commit/69136e748e32f57297728a4e0f9a75988462f1a7), [`449aed2`](https://github.com/mastra-ai/mastra/commit/449aed2ba9d507b75bf93d427646ea94f734dfd1), [`eb648a2`](https://github.com/mastra-ai/mastra/commit/eb648a2cc1728f7678768dd70cd77619b448dab9), [`0131105`](https://github.com/mastra-ai/mastra/commit/0131105532e83bdcbb73352fc7d0879eebf140dc), [`9d5059e`](https://github.com/mastra-ai/mastra/commit/9d5059eae810829935fb08e81a9bb7ecd5b144a7), [`ef756c6`](https://github.com/mastra-ai/mastra/commit/ef756c65f82d16531c43f49a27290a416611e526), [`b00ccd3`](https://github.com/mastra-ai/mastra/commit/b00ccd325ebd5d9e37e34dd0a105caae67eb568f), [`3bdfa75`](https://github.com/mastra-ai/mastra/commit/3bdfa7507a91db66f176ba8221aa28dd546e464a), [`e770de9`](https://github.com/mastra-ai/mastra/commit/e770de941a287a49b1964d44db5a5763d19890a6), [`52e2716`](https://github.com/mastra-ai/mastra/commit/52e2716b42df6eff443de72360ae83e86ec23993), [`27b4040`](https://github.com/mastra-ai/mastra/commit/27b4040bfa1a95d92546f420a02a626b1419a1d6), [`610a70b`](https://github.com/mastra-ai/mastra/commit/610a70bdad282079f0c630e0d7bb284578f20151), [`8dc7f55`](https://github.com/mastra-ai/mastra/commit/8dc7f55900395771da851dc7d78d53ae84fe34ec), [`8379099`](https://github.com/mastra-ai/mastra/commit/8379099fc467af6bef54dd7f80c9bd75bf8bbddf), [`8c0ec25`](https://github.com/mastra-ai/mastra/commit/8c0ec25646c8a7df253ed1e5ff4863a0d3f1316c), [`ff4d9a6`](https://github.com/mastra-ai/mastra/commit/ff4d9a6704fc87b31a380a76ed22736fdedbba5a), [`69821ef`](https://github.com/mastra-ai/mastra/commit/69821ef806482e2c44e2197ac0b050c3fe3a5285), [`1ed5716`](https://github.com/mastra-ai/mastra/commit/1ed5716830867b3774c4a1b43cc0d82935f32b96), [`4186bdd`](https://github.com/mastra-ai/mastra/commit/4186bdd00731305726fa06adba0b076a1d50b49f), [`7aaf973`](https://github.com/mastra-ai/mastra/commit/7aaf973f83fbbe9521f1f9e7a4fd99b8de464617)]:
142
+ - @mastra/core@1.0.0-beta.22
143
+
3
144
  ## 1.0.0-beta.10
4
145
 
5
146
  ### Minor Changes
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).
@@ -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
  /**
@@ -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,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;CAC3D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,8BAAsB,YAAa,YAAW,qBAAqB;IACjE,wDAAwD;IACxD,QAAQ,CAAC,IAAI,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AAG,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;;;;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);
@@ -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,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AC;CAuChC"}
@@ -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"}