Skip f-string inspection for spans and logs that logfire opens itself #2775
All Vouch review confidence checks passed
Residual risk 0.15 = Change Risk (0.37) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 232 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.326
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #2775"
general
weight: 0.35
ska2704
Closes #2771
With
inspect_arguments=True,Logfire._spanandLogfire.loghand the caller's frame tologfire_format_with_magic, which runsexecutingon the call site to see whether the message is an f-string. When the caller is logfire itself (Variable.get(), integrations), that parses the logfire module's source on the first call, even though the message is never a user f-string.Following the suggestion in the issue,
logfire_format_with_magicnow drops the frame when the call site is inside the logfire package, the same asinspect_arguments=False. Doing it there covers_spanandlogand every internal caller at once. For the nice-to-have: whenPYTEST_CURRENT_TESTis set (the same signallog_internal_erroruses), the magic still runs for these calls and asserts the template is unchanged, so an internal call with an f-string fails the tests instead of silently producing a span name per value.With the reproduction from the issue, the first
get()went from 9.3 ms to 1.4 ms (macOS arm64, Python 3.13), andexecutingno longer parsesvariables/variable.py.test_logfire_calls_skip_fstring_magicfails on main becausevariable.pygets inspected.test_logfire_fstring_call_fails_in_testscovers the test-time check.<!-- This is an auto-generated description by cubic. -->
<a href="https://cubic.dev/pr/pydantic/logfire/pull/2775?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->