@mastra/mcp-docs-server 0.13.24 → 0.13.25-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.
Files changed (105) hide show
  1. package/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +8 -8
  2. package/.docs/organized/changelogs/%40internal%2Ftypes-builder.md +2 -0
  3. package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +12 -0
  4. package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +11 -0
  5. package/.docs/organized/changelogs/%40mastra%2Fastra.md +10 -10
  6. package/.docs/organized/changelogs/%40mastra%2Fchroma.md +10 -10
  7. package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +10 -10
  8. package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +29 -29
  9. package/.docs/organized/changelogs/%40mastra%2Fcloud.md +10 -10
  10. package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +10 -10
  11. package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +11 -11
  12. package/.docs/organized/changelogs/%40mastra%2Fcore.md +70 -70
  13. package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +10 -10
  14. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +25 -25
  15. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +23 -23
  16. package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +24 -24
  17. package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +24 -24
  18. package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +30 -30
  19. package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +10 -10
  20. package/.docs/organized/changelogs/%40mastra%2Fevals.md +15 -15
  21. package/.docs/organized/changelogs/%40mastra%2Flance.md +11 -11
  22. package/.docs/organized/changelogs/%40mastra%2Flibsql.md +10 -10
  23. package/.docs/organized/changelogs/%40mastra%2Floggers.md +10 -10
  24. package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +17 -17
  25. package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +10 -10
  26. package/.docs/organized/changelogs/%40mastra%2Fmcp.md +10 -10
  27. package/.docs/organized/changelogs/%40mastra%2Fmemory.md +18 -18
  28. package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +10 -10
  29. package/.docs/organized/changelogs/%40mastra%2Fmssql.md +10 -10
  30. package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +11 -11
  31. package/.docs/organized/changelogs/%40mastra%2Fpg.md +16 -16
  32. package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +10 -10
  33. package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +50 -50
  34. package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +11 -11
  35. package/.docs/organized/changelogs/%40mastra%2Frag.md +13 -13
  36. package/.docs/organized/changelogs/%40mastra%2Freact-hooks.md +8 -0
  37. package/.docs/organized/changelogs/%40mastra%2Fs3vectors.md +9 -0
  38. package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +6 -0
  39. package/.docs/organized/changelogs/%40mastra%2Fserver.md +36 -36
  40. package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +10 -10
  41. package/.docs/organized/changelogs/%40mastra%2Fupstash.md +13 -13
  42. package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +10 -10
  43. package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +10 -10
  44. package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +10 -10
  45. package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +10 -10
  46. package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +10 -10
  47. package/.docs/organized/changelogs/%40mastra%2Fvoice-gladia.md +9 -0
  48. package/.docs/organized/changelogs/%40mastra%2Fvoice-google-gemini-live.md +9 -0
  49. package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +11 -11
  50. package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +11 -11
  51. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +11 -11
  52. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +11 -11
  53. package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +10 -10
  54. package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +10 -10
  55. package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +10 -10
  56. package/.docs/organized/changelogs/create-mastra.md +22 -22
  57. package/.docs/organized/changelogs/mastra.md +46 -46
  58. package/.docs/raw/index.mdx +1 -0
  59. package/.docs/raw/observability/ai-tracing/exporters/braintrust.mdx +81 -0
  60. package/.docs/raw/observability/ai-tracing/exporters/cloud.mdx +120 -0
  61. package/.docs/raw/observability/ai-tracing/exporters/default.mdx +167 -0
  62. package/.docs/raw/observability/ai-tracing/exporters/langfuse.mdx +121 -0
  63. package/.docs/raw/observability/ai-tracing/overview.mdx +565 -0
  64. package/.docs/raw/observability/ai-tracing/processors/sensitive-data-filter.mdx +274 -0
  65. package/.docs/raw/observability/{tracing.mdx → otel-tracing.mdx} +2 -2
  66. package/.docs/raw/observability/overview.mdx +66 -0
  67. package/.docs/raw/reference/agents/generate.mdx +39 -1
  68. package/.docs/raw/reference/agents/generateVNext.mdx +34 -2
  69. package/.docs/raw/reference/agents/network.mdx +34 -2
  70. package/.docs/raw/reference/observability/ai-tracing/ai-tracing.mdx +181 -0
  71. package/.docs/raw/reference/observability/ai-tracing/configuration.mdx +233 -0
  72. package/.docs/raw/reference/observability/ai-tracing/exporters/braintrust.mdx +112 -0
  73. package/.docs/raw/reference/observability/ai-tracing/exporters/cloud-exporter.mdx +176 -0
  74. package/.docs/raw/reference/observability/ai-tracing/exporters/console-exporter.mdx +148 -0
  75. package/.docs/raw/reference/observability/ai-tracing/exporters/default-exporter.mdx +196 -0
  76. package/.docs/raw/reference/observability/ai-tracing/exporters/langfuse.mdx +116 -0
  77. package/.docs/raw/reference/observability/ai-tracing/interfaces.mdx +651 -0
  78. package/.docs/raw/reference/observability/ai-tracing/processors/sensitive-data-filter.mdx +178 -0
  79. package/.docs/raw/reference/observability/ai-tracing/span.mdx +371 -0
  80. package/.docs/raw/reference/observability/otel-tracing/providers/index.mdx +22 -0
  81. package/.docs/raw/reference/streaming/agents/stream.mdx +39 -1
  82. package/.docs/raw/reference/streaming/agents/streamVNext.mdx +34 -2
  83. package/.docs/raw/reference/streaming/workflows/stream.mdx +38 -0
  84. package/.docs/raw/reference/streaming/workflows/streamVNext.mdx +38 -0
  85. package/.docs/raw/reference/tools/create-tool.mdx +34 -1
  86. package/.docs/raw/reference/workflows/run-methods/resume.mdx +38 -0
  87. package/.docs/raw/reference/workflows/run-methods/start.mdx +38 -0
  88. package/CHANGELOG.md +7 -0
  89. package/package.json +3 -3
  90. package/.docs/raw/observability/ai-tracing.mdx +0 -597
  91. package/.docs/raw/reference/observability/providers/index.mdx +0 -20
  92. /package/.docs/raw/reference/observability/{logger.mdx → logging/pino-logger.mdx} +0 -0
  93. /package/.docs/raw/reference/observability/{otel-config.mdx → otel-tracing/otel-config.mdx} +0 -0
  94. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/arize-ax.mdx +0 -0
  95. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/arize-phoenix.mdx +0 -0
  96. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/braintrust.mdx +0 -0
  97. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/dash0.mdx +0 -0
  98. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/keywordsai.mdx +0 -0
  99. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/laminar.mdx +0 -0
  100. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/langfuse.mdx +0 -0
  101. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/langsmith.mdx +0 -0
  102. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/langwatch.mdx +0 -0
  103. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/new-relic.mdx +0 -0
  104. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/signoz.mdx +0 -0
  105. /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/traceloop.mdx +0 -0
@@ -0,0 +1,651 @@
1
+ ---
2
+ title: "Interfaces | AI Tracing | Reference"
3
+ description: AI Tracing type definitions and interfaces
4
+ ---
5
+
6
+ import { PropertiesTable } from "@/components/properties-table";
7
+
8
+ # Interfaces
9
+
10
+ ## Core Interfaces
11
+
12
+ ### AITracing
13
+
14
+ Primary interface for AI Tracing.
15
+
16
+ ```typescript
17
+ interface AITracing {
18
+ /** Get current configuration */
19
+ getConfig(): Readonly<Required<TracingConfig>>;
20
+
21
+ /** Get all exporters */
22
+ getExporters(): readonly AITracingExporter[];
23
+
24
+ /** Get all processors */
25
+ getProcessors(): readonly AISpanProcessor[];
26
+
27
+ /** Get the logger instance (for exporters and other components) */
28
+ getLogger(): IMastraLogger;
29
+
30
+ /** Start a new span of a specific AISpanType */
31
+ startSpan<TType extends AISpanType>(options: StartSpanOptions<TType>): AISpan<TType>;
32
+
33
+ /** Shutdown AI tracing and clean up resources */
34
+ shutdown(): Promise<void>;
35
+ }
36
+ ```
37
+
38
+ ### AISpanTypeMap
39
+
40
+ Mapping of span types to their corresponding attribute interfaces.
41
+
42
+ ```typescript
43
+ interface AISpanTypeMap {
44
+ AGENT_RUN: AgentRunAttributes;
45
+ WORKFLOW_RUN: WorkflowRunAttributes;
46
+ LLM_GENERATION: LLMGenerationAttributes;
47
+ LLM_CHUNK: LLMChunkAttributes;
48
+ TOOL_CALL: ToolCallAttributes;
49
+ MCP_TOOL_CALL: MCPToolCallAttributes;
50
+ WORKFLOW_STEP: WorkflowStepAttributes;
51
+ WORKFLOW_CONDITIONAL: WorkflowConditionalAttributes;
52
+ WORKFLOW_CONDITIONAL_EVAL: WorkflowConditionalEvalAttributes;
53
+ WORKFLOW_PARALLEL: WorkflowParallelAttributes;
54
+ WORKFLOW_LOOP: WorkflowLoopAttributes;
55
+ WORKFLOW_SLEEP: WorkflowSleepAttributes;
56
+ WORKFLOW_WAIT_EVENT: WorkflowWaitEventAttributes;
57
+ GENERIC: AIBaseAttributes;
58
+ }
59
+ ```
60
+
61
+ This mapping defines which attribute interface is used for each span type when creating or processing spans.
62
+
63
+ ### AISpan
64
+
65
+ AI Span interface, used internally for tracing.
66
+
67
+ ```typescript
68
+ interface AISpan<TType extends AISpanType> {
69
+ readonly id: string;
70
+ readonly traceId: string;
71
+ readonly type: TType;
72
+ readonly name: string;
73
+
74
+ /** Is an internal span? (spans internal to the operation of mastra) */
75
+ isInternal: boolean;
76
+
77
+ /** Parent span reference (undefined for root spans) */
78
+ parent?: AnyAISpan;
79
+
80
+ /** Pointer to the AITracing instance */
81
+ aiTracing: AITracing;
82
+
83
+ attributes?: AISpanTypeMap[TType];
84
+ metadata?: Record<string, any>;
85
+ input?: any;
86
+ output?: any;
87
+ errorInfo?: any;
88
+
89
+ /** End the span */
90
+ end(options?: EndSpanOptions<TType>): void;
91
+
92
+ /** Record an error for the span, optionally end the span as well */
93
+ error(options: ErrorSpanOptions<TType>): void;
94
+
95
+ /** Update span attributes */
96
+ update(options: UpdateSpanOptions<TType>): void;
97
+
98
+ /** Create child span - can be any span type independent of parent */
99
+ createChildSpan<TChildType extends AISpanType>(
100
+ options: ChildSpanOptions<TChildType>
101
+ ): AISpan<TChildType>;
102
+
103
+ /** Create event span - can be any span type independent of parent */
104
+ createEventSpan<TChildType extends AISpanType>(
105
+ options: ChildEventOptions<TChildType>
106
+ ): AISpan<TChildType>;
107
+
108
+ /** Returns TRUE if the span is the root span of a trace */
109
+ get isRootSpan(): boolean;
110
+
111
+ /** Returns TRUE if the span is a valid span (not a NO-OP Span) */
112
+ get isValid(): boolean;
113
+ }
114
+ ```
115
+
116
+ ### AITracingExporter
117
+
118
+ Interface for tracing exporters.
119
+
120
+ ```typescript
121
+ interface AITracingExporter {
122
+ /** Exporter name */
123
+ name: string;
124
+
125
+ /** Initialize exporter (called after all dependencies are ready) */
126
+ init?(): void;
127
+
128
+ /** Export tracing events */
129
+ exportEvent(event: AITracingEvent): Promise<void>;
130
+
131
+ /** Shutdown exporter */
132
+ shutdown(): Promise<void>;
133
+ }
134
+ ```
135
+
136
+ ### AISpanProcessor
137
+
138
+ Interface for span processors.
139
+
140
+ ```typescript
141
+ interface AISpanProcessor {
142
+ /** Processor name */
143
+ name: string;
144
+
145
+ /** Process span before export */
146
+ process(span?: AnyAISpan): AnyAISpan | undefined;
147
+
148
+ /** Shutdown processor */
149
+ shutdown(): Promise<void>;
150
+ }
151
+ ```
152
+
153
+ ## Span Types
154
+
155
+ ### AISpanType
156
+
157
+ AI-specific span types with their associated metadata.
158
+
159
+ ```typescript
160
+ enum AISpanType {
161
+ /** Agent run - root span for agent processes */
162
+ AGENT_RUN = 'agent_run',
163
+
164
+ /** Generic span for custom operations */
165
+ GENERIC = 'generic',
166
+
167
+ /** LLM generation with model calls, token usage, prompts, completions */
168
+ LLM_GENERATION = 'llm_generation',
169
+
170
+ /** Individual LLM streaming chunk/event */
171
+ LLM_CHUNK = 'llm_chunk',
172
+
173
+ /** MCP (Model Context Protocol) tool execution */
174
+ MCP_TOOL_CALL = 'mcp_tool_call',
175
+
176
+ /** Function/tool execution with inputs, outputs, errors */
177
+ TOOL_CALL = 'tool_call',
178
+
179
+ /** Workflow run - root span for workflow processes */
180
+ WORKFLOW_RUN = 'workflow_run',
181
+
182
+ /** Workflow step execution with step status, data flow */
183
+ WORKFLOW_STEP = 'workflow_step',
184
+
185
+ /** Workflow conditional execution with condition evaluation */
186
+ WORKFLOW_CONDITIONAL = 'workflow_conditional',
187
+
188
+ /** Individual condition evaluation within conditional */
189
+ WORKFLOW_CONDITIONAL_EVAL = 'workflow_conditional_eval',
190
+
191
+ /** Workflow parallel execution */
192
+ WORKFLOW_PARALLEL = 'workflow_parallel',
193
+
194
+ /** Workflow loop execution */
195
+ WORKFLOW_LOOP = 'workflow_loop',
196
+
197
+ /** Workflow sleep operation */
198
+ WORKFLOW_SLEEP = 'workflow_sleep',
199
+
200
+ /** Workflow wait for event operation */
201
+ WORKFLOW_WAIT_EVENT = 'workflow_wait_event',
202
+ }
203
+ ```
204
+
205
+ ### AnyAISpan
206
+
207
+ Union type for cases that need to handle any span.
208
+
209
+ ```typescript
210
+ type AnyAISpan = AISpan<keyof AISpanTypeMap>;
211
+ ```
212
+
213
+ ## Span Attributes
214
+
215
+ ### AgentRunAttributes
216
+
217
+ Agent Run attributes.
218
+
219
+ ```typescript
220
+ interface AgentRunAttributes {
221
+ /** Agent identifier */
222
+ agentId: string;
223
+
224
+ /** Agent Instructions */
225
+ instructions?: string;
226
+
227
+ /** Agent Prompt */
228
+ prompt?: string;
229
+
230
+ /** Available tools for this execution */
231
+ availableTools?: string[];
232
+
233
+ /** Maximum steps allowed */
234
+ maxSteps?: number;
235
+ }
236
+ ```
237
+
238
+ ### LLMGenerationAttributes
239
+
240
+ LLM Generation attributes.
241
+
242
+ ```typescript
243
+ interface LLMGenerationAttributes {
244
+ /** Model name (e.g., 'gpt-4', 'claude-3') */
245
+ model?: string;
246
+
247
+ /** Model provider (e.g., 'openai', 'anthropic') */
248
+ provider?: string;
249
+
250
+ /** Type of result/output this LLM call produced */
251
+ resultType?: 'tool_selection' | 'response_generation' | 'reasoning' | 'planning';
252
+
253
+ /** Token usage statistics */
254
+ usage?: {
255
+ promptTokens?: number;
256
+ completionTokens?: number;
257
+ totalTokens?: number;
258
+ promptCacheHitTokens?: number;
259
+ promptCacheMissTokens?: number;
260
+ };
261
+
262
+ /** Model parameters */
263
+ parameters?: {
264
+ maxOutputTokens?: number;
265
+ temperature?: number;
266
+ topP?: number;
267
+ topK?: number;
268
+ presencePenalty?: number;
269
+ frequencyPenalty?: number;
270
+ stopSequences?: string[];
271
+ seed?: number;
272
+ maxRetries?: number;
273
+ };
274
+
275
+ /** Whether this was a streaming response */
276
+ streaming?: boolean;
277
+
278
+ /** Reason the generation finished */
279
+ finishReason?: string;
280
+ }
281
+ ```
282
+
283
+ ### LLMChunkAttributes
284
+
285
+ LLM Chunk attributes - for individual streaming chunks/events.
286
+
287
+ ```typescript
288
+ interface LLMChunkAttributes {
289
+ /** Type of chunk (text-delta, reasoning-delta, tool-call, etc.) */
290
+ chunkType?: string;
291
+
292
+ /** Sequence number of this chunk in the stream */
293
+ sequenceNumber?: number;
294
+ }
295
+ ```
296
+
297
+ ### ToolCallAttributes
298
+
299
+ Tool Call attributes.
300
+
301
+ ```typescript
302
+ interface ToolCallAttributes {
303
+ toolId?: string;
304
+ toolType?: string;
305
+ toolDescription?: string;
306
+ success?: boolean;
307
+ }
308
+ ```
309
+
310
+ ### MCPToolCallAttributes
311
+
312
+ MCP Tool Call attributes.
313
+
314
+ ```typescript
315
+ interface MCPToolCallAttributes {
316
+ /** Id of the MCP tool/function */
317
+ toolId: string;
318
+
319
+ /** MCP server identifier */
320
+ mcpServer: string;
321
+
322
+ /** MCP server version */
323
+ serverVersion?: string;
324
+
325
+ /** Whether tool execution was successful */
326
+ success?: boolean;
327
+ }
328
+ ```
329
+
330
+ ### WorkflowRunAttributes
331
+
332
+ Workflow Run attributes.
333
+
334
+ ```typescript
335
+ interface WorkflowRunAttributes {
336
+ /** Workflow identifier */
337
+ workflowId: string;
338
+
339
+ /** Workflow version */
340
+ workflowVersion?: string;
341
+
342
+ /** Workflow run ID */
343
+ runId?: string;
344
+
345
+ /** Final workflow execution status */
346
+ status?: WorkflowRunStatus;
347
+ }
348
+ ```
349
+
350
+ ### WorkflowStepAttributes
351
+
352
+ Workflow Step attributes.
353
+
354
+ ```typescript
355
+ interface WorkflowStepAttributes {
356
+ /** Step identifier */
357
+ stepId?: string;
358
+
359
+ /** Step type */
360
+ stepType?: string;
361
+
362
+ /** Step status */
363
+ status?: WorkflowStepStatus;
364
+
365
+ /** Step execution order */
366
+ stepNumber?: number;
367
+
368
+ /** Result store key */
369
+ resultKey?: string;
370
+ }
371
+ ```
372
+
373
+ ## Options Types
374
+
375
+ ### StartSpanOptions
376
+
377
+ Options for starting new spans.
378
+
379
+ ```typescript
380
+ interface StartSpanOptions<TType extends AISpanType> {
381
+ /** Span type */
382
+ type: TType;
383
+
384
+ /** Span name */
385
+ name: string;
386
+
387
+ /** Span attributes */
388
+ attributes?: AISpanTypeMap[TType];
389
+
390
+ /** Span metadata */
391
+ metadata?: Record<string, any>;
392
+
393
+ /** Input data */
394
+ input?: any;
395
+
396
+ /** Parent span */
397
+ parent?: AnyAISpan;
398
+
399
+ /** Policy-level tracing configuration */
400
+ tracingPolicy?: TracingPolicy;
401
+
402
+ /** Options passed when using a custom sampler strategy */
403
+ customSamplerOptions?: CustomSamplerOptions;
404
+ }
405
+ ```
406
+
407
+ ### UpdateSpanOptions
408
+
409
+ Options for updating spans.
410
+
411
+ ```typescript
412
+ interface UpdateSpanOptions<TType extends AISpanType> {
413
+ /** Span attributes */
414
+ attributes?: Partial<AISpanTypeMap[TType]>;
415
+
416
+ /** Span metadata */
417
+ metadata?: Record<string, any>;
418
+
419
+ /** Input data */
420
+ input?: any;
421
+
422
+ /** Output data */
423
+ output?: any;
424
+ }
425
+ ```
426
+
427
+ ### EndSpanOptions
428
+
429
+ Options for ending spans.
430
+
431
+ ```typescript
432
+ interface EndSpanOptions<TType extends AISpanType> {
433
+ /** Output data */
434
+ output?: any;
435
+
436
+ /** Span metadata */
437
+ metadata?: Record<string, any>;
438
+
439
+ /** Span attributes */
440
+ attributes?: Partial<AISpanTypeMap[TType]>;
441
+ }
442
+ ```
443
+
444
+ ### ErrorSpanOptions
445
+
446
+ Options for recording span errors.
447
+
448
+ ```typescript
449
+ interface ErrorSpanOptions<TType extends AISpanType> {
450
+ /** The error associated with the issue */
451
+ error: Error;
452
+
453
+ /** End the span when true */
454
+ endSpan?: boolean;
455
+
456
+ /** Span metadata */
457
+ metadata?: Record<string, any>;
458
+
459
+ /** Span attributes */
460
+ attributes?: Partial<AISpanTypeMap[TType]>;
461
+ }
462
+ ```
463
+
464
+ ## Context Types
465
+
466
+ ### TracingContext
467
+
468
+ Context for AI tracing that flows through workflow and agent execution.
469
+
470
+ ```typescript
471
+ interface TracingContext {
472
+ /** Current AI span for creating child spans and adding metadata */
473
+ currentSpan?: AnyAISpan;
474
+ }
475
+ ```
476
+
477
+ ### TracingProperties
478
+
479
+ Properties returned to the user for working with traces externally.
480
+
481
+ ```typescript
482
+ type TracingProperties = {
483
+ /** Trace ID used on the execution (if the execution was traced) */
484
+ traceId?: string;
485
+ };
486
+ ```
487
+
488
+ ### TracingOptions
489
+
490
+ Options passed when starting a new agent or workflow execution.
491
+
492
+ ```typescript
493
+ interface TracingOptions {
494
+ /** Metadata to add to the root trace span */
495
+ metadata?: Record<string, any>;
496
+ }
497
+ ```
498
+
499
+ ### TracingPolicy
500
+
501
+ Policy-level tracing configuration applied when creating a workflow or agent.
502
+
503
+ ```typescript
504
+ interface TracingPolicy {
505
+ /**
506
+ * Bitwise options to set different types of spans as Internal in
507
+ * a workflow or agent execution. Internal spans are hidden by
508
+ * default in exported traces.
509
+ */
510
+ internal?: InternalSpans;
511
+ }
512
+ ```
513
+
514
+ ## Configuration Types
515
+
516
+ ### TracingConfig
517
+
518
+ Configuration for a single tracing instance.
519
+
520
+ ```typescript
521
+ interface TracingConfig {
522
+ /** Unique identifier for this config in the ai tracing registry */
523
+ name: string;
524
+
525
+ /** Service name for tracing */
526
+ serviceName: string;
527
+
528
+ /** Sampling strategy - controls whether tracing is collected (defaults to ALWAYS) */
529
+ sampling?: SamplingStrategy;
530
+
531
+ /** Custom exporters */
532
+ exporters?: AITracingExporter[];
533
+
534
+ /** Custom processors */
535
+ processors?: AISpanProcessor[];
536
+
537
+ /** Set to true if you want to see spans internal to the operation of mastra */
538
+ includeInternalSpans?: boolean;
539
+ }
540
+ ```
541
+
542
+ ### ObservabilityRegistryConfig
543
+
544
+ Complete AI Tracing registry configuration.
545
+
546
+ ```typescript
547
+ interface ObservabilityRegistryConfig {
548
+ /** Enables default exporters, with sampling: always, and sensitive data filtering */
549
+ default?: {
550
+ enabled?: boolean;
551
+ };
552
+
553
+ /** Map of tracing instance names to their configurations or pre-instantiated instances */
554
+ configs?: Record<string, Omit<TracingConfig, 'name'> | AITracing>;
555
+
556
+ /** Optional selector function to choose which tracing instance to use */
557
+ configSelector?: ConfigSelector;
558
+ }
559
+ ```
560
+
561
+ ## Sampling Types
562
+
563
+ ### SamplingStrategy
564
+
565
+ Sampling strategy configuration.
566
+
567
+ ```typescript
568
+ type SamplingStrategy =
569
+ | { type: 'always' }
570
+ | { type: 'never' }
571
+ | { type: 'ratio'; probability: number }
572
+ | { type: 'custom'; sampler: (options?: CustomSamplerOptions) => boolean };
573
+ ```
574
+
575
+ ### CustomSamplerOptions
576
+
577
+ Options passed when using a custom sampler strategy.
578
+
579
+ ```typescript
580
+ interface CustomSamplerOptions {
581
+ runtimeContext?: RuntimeContext;
582
+ metadata?: Record<string, any>;
583
+ }
584
+ ```
585
+
586
+ ## Config Selector Types
587
+
588
+ ### ConfigSelector
589
+
590
+ Function to select which AI tracing instance to use for a given span.
591
+
592
+ ```typescript
593
+ type ConfigSelector = (
594
+ options: ConfigSelectorOptions,
595
+ availableConfigs: ReadonlyMap<string, AITracing>
596
+ ) => string | undefined;
597
+ ```
598
+
599
+ ### ConfigSelectorOptions
600
+
601
+ Options passed when using a custom tracing config selector.
602
+
603
+ ```typescript
604
+ interface ConfigSelectorOptions {
605
+ /** Runtime context */
606
+ runtimeContext?: RuntimeContext;
607
+ }
608
+ ```
609
+
610
+ ## Internal Spans
611
+
612
+ ### InternalSpans
613
+
614
+ Bitwise options to set different types of spans as internal in a workflow or agent execution.
615
+
616
+ ```typescript
617
+ enum InternalSpans {
618
+ /** No spans are marked internal */
619
+ NONE = 0,
620
+
621
+ /** Workflow spans are marked internal */
622
+ WORKFLOW = 1 << 0,
623
+
624
+ /** Agent spans are marked internal */
625
+ AGENT = 1 << 1,
626
+
627
+ /** Tool spans are marked internal */
628
+ TOOL = 1 << 2,
629
+
630
+ /** LLM spans are marked internal */
631
+ LLM = 1 << 3,
632
+
633
+ /** All spans are marked internal */
634
+ ALL = (1 << 4) - 1,
635
+ }
636
+ ```
637
+
638
+ ## See Also
639
+
640
+ ### Documentation
641
+ - [AI Tracing Overview](/docs/observability/ai-tracing/overview) - Complete guide to AI tracing
642
+ - [Creating Child Spans](/docs/observability/ai-tracing/overview#creating-child-spans) - Working with span hierarchies
643
+ - [Adding Custom Metadata](/docs/observability/ai-tracing/overview#adding-custom-metadata) - Enriching traces
644
+
645
+ ### Reference
646
+ - [Configuration](/reference/observability/ai-tracing/configuration) - Registry and configuration
647
+ - [AITracing Classes](/reference/observability/ai-tracing/ai-tracing) - Core implementations
648
+ - [Span Reference](/reference/observability/ai-tracing/span) - Span lifecycle methods
649
+
650
+ ### Examples
651
+ - [Basic AI Tracing](/examples/observability/basic-ai-tracing) - Implementation example