0
Fork 0
mirror of https://github.com/mastra-ai/mastra.git synced 2026-11-17 08:44:46 +00:00
mastra/observability/braintrust/examples/basic.ts
Ken Jiang 2db7339c24
Add braintrustLogger as an optional parameter to BraintrustExporter (#9946)
## Description

This PR adds `braintrustLogger` as a parameter to `BraintrustExporter`
allowing developers to pass in their own braintrust logger. This
enables:

* nesting Mastra traces inside parent spans  
* running braintrust evals on mastra agents

Note: this PR isn't intended to be a breaking change.

## Related Issue(s)

customer request


## Type of Change

- [ ] Bug fix (non-breaking change that fixes an issue)
- [x] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation update
- [ ] Code refactoring
- [ ] Performance improvement
- [ ] Test update

## Checklist

- [x] I have made corresponding changes to the documentation (if
applicable)
- [x] I have added tests that prove my fix is effective or that my
feature works

I've manually tested and checked the scripts ran into this repo.
braintrust eval:
<img width="1435" height="1262" alt="image"
src="https://github.com/user-attachments/assets/5328f15d-fd75-44f7-b5cf-058ab4ea00ad"
/>

parent span:
<img width="1436" height="1194" alt="image"
src="https://github.com/user-attachments/assets/91c4088a-2a62-46ba-90f8-d5c7af95255a"
/>


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
  * Optional braintrustLogger for context-aware Braintrust tracing.
* New example demos: standard integration, logger-traced context, and
Eval workflow.

* **Chores**
  * Runnable scripts to launch the examples.
  * Examples excluded from linting and TypeScript compilation.
  * Added changeset declaring a patch release.

* **Tests**
* Added tests covering braintrustLogger integration, external-span
attachment, and nested trace behavior.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-11-13 14:45:23 -08:00

96 lines
2.8 KiB