feat(trace): add advanced span filters - #728
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d95d83cc5c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "Codex (@codex) review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".
d95d83c to
17dce78
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 17dce788f8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "Codex (@codex) review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".
1ce3164 to
10b2a3e
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 10b2a3ea7d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "Codex (@codex) review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".
10b2a3e to
46a12e1
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 46a12e12c6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "Codex (@codex) review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".
46a12e1 to
0ddb869
Compare
0ddb869 to
53b1a18
Compare
Add `filters` to `Trace.get_spans()` so callers can select spans by type,
name, error state, partial metadata, and duration without fetching the
whole trace and filtering it themselves.
```python
spans = await trace.get_spans(
filters={
"span_type": ["tool"],
"name": ["search", "lookup"],
"has_error": True,
"metadata": {"model": "gpt-5"},
"duration": {"min": 0.5, "max": 10},
}
)
```
Combine filter dimensions with AND and match any value within each name
or span-type list. Duration bounds are inclusive and measured in seconds.
Keep the existing top-level `span_type` argument supported.
Apply consistent filtering to buffered spans, complete trace caches, and
BTQL queries. Check returned metadata candidates locally to handle backend
type coercion differences, and avoid caching partial filtered results as
complete traces. Keep client-side validation limited to supported keys
and input shapes.
d74177d to
478d6b1
Compare
Add
filterstotrace.get_spans()so callers can select spans by type, name, error state, partial metadata, and duration without fetching the whole trace and filtering it themselves.Filter dimensions combine with AND, and each name or span-type list matches any of its values. Metadata supports nested partial matching. Duration bounds are inclusive and measured in seconds. The existing top-level
span_typeargument remains supported without deprecation.Filtering applies consistently to buffered spans, complete trace caches, and BTQL queries. Returned metadata candidates are checked locally to handle backend type coercion differences. Partial filtered results are kept out of the complete trace cache, and client-side validation stays limited to supported keys and input shapes.
Resolves https://linear.app/braintrustdata/issue/SDK-317/add-filters-on-traceget-spans-to-python-sdk