How to customize tracing metadata for Agents invoked with ChatRoute?

Is it possible to add metadata to the tracingContext when a agent is invoked using the ChatRoute supplied by @mastra/ai-sdk? Docs here mention how to update the span metadata but I don't see how I could do this for an agent invoked this way.
AI Tracing | Observability | Mastra Docs
Set up AI tracing for Mastra applications
6 Replies
Incisiv3
Incisiv3OP7d ago
Could I somehow accomplish this with an input processor? -- nvm doesn't seem like those have access to the runtimeContext
Mastra Triager
GitHub
[DISCORD:1428124689867214908] How to customize tracing metadata for...
This issue was created from Discord post: https://discord.com/channels/1309558646228779139/1428124689867214908 Is it possible to add metadata to the tracingContext when a agent is invoked using the...
_roamin_
_roamin_7d ago
Hi @Incisiv3 ! You should be able to pass the tracing options inside your request json body:
{
messages: [...],
tracingOptions: {
metadata: {
'test-metadata': 'value',
}
}
}
{
messages: [...],
tracingOptions: {
metadata: {
'test-metadata': 'value',
}
}
}
Incisiv3
Incisiv3OP7d ago
ok thanks! I'll give it a go and report back.
Incisiv3
Incisiv3OP7d ago
Didn't see any of the metadata show up, here is how I'm sending it along to the mastra service
No description
Incisiv3
Incisiv3OP7d ago
I do see the trace metadata in langfuse whenever I kick off a workflow with tracingOptions though, seems like the chatRoute might not be processing the tracing options or I missed something in the above @Romain let me know if there are other things I can try/tweak

Did you find this page helpful?