Skip to content

fix(tracing)!: require the gen_ai. prefix in the default span filter - #1929

Merged
hassiebp merged 13 commits into
prepare-v5-releasefrom
lfe-17079-python-sdk-v5-default-span-filter-requires-the-gen_ai-prefix
Oct 7, 2026
Merged

hassiebp merged 13 commits into
prepare-v5-releasefrom
lfe-17079-python-sdk-v5-default-span-filter-requires-the-gen_ai-prefix

Conversation

@hassiebp

@hassiebp hassiebp commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

What does this PR do?

is_genai_span (used by the default should_export_span filter) matched any attribute key starting with gen_ai. Lookalikes such as gen_ai_custom, gen_ai-request.model or gen_airflow.model therefore exported unrelated third-party spans. It now matches only the gen_ai.* namespace.

This is the change from #1924 (by @fallintoplace), landed on the v5 branch because it narrows what the default filter exports.

Stack: independent. Base: prepare-v5-release. It touches only langfuse/_client/span_filter.py and tests/unit/test_span_filter.py, so it can merge at any point.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Refactor
  • Documentation update
  • Tooling, CI, or repo maintenance

Verification

uv run --frozen ruff check .                       # All checks passed!
uv run --frozen mypy langfuse --no-error-summary   # clean
uv run --frozen pytest -q tests/unit/test_span_filter.py  # 62 passed
uv run --frozen pytest -n auto tests/unit          # 736 passed, 2 skipped

Checklist

  • I self-reviewed the diff using code_review.md.
  • I added or updated tests for behavior changes.
  • I updated docs, examples, or .env.template if needed.
  • I did not hand-edit generated files; if generated files changed, I used the upstream regeneration path.
  • I did not commit secrets or credentials.
Open in Web Open in Cursor 

RetriggerConfidence Score: 5/5

The PR appears safe to merge; no actionable regression was identified.

Summary

The PR narrows default GenAI span selection to attributes in the gen_ai.* namespace and adds cases for lookalike keys and valid namespace keys.

Reviews (1) · Last reviewed commit: "fix(tracing)!: require the gen_ai. prefi..."

is_genai_span matched any attribute key starting with "gen_ai", so
lookalikes such as gen_ai_custom or gen_airflow.model exported unrelated
third-party spans. Match only the gen_ai.* namespace.

Co-authored-by: Hassieb Pakzad <hassiebp@users.noreply.github.com>
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown

@claude review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-06T14:31:33.502560Z 8ef341c PR opened
ℹ️ 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 review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

No review was started: this request came from a bot account. Manual reviews can only be requested by someone with write access to this repository. Ask a maintainer to comment @claude review, or have your automation post the comment from a user account with write access.

Tip: disable this comment in your organization's Code Review settings.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, a correct one-line namespace-boundary fix with solid test coverage.

Extended reasoning...

The change is a single-character fix in is_genai_span (langfuse/_client/span_filter.py), changing the prefix check from "gen_ai" to "gen_ai." so lookalike attribute keys like gen_ai_custom or gen_airflow.model no longer falsely match; it mirrors the existing _matches_scope_prefix boundary pattern already used in the same file. No security-sensitive surface (auth, crypto, injection) is touched—this only affects which spans are exported by default. The accompanying test additions in tests/unit/test_span_filter.py are thorough, covering matching and lookalike keys, non-string/bytes keys, and empty attributes, for both is_genai_span and is_default_export_span. The change is small, self-contained, and mechanically verified against the code.

cursoragent and others added 8 commits October 7, 2026 08:43
Co-authored-by: Hassieb Pakzad <hassiebp@users.noreply.github.com>
…t-span-filter-requires-the-gen_ai-prefix

Co-authored-by: Hassieb Pakzad <hassiebp@users.noreply.github.com>
Co-authored-by: Hassieb Pakzad <hassiebp@users.noreply.github.com>
Co-authored-by: Hassieb Pakzad <hassiebp@users.noreply.github.com>
…t-span-filter-requires-the-gen_ai-prefix

Co-authored-by: Hassieb Pakzad <hassiebp@users.noreply.github.com>
…t-span-filter-requires-the-gen_ai-prefix

Co-authored-by: Hassieb Pakzad <hassiebp@users.noreply.github.com>
…t-span-filter-requires-the-gen_ai-prefix

Co-authored-by: Hassieb Pakzad <hassiebp@users.noreply.github.com>
…t-span-filter-requires-the-gen_ai-prefix

Co-authored-by: Hassieb Pakzad <hassiebp@users.noreply.github.com>
cursoragent and others added 4 commits October 7, 2026 20:25
…t-span-filter-requires-the-gen_ai-prefix

Co-authored-by: Hassieb Pakzad <hassiebp@users.noreply.github.com>
…t-span-filter-requires-the-gen_ai-prefix

Co-authored-by: Hassieb Pakzad <hassiebp@users.noreply.github.com>
…t-span-filter-requires-the-gen_ai-prefix

Co-authored-by: Hassieb Pakzad <hassiebp@users.noreply.github.com>
Co-authored-by: Hassieb Pakzad <hassiebp@users.noreply.github.com>
@hassiebp
hassiebp merged commit fbe80b0 into prepare-v5-release Oct 7, 2026
3 checks passed
@hassiebp
hassiebp deleted the lfe-17079-python-sdk-v5-default-span-filter-requires-the-gen_ai-prefix branch October 7, 2026 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants