@mastra/mcp-docs-server 0.13.24 → 0.13.25-alpha.1
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/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +8 -8
- package/.docs/organized/changelogs/%40internal%2Ftypes-builder.md +2 -0
- package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +24 -1
- package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +22 -0
- package/.docs/organized/changelogs/%40mastra%2Fastra.md +19 -19
- package/.docs/organized/changelogs/%40mastra%2Fchroma.md +19 -19
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +21 -21
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +46 -46
- package/.docs/organized/changelogs/%40mastra%2Fcloud.md +19 -19
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +21 -21
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +21 -21
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +104 -104
- package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +19 -19
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +40 -40
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +33 -33
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +34 -34
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +34 -34
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +59 -59
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +21 -21
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +24 -24
- package/.docs/organized/changelogs/%40mastra%2Flance.md +21 -21
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +29 -29
- package/.docs/organized/changelogs/%40mastra%2Floggers.md +19 -19
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +25 -25
- package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +19 -19
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +22 -22
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +27 -27
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +21 -21
- package/.docs/organized/changelogs/%40mastra%2Fmssql.md +21 -21
- package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +19 -19
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +33 -33
- package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +19 -19
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +73 -73
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Frag.md +22 -22
- package/.docs/organized/changelogs/%40mastra%2Freact.md +17 -0
- package/.docs/organized/changelogs/%40mastra%2Fs3vectors.md +18 -0
- package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +6 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +51 -51
- package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +19 -19
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +24 -24
- package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +19 -19
- package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +19 -19
- package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +19 -19
- package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +19 -19
- package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +19 -19
- package/.docs/organized/changelogs/%40mastra%2Fvoice-gladia.md +20 -3
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google-gemini-live.md +18 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +21 -21
- package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +21 -21
- package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +19 -19
- package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +19 -19
- package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +19 -19
- package/.docs/organized/changelogs/create-mastra.md +32 -32
- package/.docs/organized/changelogs/mastra.md +64 -64
- package/.docs/organized/code-examples/agent.md +0 -4
- package/.docs/organized/code-examples/ai-elements.md +47 -0
- package/.docs/organized/code-examples/heads-up-game.md +5 -5
- package/.docs/raw/auth/clerk.mdx +3 -3
- package/.docs/raw/index.mdx +1 -0
- package/.docs/raw/observability/ai-tracing/exporters/braintrust.mdx +81 -0
- package/.docs/raw/observability/ai-tracing/exporters/cloud.mdx +120 -0
- package/.docs/raw/observability/ai-tracing/exporters/default.mdx +168 -0
- package/.docs/raw/observability/ai-tracing/exporters/langfuse.mdx +121 -0
- package/.docs/raw/observability/ai-tracing/exporters/langsmith.mdx +88 -0
- package/.docs/raw/observability/ai-tracing/exporters/otel.mdx +250 -0
- package/.docs/raw/observability/ai-tracing/overview.mdx +565 -0
- package/.docs/raw/observability/ai-tracing/processors/sensitive-data-filter.mdx +274 -0
- package/.docs/raw/observability/{tracing.mdx → otel-tracing.mdx} +2 -2
- package/.docs/raw/observability/overview.mdx +66 -0
- package/.docs/raw/reference/agents/generate.mdx +39 -1
- package/.docs/raw/reference/agents/generateVNext.mdx +34 -2
- package/.docs/raw/reference/agents/network.mdx +35 -3
- package/.docs/raw/reference/auth/clerk.mdx +1 -1
- package/.docs/raw/reference/client-js/agents.mdx +4 -13
- package/.docs/raw/reference/client-js/mastra-client.mdx +10 -0
- package/.docs/raw/reference/client-js/observability.mdx +76 -0
- package/.docs/raw/reference/core/getScorer.mdx +75 -0
- package/.docs/raw/reference/core/getScorerByName.mdx +75 -0
- package/.docs/raw/reference/core/getScorers.mdx +42 -0
- package/.docs/raw/reference/core/mastra-class.mdx +7 -0
- package/.docs/raw/reference/observability/ai-tracing/ai-tracing.mdx +182 -0
- package/.docs/raw/reference/observability/ai-tracing/configuration.mdx +234 -0
- package/.docs/raw/reference/observability/ai-tracing/exporters/braintrust.mdx +112 -0
- package/.docs/raw/reference/observability/ai-tracing/exporters/cloud-exporter.mdx +176 -0
- package/.docs/raw/reference/observability/ai-tracing/exporters/console-exporter.mdx +148 -0
- package/.docs/raw/reference/observability/ai-tracing/exporters/default-exporter.mdx +196 -0
- package/.docs/raw/reference/observability/ai-tracing/exporters/langfuse.mdx +116 -0
- package/.docs/raw/reference/observability/ai-tracing/exporters/langsmith.mdx +112 -0
- package/.docs/raw/reference/observability/ai-tracing/exporters/otel.mdx +355 -0
- package/.docs/raw/reference/observability/ai-tracing/interfaces.mdx +651 -0
- package/.docs/raw/reference/observability/ai-tracing/processors/sensitive-data-filter.mdx +178 -0
- package/.docs/raw/reference/observability/ai-tracing/span.mdx +371 -0
- package/.docs/raw/reference/observability/{logger.mdx → logging/pino-logger.mdx} +1 -1
- package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/index.mdx +6 -4
- package/.docs/raw/reference/scorers/create-scorer.mdx +59 -9
- package/.docs/raw/reference/scorers/mastra-scorer.mdx +6 -0
- package/.docs/raw/reference/scorers/run-experiment.mdx +216 -0
- package/.docs/raw/reference/streaming/ChunkType.mdx +3 -2
- package/.docs/raw/reference/streaming/agents/MastraModelOutput.mdx +1 -1
- package/.docs/raw/reference/streaming/agents/stream.mdx +41 -3
- package/.docs/raw/reference/streaming/agents/streamVNext.mdx +34 -2
- package/.docs/raw/reference/streaming/workflows/resumeStreamVNext.mdx +17 -1
- package/.docs/raw/reference/streaming/workflows/stream.mdx +39 -1
- package/.docs/raw/reference/streaming/workflows/streamVNext.mdx +39 -1
- package/.docs/raw/reference/tools/create-tool.mdx +34 -1
- package/.docs/raw/reference/workflows/run-methods/resume.mdx +38 -0
- package/.docs/raw/reference/workflows/run-methods/start.mdx +38 -0
- package/.docs/raw/scorers/custom-scorers.mdx +16 -1
- package/.docs/raw/scorers/overview.mdx +28 -0
- package/CHANGELOG.md +15 -0
- package/package.json +6 -6
- package/.docs/raw/observability/ai-tracing.mdx +0 -597
- /package/.docs/raw/reference/observability/{otel-config.mdx → otel-tracing/otel-config.mdx} +0 -0
- /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/arize-ax.mdx +0 -0
- /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/arize-phoenix.mdx +0 -0
- /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/braintrust.mdx +0 -0
- /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/dash0.mdx +0 -0
- /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/keywordsai.mdx +0 -0
- /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/laminar.mdx +0 -0
- /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/langfuse.mdx +0 -0
- /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/langsmith.mdx +0 -0
- /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/langwatch.mdx +0 -0
- /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/new-relic.mdx +0 -0
- /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/signoz.mdx +0 -0
- /package/.docs/raw/reference/observability/{providers → otel-tracing/providers}/traceloop.mdx +0 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: getScorer() | Core | Mastra Docs"
|
|
3
|
+
description: "Documentation for the `getScorer()` method in Mastra, which retrieves a specific scorer by its registration key."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# getScorer()
|
|
7
|
+
|
|
8
|
+
The `getScorer()` method retrieves a specific scorer that was registered with the Mastra instance using its registration key. This method provides type-safe access to scorers and throws an error if the requested scorer is not found.
|
|
9
|
+
|
|
10
|
+
## Usage Example
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
import { mastra } from './mastra';
|
|
14
|
+
|
|
15
|
+
// Get a specific scorer by key
|
|
16
|
+
const relevancyScorer = mastra.getScorer('relevancyScorer');
|
|
17
|
+
|
|
18
|
+
const weatherAgent = mastra.getAgent('weatherAgent')
|
|
19
|
+
|
|
20
|
+
// Use the scorer to evaluate an AI output
|
|
21
|
+
await weatherAgent.generate('What is the weather in Rome', {
|
|
22
|
+
scorers: {
|
|
23
|
+
answerRelevancy: {
|
|
24
|
+
scorer: relevancyScorer,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Parameters
|
|
31
|
+
|
|
32
|
+
<PropertiesTable
|
|
33
|
+
content={[
|
|
34
|
+
{
|
|
35
|
+
name: "key",
|
|
36
|
+
type: "string",
|
|
37
|
+
description: "The registration key of the scorer to retrieve. This should match a key used when registering scorers in the Mastra constructor.",
|
|
38
|
+
isOptional: false,
|
|
39
|
+
},
|
|
40
|
+
]}
|
|
41
|
+
/>
|
|
42
|
+
|
|
43
|
+
## Returns
|
|
44
|
+
|
|
45
|
+
<PropertiesTable
|
|
46
|
+
content={[
|
|
47
|
+
{
|
|
48
|
+
name: "scorer",
|
|
49
|
+
type: "MastraScorer",
|
|
50
|
+
description: "The MastraScorer instance associated with the provided key.",
|
|
51
|
+
},
|
|
52
|
+
]}
|
|
53
|
+
/>
|
|
54
|
+
|
|
55
|
+
## Error Handling
|
|
56
|
+
|
|
57
|
+
This method throws a `MastraError` if:
|
|
58
|
+
- The scorer with the specified key is not found
|
|
59
|
+
- No scorers are registered with the Mastra instance
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
try {
|
|
63
|
+
const scorer = mastra.getScorer('nonExistentScorer');
|
|
64
|
+
} catch (error) {
|
|
65
|
+
if (error.id === 'MASTRA_GET_SCORER_NOT_FOUND') {
|
|
66
|
+
console.log('Scorer not found, using default evaluation');
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Related
|
|
72
|
+
|
|
73
|
+
- [getScorers()](../../reference/core/getScorers.mdx) - Get all registered scorers
|
|
74
|
+
- [getScorerByName()](../../reference/core/getScorerByName.mdx) - Get a scorer by its name property
|
|
75
|
+
- [Custom Scorers](../../docs/scorers/custom-scorers.mdx) - Learn how to create custom scorers
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: getScorerByName() | Core | Mastra Docs"
|
|
3
|
+
description: "Documentation for the `getScorerByName()` method in Mastra, which retrieves a scorer by its name property rather than registration key."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# getScorerByName()
|
|
7
|
+
|
|
8
|
+
The `getScorerByName()` method retrieves a scorer by searching for its `name` property rather than the registration key. This is useful when you know the scorer's display name but not necessarily how it was registered in the Mastra instance.
|
|
9
|
+
|
|
10
|
+
## Usage Example
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
import { mastra } from './mastra';
|
|
14
|
+
|
|
15
|
+
// Get a scorer by its name property
|
|
16
|
+
const relevancyScorer = mastra.getScorerByName('Answer Relevancy');
|
|
17
|
+
|
|
18
|
+
const weatherAgent = mastra.getAgent('weatherAgent')
|
|
19
|
+
|
|
20
|
+
// Use the scorer to evaluate an AI output
|
|
21
|
+
await weatherAgent.generate('What is the weather in Rome', {
|
|
22
|
+
scorers: {
|
|
23
|
+
answerRelevancy: {
|
|
24
|
+
scorer: relevancyScorer,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Parameters
|
|
31
|
+
|
|
32
|
+
<PropertiesTable
|
|
33
|
+
content={[
|
|
34
|
+
{
|
|
35
|
+
name: "name",
|
|
36
|
+
type: "string",
|
|
37
|
+
description: "The name property of the scorer to retrieve. This should match the 'name' field specified when creating the scorer with createScorer().",
|
|
38
|
+
isOptional: false,
|
|
39
|
+
},
|
|
40
|
+
]}
|
|
41
|
+
/>
|
|
42
|
+
|
|
43
|
+
## Returns
|
|
44
|
+
|
|
45
|
+
<PropertiesTable
|
|
46
|
+
content={[
|
|
47
|
+
{
|
|
48
|
+
name: "scorer",
|
|
49
|
+
type: "MastraScorer",
|
|
50
|
+
description: "The MastraScorer instance that has the matching name property.",
|
|
51
|
+
},
|
|
52
|
+
]}
|
|
53
|
+
/>
|
|
54
|
+
|
|
55
|
+
## Error Handling
|
|
56
|
+
|
|
57
|
+
This method throws a `MastraError` if:
|
|
58
|
+
- No scorer with the specified name is found
|
|
59
|
+
- No scorers are registered with the Mastra instance
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
try {
|
|
63
|
+
const scorer = mastra.getScorerByName('Non-existent Scorer');
|
|
64
|
+
} catch (error) {
|
|
65
|
+
if (error.id === 'MASTRA_GET_SCORER_BY_NAME_NOT_FOUND') {
|
|
66
|
+
console.log('Scorer with that name not found');
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Related
|
|
72
|
+
|
|
73
|
+
- [getScorer()](../../reference/core/getScorer) - Get a scorer by its registration key
|
|
74
|
+
- [getScorers()](../../reference/core/getScorers) - Get all registered scorers
|
|
75
|
+
- [createScorer()](../../reference/scorers/create-scorer) - Learn how to create scorers with names
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: getScorers() | Core | Mastra Docs"
|
|
3
|
+
description: "Documentation for the `getScorers()` method in Mastra, which returns all registered scorers for evaluating AI outputs."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# getScorers()
|
|
7
|
+
|
|
8
|
+
The `getScorers()` method returns all scorers that have been registered with the Mastra instance. Scorers are used for evaluating AI outputs and can override default scorers during agent generation or workflow execution.
|
|
9
|
+
|
|
10
|
+
## Usage Example
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
import { mastra } from './mastra';
|
|
14
|
+
|
|
15
|
+
// Get all registered scorers
|
|
16
|
+
const allScorers = mastra.getScorers();
|
|
17
|
+
|
|
18
|
+
// Access a specific scorer
|
|
19
|
+
const myScorer = allScorers.relevancyScorer;
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Parameters
|
|
23
|
+
|
|
24
|
+
This method takes no parameters.
|
|
25
|
+
|
|
26
|
+
## Returns
|
|
27
|
+
|
|
28
|
+
<PropertiesTable
|
|
29
|
+
content={[
|
|
30
|
+
{
|
|
31
|
+
name: "scorers",
|
|
32
|
+
type: "Record<string, MastraScorer> | undefined",
|
|
33
|
+
description: "An object containing all registered scorers, where keys are scorer names and values are MastraScorer instances. Returns undefined if no scorers are registered.",
|
|
34
|
+
},
|
|
35
|
+
]}
|
|
36
|
+
/>
|
|
37
|
+
|
|
38
|
+
## Related
|
|
39
|
+
|
|
40
|
+
- [getScorer()](../../reference/core/getScorer) - Get a specific scorer by key
|
|
41
|
+
- [getScorerByName()](../../reference/core/getScorerByName) - Get a scorer by its name property
|
|
42
|
+
- [Scorers Overview](../../docs/scorers/overview) - Learn about creating and using scorers
|
|
@@ -129,6 +129,13 @@ export const mastra = new Mastra({
|
|
|
129
129
|
isOptional: true,
|
|
130
130
|
defaultValue: "{ externals: [], sourcemap: false, transpilePackages: [] }",
|
|
131
131
|
},
|
|
132
|
+
{
|
|
133
|
+
name: "scorers",
|
|
134
|
+
type: "Record<string, MastraScorer>",
|
|
135
|
+
description: "Scorers to register for scoring traces and overriding default scorers used during agent generation or workflow execution. Structured as a key-value pair, with keys being the scorer name and values being the scorer instance.",
|
|
136
|
+
isOptional: true,
|
|
137
|
+
defaultValue: "{}",
|
|
138
|
+
},
|
|
132
139
|
]}
|
|
133
140
|
/>
|
|
134
141
|
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "AITracing | AI Tracing | Reference"
|
|
3
|
+
description: Core AI Tracing classes and methods
|
|
4
|
+
asIndexPage: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
import { PropertiesTable } from "@/components/properties-table";
|
|
8
|
+
|
|
9
|
+
# AITracing
|
|
10
|
+
|
|
11
|
+
## DefaultAITracing
|
|
12
|
+
|
|
13
|
+
Default implementation of the AITracing interface.
|
|
14
|
+
|
|
15
|
+
### Constructor
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
new DefaultAITracing(config: TracingConfig)
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Creates a new DefaultAITracing instance with the specified configuration.
|
|
22
|
+
|
|
23
|
+
### Properties
|
|
24
|
+
|
|
25
|
+
Inherits all properties and methods from BaseAITracing.
|
|
26
|
+
|
|
27
|
+
## BaseAITracing
|
|
28
|
+
|
|
29
|
+
Base class for custom AI tracing implementations.
|
|
30
|
+
|
|
31
|
+
### Methods
|
|
32
|
+
|
|
33
|
+
#### getConfig
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
getConfig(): Readonly<Required<TracingConfig>>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Returns the current tracing configuration.
|
|
40
|
+
|
|
41
|
+
#### getExporters
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
getExporters(): readonly AITracingExporter[]
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Returns all configured exporters.
|
|
48
|
+
|
|
49
|
+
#### getProcessors
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
getProcessors(): readonly AISpanProcessor[]
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Returns all configured processors.
|
|
56
|
+
|
|
57
|
+
#### getLogger
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
getLogger(): IMastraLogger
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Returns the logger instance for exporters and other components.
|
|
64
|
+
|
|
65
|
+
#### startSpan
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
startSpan<TType extends AISpanType>(
|
|
69
|
+
options: StartSpanOptions<TType>
|
|
70
|
+
): AISpan<TType>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Start a new span of a specific AISpanType. Creates the root span of a trace if no parent is provided.
|
|
74
|
+
|
|
75
|
+
<PropertiesTable
|
|
76
|
+
props={[
|
|
77
|
+
{
|
|
78
|
+
name: "type",
|
|
79
|
+
type: "AISpanType",
|
|
80
|
+
description: "Type of span to create",
|
|
81
|
+
required: true,
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: "name",
|
|
85
|
+
type: "string",
|
|
86
|
+
description: "Name of the span",
|
|
87
|
+
required: true,
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: "parent",
|
|
91
|
+
type: "AnyAISpan",
|
|
92
|
+
description: "Parent span (if not root)",
|
|
93
|
+
required: false,
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: "attributes",
|
|
97
|
+
type: "AISpanTypeMap[TType]",
|
|
98
|
+
description: "Type-specific attributes",
|
|
99
|
+
required: false,
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: "metadata",
|
|
103
|
+
type: "Record<string, any>",
|
|
104
|
+
description: "User-defined metadata",
|
|
105
|
+
required: false,
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: "input",
|
|
109
|
+
type: "any",
|
|
110
|
+
description: "Initial input data",
|
|
111
|
+
required: false,
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: "customSamplerOptions",
|
|
115
|
+
type: "CustomSamplerOptions",
|
|
116
|
+
description: "Options for custom sampler",
|
|
117
|
+
required: false,
|
|
118
|
+
},
|
|
119
|
+
]}
|
|
120
|
+
/>
|
|
121
|
+
|
|
122
|
+
#### shutdown
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
async shutdown(): Promise<void>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Shuts down all exporters and processors, cleaning up resources.
|
|
129
|
+
|
|
130
|
+
## Custom Implementation
|
|
131
|
+
|
|
132
|
+
To create a custom AI tracing implementation, extend BaseAITracing:
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
class CustomAITracing extends BaseAITracing {
|
|
136
|
+
constructor(config: TracingConfig) {
|
|
137
|
+
super(config);
|
|
138
|
+
// Custom initialization
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Override methods as needed
|
|
142
|
+
startSpan<TType extends AISpanType>(
|
|
143
|
+
options: StartSpanOptions<TType>
|
|
144
|
+
): AISpan<TType> {
|
|
145
|
+
// Custom span creation logic
|
|
146
|
+
return super.startSpan(options);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## NO-OP Spans
|
|
152
|
+
|
|
153
|
+
When tracing is disabled (sampling returns false), NO-OP spans are returned:
|
|
154
|
+
|
|
155
|
+
### NoOpAISpan
|
|
156
|
+
|
|
157
|
+
```typescript
|
|
158
|
+
class NoOpAISpan<TType extends AISpanType> extends BaseAISpan<TType>
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
A span that performs no operations. All methods are no-ops:
|
|
162
|
+
- `id` returns `'no-op'`
|
|
163
|
+
- `traceId` returns `'no-op-trace'`
|
|
164
|
+
- `isValid` returns `false`
|
|
165
|
+
- `end()`, `error()`, `update()` do nothing
|
|
166
|
+
- `createChildSpan()` returns another NO-OP span
|
|
167
|
+
|
|
168
|
+
## See Also
|
|
169
|
+
|
|
170
|
+
### Documentation
|
|
171
|
+
- [AI Tracing Overview](/docs/observability/ai-tracing/overview) - Concepts and usage guide
|
|
172
|
+
- [Configuration Reference](/reference/observability/ai-tracing/configuration) - Configuration options
|
|
173
|
+
- [Interfaces Reference](/reference/observability/ai-tracing/interfaces) - Type definitions
|
|
174
|
+
- [Span Reference](/reference/observability/ai-tracing/span) - Span lifecycle and methods
|
|
175
|
+
|
|
176
|
+
### Examples
|
|
177
|
+
- [Basic AI Tracing](/examples/observability/basic-ai-tracing) - Getting started example
|
|
178
|
+
|
|
179
|
+
### Exporters
|
|
180
|
+
- [DefaultExporter](/reference/observability/ai-tracing/exporters/default-exporter) - Storage persistence
|
|
181
|
+
- [CloudExporter](/reference/observability/ai-tracing/exporters/cloud-exporter) - Mastra Cloud integration
|
|
182
|
+
- [ConsoleExporter](/reference/observability/ai-tracing/exporters/console-exporter) - Debug output
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Configuration | AI Tracing | Reference"
|
|
3
|
+
description: AI Tracing configuration types and registry functions
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
import { PropertiesTable } from "@/components/properties-table";
|
|
7
|
+
|
|
8
|
+
# Configuration
|
|
9
|
+
|
|
10
|
+
## ObservabilityRegistryConfig
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
interface ObservabilityRegistryConfig {
|
|
14
|
+
default?: { enabled?: boolean };
|
|
15
|
+
configs?: Record<string, TracingConfig | AITracing>;
|
|
16
|
+
configSelector?: ConfigSelector;
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
<PropertiesTable
|
|
21
|
+
props={[
|
|
22
|
+
{
|
|
23
|
+
name: "default",
|
|
24
|
+
type: "{ enabled?: boolean }",
|
|
25
|
+
description: "Enable default configuration",
|
|
26
|
+
required: false,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: "configs",
|
|
30
|
+
type: "Record<string, TracingConfig | AITracing>",
|
|
31
|
+
description: "Named tracing configurations",
|
|
32
|
+
required: false,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: "configSelector",
|
|
36
|
+
type: "ConfigSelector",
|
|
37
|
+
description: "Runtime configuration selector",
|
|
38
|
+
required: false,
|
|
39
|
+
},
|
|
40
|
+
]}
|
|
41
|
+
/>
|
|
42
|
+
|
|
43
|
+
## TracingConfig
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
interface TracingConfig {
|
|
47
|
+
name: string;
|
|
48
|
+
serviceName: string;
|
|
49
|
+
sampling?: SamplingStrategy;
|
|
50
|
+
exporters?: AITracingExporter[];
|
|
51
|
+
processors?: AISpanProcessor[];
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
<PropertiesTable
|
|
56
|
+
props={[
|
|
57
|
+
{
|
|
58
|
+
name: "name",
|
|
59
|
+
type: "string",
|
|
60
|
+
description: "Configuration identifier",
|
|
61
|
+
required: true,
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: "serviceName",
|
|
65
|
+
type: "string",
|
|
66
|
+
description: "Service name in traces",
|
|
67
|
+
required: true,
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: "sampling",
|
|
71
|
+
type: "SamplingStrategy",
|
|
72
|
+
description: "Sampling configuration",
|
|
73
|
+
required: false,
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: "exporters",
|
|
77
|
+
type: "AITracingExporter[]",
|
|
78
|
+
description: "Trace data exporters",
|
|
79
|
+
required: false,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: "processors",
|
|
83
|
+
type: "AISpanProcessor[]",
|
|
84
|
+
description: "Span processors",
|
|
85
|
+
required: false,
|
|
86
|
+
},
|
|
87
|
+
]}
|
|
88
|
+
/>
|
|
89
|
+
|
|
90
|
+
## SamplingStrategy
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
type SamplingStrategy =
|
|
94
|
+
| { type: 'always' }
|
|
95
|
+
| { type: 'never' }
|
|
96
|
+
| { type: 'ratio', probability: number }
|
|
97
|
+
| { type: 'custom', sampler: (options?: TracingOptions) => boolean };
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## ConfigSelector
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
type ConfigSelector = (
|
|
104
|
+
options: ConfigSelectorOptions,
|
|
105
|
+
availableConfigs: Map<string, AITracing>
|
|
106
|
+
) => string | undefined;
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## ConfigSelectorOptions
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
interface ConfigSelectorOptions {
|
|
113
|
+
metadata?: Record<string, any>;
|
|
114
|
+
runtimeContext?: Map<string, any>;
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
# Registry Functions
|
|
119
|
+
|
|
120
|
+
## setupAITracing
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
function setupAITracing(config: ObservabilityRegistryConfig): void
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Initializes AI tracing from configuration. Called automatically by Mastra constructor.
|
|
127
|
+
|
|
128
|
+
## registerAITracing
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
function registerAITracing(
|
|
132
|
+
name: string,
|
|
133
|
+
instance: AITracing,
|
|
134
|
+
isDefault?: boolean
|
|
135
|
+
): void
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Registers a tracing config in the global registry.
|
|
139
|
+
|
|
140
|
+
## getAITracing
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
function getAITracing(name: string): AITracing | undefined
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Retrieves a tracing config by name.
|
|
147
|
+
|
|
148
|
+
## getDefaultAITracing
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
function getDefaultAITracing(): AITracing | undefined
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Returns the default tracing config.
|
|
155
|
+
|
|
156
|
+
## getSelectedAITracing
|
|
157
|
+
|
|
158
|
+
```typescript
|
|
159
|
+
function getSelectedAITracing(
|
|
160
|
+
options: ConfigSelectorOptions
|
|
161
|
+
): AITracing | undefined
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Returns the tracing config selected by the config selector or default.
|
|
165
|
+
|
|
166
|
+
## setSelector
|
|
167
|
+
|
|
168
|
+
```typescript
|
|
169
|
+
function setSelector(selector: ConfigSelector): void
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Sets the global config selector function.
|
|
173
|
+
|
|
174
|
+
## unregisterAITracing
|
|
175
|
+
|
|
176
|
+
```typescript
|
|
177
|
+
function unregisterAITracing(name: string): boolean
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Removes a tracing config from the registry.
|
|
181
|
+
|
|
182
|
+
## shutdownAITracingRegistry
|
|
183
|
+
|
|
184
|
+
```typescript
|
|
185
|
+
async function shutdownAITracingRegistry(): Promise<void>
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Shuts down all tracing configs and clears the registry.
|
|
189
|
+
|
|
190
|
+
## clearAITracingRegistry
|
|
191
|
+
|
|
192
|
+
```typescript
|
|
193
|
+
function clearAITracingRegistry(): void
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Clears all configs without shutdown.
|
|
197
|
+
|
|
198
|
+
## getAllAITracing
|
|
199
|
+
|
|
200
|
+
```typescript
|
|
201
|
+
function getAllAITracing(): ReadonlyMap<string, AITracing>
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
Returns all registered tracing configs.
|
|
205
|
+
|
|
206
|
+
## hasAITracing
|
|
207
|
+
|
|
208
|
+
```typescript
|
|
209
|
+
function hasAITracing(name: string): boolean
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Checks if a tracing instance exists and is enabled.
|
|
213
|
+
|
|
214
|
+
## See Also
|
|
215
|
+
|
|
216
|
+
### Documentation
|
|
217
|
+
- [AI Tracing Overview](/docs/observability/ai-tracing/overview) - Concepts and usage guide
|
|
218
|
+
- [Sampling Strategies](/docs/observability/ai-tracing/overview#sampling-strategies) - Sampling configuration details
|
|
219
|
+
- [Multi-Config Setup](/docs/observability/ai-tracing/overview#multi-config-setup) - Using multiple configurations
|
|
220
|
+
|
|
221
|
+
### Reference
|
|
222
|
+
- [AITracing Classes](/reference/observability/ai-tracing/ai-tracing) - Core tracing classes
|
|
223
|
+
- [Interfaces](/reference/observability/ai-tracing/interfaces) - Type definitions
|
|
224
|
+
- [Span Reference](/reference/observability/ai-tracing/span) - Span lifecycle
|
|
225
|
+
|
|
226
|
+
### Examples
|
|
227
|
+
- [Basic AI Tracing](/examples/observability/basic-ai-tracing) - Getting started
|
|
228
|
+
|
|
229
|
+
### Exporters
|
|
230
|
+
- [DefaultExporter](/reference/observability/ai-tracing/exporters/default-exporter) - Storage configuration
|
|
231
|
+
- [CloudExporter](/reference/observability/ai-tracing/exporters/cloud-exporter) - Cloud setup
|
|
232
|
+
- [Braintrust](/reference/observability/ai-tracing/exporters/braintrust) - Braintrust integration
|
|
233
|
+
- [Langfuse](/reference/observability/ai-tracing/exporters/langfuse) - Langfuse integration
|
|
234
|
+
- [LangSmith](/reference/observability/ai-tracing/exporters/langsmith) - LangSmith integration
|