Python: the log controls apply to the Logfire SDK's logs
Merged
ST
1mo ago+172+172+012345678901234567890123456789-36-36-01234567890123456789
Fixes a gap found in the Fleet end-to-end run: for an app on the Logfire SDK, pausing logs, log_levels and log_rate_limit did nothing, yet the policy came back APPLIED.
The Logfire SDK's logs (logfire.info(), and Python logging through LogfireLoggingHandler) are spans marked logfire.span_type = "log", so they went through the trace gate and never reached the log controls.
What changes
Controls.spans(to, log_spans=True), used only byconfigure_logfire's exporters to Logfire, sends Logfire log spans through the log controls:- the logs export (
send_logs); log_levels, bylogfire.level_num(already an OpenTelemetry SeverityNumber). Forscopes, the Python logger's name (logfire.logger_name), else the span's scope (logfire,logfire.<suffix>);log_rate_limit.
- the logs export (
- The trace pause (
send_traces) leaves Logfire logs alone, and their counts go to the logs' export counts. Other spans are gated as before. - The OpenTelemetry SDK path (
configure(),opentelemetry-instrument) is unchanged: there, every span is a span. docs/python-otel.mdnow describes this, replacing "the trace controls apply to them".
Spec
No OpAMP change. This is how the SDK carries out the send_logs* settings it already declares, so the APPLIED status is now true. Treating Logfire's log spans as logs, and the logger name as their scope, is our choice where the settings leave it open.
Tests
test_the_logfire_sdks_logs_go_through_the_log_controls_not_the_trace_ones(gate unit test) andtest_the_log_controls_apply_to_the_logfire_sdks_logs(a realconfigure_logfirechild usinglogfire.info/warnand the logging handler). Both fail without the change.python/otelsuite: 571 passed.
Generated by Claude Code