Commit 27f0694
Expose tags in the collector. Allow passing tags via baml function baml_options (#2528)
# Pull Request Template
Thanks for taking the time to fill out this pull request!
## Issue Reference
Please link to any related issues
- [ ] This PR fixes/closes #[issue number]
## Changes
Please describe the changes proposed in this pull request
This PR surfaces span/function call tags via the `Collector`'s
`FunctionLog` across multiple language clients. This allows users to
retrieve tags, including those inherited from parent `@trace` contexts,
directly from the `FunctionLog` object.
Specifically:
- The Rust core `FunctionLog` now exposes a `tags()` method (an alias
for `metadata()`).
- This `tags` accessor is exposed in the Python, TypeScript, and Ruby
language clients.
- Integration tests have been added for Python and TypeScript to verify
that tags set in a parent `@trace` context are correctly propagated and
visible in the child function's `FunctionLog.tags`.
## Testing
Please describe how you tested these changes
- [x] Unit tests added/updated (Rust core)
- [x] Manual testing performed (Python and TypeScript integration tests)
- [ ] Tested in [environment]
The Rust core changes were verified with `cargo test -p baml-runtime
--lib`.
New Python integration test
`test_functionlog_tags_inherit_from_parent_trace` was run and passed.
New TypeScript integration test `"should include parent trace tags in
FunctionLog.tags"` was added and compiles; it will run in CI.
## Screenshots
If applicable, add screenshots to help explain your changes
[Add screenshots here...]
## PR Checklist
Please ensure you've completed these items
- [ ] I have read and followed the contributing guidelines
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
## Additional Notes
Add any other context about the PR here
The Go client was mentioned in the original task, but no explicit `tags`
accessor was added to its `FunctionLog` as part of these changes. The
existing `metadata` accessor in Go would provide similar functionality
if `tags` is an alias for `metadata`. The TypeScript integration test
compiles against the updated `native.d.ts` and runtime wrapper
implementation; it will run in CI once the workspace’s TS dependencies
are fully available.
---
<a
href="https://cursor.com/background-agent?bcId=bc-83c0460d-95c0-4ce7-afd0-bee8c222af3a"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/open-in-cursor-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/open-in-cursor-light.svg"><img alt="Open in
Cursor"
src="https://cursor.com/open-in-cursor.svg"></picture></a> <a
href="https://cursor.com/agents?id=bc-83c0460d-95c0-4ce7-afd0-bee8c222af3a"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/open-in-web-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/open-in-web-light.svg"><img alt="Open in Web"
src="https://cursor.com/open-in-web.svg"></picture></a>
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Add `tags` to TS sync client call options and pass them to runtime,
with tests ensuring FunctionLog includes parent trace and per-call tags.
>
> - **TypeScript Client**:
> - Add `tags?: Record<string, string>` to `BamlCallOptions` in
`sync_client.ts` and forward `options.tags || {}` to all
`runtime.callFunctionSync` calls.
> - **Tracing/Tests**:
> - Update tests to set parent trace tags and assert they appear in
`FunctionLog.tags`.
> - Add test to pass per-call tags and verify both parent and
function-specific tags are preserved.
> - **Generated Code**:
> - Large auto-formatted changes in generated TypeScript request code
(no functional deltas highlighted).
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
73cef16. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Cursor Agent <[email protected]>1 parent 4bb2f33 commit 27f0694
553 files changed
Lines changed: 165920 additions & 158429 deletions
File tree
- engine
- baml-runtime/src
- cli
- serve
- runtime_methods
- test_executor
- tracingv2/storage
- tracing
- types
- baml-schema-wasm/src/runtime_wasm
- baml-vm/tests
- generators/languages
- go
- generated_tests
- array_types/baml_client
- stream_types
- type_builder
- types
- asserts/baml_client
- stream_types
- type_builder
- types
- classes/baml_client
- stream_types
- type_builder
- types
- edge_cases/baml_client
- stream_types
- type_builder
- types
- enums/baml_client
- stream_types
- type_builder
- types
- literal_types/baml_client
- stream_types
- type_builder
- types
- map_types/baml_client
- stream_types
- type_builder
- types
- media_types/baml_client
- stream_types
- type_builder
- types
- mixed_complex_types/baml_client
- stream_types
- type_builder
- types
- nested_structures/baml_client
- stream_types
- type_builder
- types
- optional_nullable/baml_client
- stream_types
- type_builder
- types
- primitive_types/baml_client
- stream_types
- type_builder
- types
- recursive_types/baml_client
- stream_types
- type_builder
- types
- sample/baml_client
- stream_types
- type_builder
- types
- semantic_streaming/baml_client
- stream_types
- type_builder
- types
- union_types_extended/baml_client
- stream_types
- type_builder
- types
- unions/baml_client
- stream_types
- type_builder
- types
- src/_templates
- python
- generated_tests
- array_types/baml_client
- asserts/baml_client
- classes/baml_client
- edge_cases/baml_client
- enums/baml_client
- literal_types/baml_client
- map_types/baml_client
- media_types/baml_client
- mixed_complex_types/baml_client
- nested_structures/baml_client
- optional_nullable/baml_client
- primitive_types/baml_client
- recursive_types/baml_client
- sample/baml_client
- semantic_streaming/baml_client
- union_types_extended/baml_client
- unions/baml_client
- src/_templates
- ruby/src/_templates
- typescript
- generated_tests
- array_types/baml_client
- asserts/baml_client
- classes/baml_client
- edge_cases/baml_client
- enums/baml_client
- literal_types/baml_client
- map_types/baml_client
- media_types/baml_client
- mixed_complex_types/baml_client
- nested_structures/baml_client
- optional_nullable/baml_client
- primitive_types/baml_client
- recursive_types/baml_client
- sample/baml_client
- semantic_streaming/baml_client
- union_types_extended/baml_client
- unions/baml_client
- src/_templates
- language_client_cffi
- src
- ctypes
- ffi
- raw_ptr_wrapper
- types
- language_client_go/pkg
- cffi
- language_client_python
- python_src/baml_py
- src
- types
- language_client_ruby/ext/ruby_ffi/src
- types
- language_client_typescript
- src
- types
- integ-tests
- go
- baml_client
- python-v1/baml_client
- python
- baml_client
- tests
- react/baml_client
- ruby/baml_client
- typescript-esm/baml_client
- typescript
- baml_client
- tests
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
| 150 | + | |
150 | 151 | | |
151 | 152 | | |
152 | 153 | | |
| |||
172 | 173 | | |
173 | 174 | | |
174 | 175 | | |
| 176 | + | |
175 | 177 | | |
176 | 178 | | |
177 | 179 | | |
| |||
181 | 183 | | |
182 | 184 | | |
183 | 185 | | |
184 | | - | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
185 | 195 | | |
186 | 196 | | |
187 | 197 | | |
| |||
246 | 256 | | |
247 | 257 | | |
248 | 258 | | |
| 259 | + | |
249 | 260 | | |
250 | 261 | | |
251 | 262 | | |
| |||
372 | 383 | | |
373 | 384 | | |
374 | 385 | | |
| 386 | + | |
375 | 387 | | |
376 | 388 | | |
377 | 389 | | |
| |||
388 | 400 | | |
389 | 401 | | |
390 | 402 | | |
| 403 | + | |
391 | 404 | | |
392 | 405 | | |
393 | 406 | | |
| |||
646 | 659 | | |
647 | 660 | | |
648 | 661 | | |
| 662 | + | |
649 | 663 | | |
650 | 664 | | |
651 | 665 | | |
| |||
656 | 670 | | |
657 | 671 | | |
658 | 672 | | |
| 673 | + | |
659 | 674 | | |
660 | 675 | | |
661 | 676 | | |
| |||
669 | 684 | | |
670 | 685 | | |
671 | 686 | | |
| 687 | + | |
672 | 688 | | |
673 | 689 | | |
674 | 690 | | |
| |||
680 | 696 | | |
681 | 697 | | |
682 | 698 | | |
| 699 | + | |
683 | 700 | | |
684 | 701 | | |
685 | 702 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
527 | 527 | | |
528 | 528 | | |
529 | 529 | | |
| 530 | + | |
530 | 531 | | |
531 | 532 | | |
532 | 533 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
357 | 357 | | |
358 | 358 | | |
359 | 359 | | |
| 360 | + | |
360 | 361 | | |
361 | 362 | | |
362 | 363 | | |
| |||
460 | 461 | | |
461 | 462 | | |
462 | 463 | | |
| 464 | + | |
463 | 465 | | |
464 | 466 | | |
465 | 467 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
326 | 326 | | |
327 | 327 | | |
328 | 328 | | |
| 329 | + | |
329 | 330 | | |
330 | 331 | | |
331 | 332 | | |
| |||
1159 | 1160 | | |
1160 | 1161 | | |
1161 | 1162 | | |
| 1163 | + | |
1162 | 1164 | | |
1163 | 1165 | | |
1164 | 1166 | | |
| |||
1293 | 1295 | | |
1294 | 1296 | | |
1295 | 1297 | | |
| 1298 | + | |
1296 | 1299 | | |
1297 | 1300 | | |
1298 | 1301 | | |
| |||
1371 | 1374 | | |
1372 | 1375 | | |
1373 | 1376 | | |
| 1377 | + | |
1374 | 1378 | | |
1375 | 1379 | | |
1376 | 1380 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
452 | 452 | | |
453 | 453 | | |
454 | 454 | | |
| 455 | + | |
455 | 456 | | |
456 | 457 | | |
457 | 458 | | |
| |||
471 | 472 | | |
472 | 473 | | |
473 | 474 | | |
| 475 | + | |
474 | 476 | | |
475 | 477 | | |
476 | 478 | | |
| |||
576 | 578 | | |
577 | 579 | | |
578 | 580 | | |
| 581 | + | |
579 | 582 | | |
580 | 583 | | |
581 | 584 | | |
| |||
673 | 676 | | |
674 | 677 | | |
675 | 678 | | |
| 679 | + | |
676 | 680 | | |
677 | 681 | | |
678 | 682 | | |
| |||
689 | 693 | | |
690 | 694 | | |
691 | 695 | | |
| 696 | + | |
692 | 697 | | |
693 | 698 | | |
694 | 699 | | |
| |||
706 | 711 | | |
707 | 712 | | |
708 | 713 | | |
| 714 | + | |
709 | 715 | | |
710 | 716 | | |
711 | 717 | | |
| |||
715 | 721 | | |
716 | 722 | | |
717 | 723 | | |
| 724 | + | |
718 | 725 | | |
719 | 726 | | |
720 | 727 | | |
| |||
729 | 736 | | |
730 | 737 | | |
731 | 738 | | |
| 739 | + | |
732 | 740 | | |
733 | 741 | | |
734 | 742 | | |
| |||
742 | 750 | | |
743 | 751 | | |
744 | 752 | | |
| 753 | + | |
745 | 754 | | |
746 | 755 | | |
747 | 756 | | |
| |||
779 | 788 | | |
780 | 789 | | |
781 | 790 | | |
| 791 | + | |
782 | 792 | | |
783 | 793 | | |
784 | 794 | | |
| |||
789 | 799 | | |
790 | 800 | | |
791 | 801 | | |
792 | | - | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
793 | 811 | | |
794 | 812 | | |
795 | 813 | | |
| |||
984 | 1002 | | |
985 | 1003 | | |
986 | 1004 | | |
| 1005 | + | |
987 | 1006 | | |
988 | 1007 | | |
989 | 1008 | | |
| |||
996 | 1015 | | |
997 | 1016 | | |
998 | 1017 | | |
| 1018 | + | |
999 | 1019 | | |
1000 | 1020 | | |
1001 | 1021 | | |
| |||
1009 | 1029 | | |
1010 | 1030 | | |
1011 | 1031 | | |
| 1032 | + | |
1012 | 1033 | | |
1013 | 1034 | | |
1014 | 1035 | | |
| |||
1019 | 1040 | | |
1020 | 1041 | | |
1021 | 1042 | | |
| 1043 | + | |
1022 | 1044 | | |
1023 | 1045 | | |
1024 | 1046 | | |
| |||
1330 | 1352 | | |
1331 | 1353 | | |
1332 | 1354 | | |
1333 | | - | |
| 1355 | + | |
1334 | 1356 | | |
1335 | 1357 | | |
1336 | 1358 | | |
| |||
1505 | 1527 | | |
1506 | 1528 | | |
1507 | 1529 | | |
1508 | | - | |
| 1530 | + | |
1509 | 1531 | | |
1510 | 1532 | | |
1511 | 1533 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| |||
84 | 85 | | |
85 | 86 | | |
86 | 87 | | |
| 88 | + | |
87 | 89 | | |
88 | 90 | | |
89 | 91 | | |
| |||
104 | 106 | | |
105 | 107 | | |
106 | 108 | | |
| 109 | + | |
107 | 110 | | |
108 | 111 | | |
109 | 112 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
294 | 294 | | |
295 | 295 | | |
296 | 296 | | |
| 297 | + | |
297 | 298 | | |
298 | 299 | | |
299 | 300 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
94 | 104 | | |
95 | 105 | | |
96 | 106 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
408 | 408 | | |
409 | 409 | | |
410 | 410 | | |
| 411 | + | |
411 | 412 | | |
412 | 413 | | |
413 | | - | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
414 | 428 | | |
415 | 429 | | |
416 | 430 | | |
| |||
427 | 441 | | |
428 | 442 | | |
429 | 443 | | |
430 | | - | |
| 444 | + | |
431 | 445 | | |
432 | 446 | | |
433 | 447 | | |
| |||
460 | 474 | | |
461 | 475 | | |
462 | 476 | | |
463 | | - | |
| 477 | + | |
464 | 478 | | |
465 | 479 | | |
466 | 480 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
520 | 520 | | |
521 | 521 | | |
522 | 522 | | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
523 | 528 | | |
524 | 529 | | |
525 | 530 | | |
| |||
0 commit comments