Add configure(fleet=...) to manage the SDK from Logfire Fleet #2736
All Vouch review confidence checks passed
Residual risk 0.31 = Change Risk (0.78) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.78 · 610 lines diff across 7 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.384
Shallow Review Depth
shallow_review_depth
0.289
Sensitive Paths
sensitive_paths
0.078
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #2736"
general
weight: 0.35
Viicos
<!-- claude-projects-attribution: {"github_login":"strawgate"} -->
_Requested by Bill · project thread_
What
logfire.configure()gets afleetoption. With it, a Logfire Fleet policy governs everything the SDK sends: sampling, which signals are sent, log levels, redaction and volume limits, on every exporter, the console included.fleet=Truereads the Fleet server fromOTEL_OPAMP_ENDPOINTandOTEL_OPAMP_HEADERS, which the Fleet setup page gives you.fleet=logfire.fleet.FleetOptions(endpoint=..., headers=..., state_dir=..., heartbeat_interval=...)gives the server in code instead.fleetextra,logfire-fleet-otel>=0.2.1,<0.3; python_version >= '3.11'. Its native core is about 1 MB per platform wheel, so it stays out of the base install. It is imported only whenfleetis set.How
logfire/_internal/fleet.pyfinds the client and checks its contract version._initialize()then calls it where the policy has to act:1. Head sampler: the head sampler goes in, and the live sampler comes out for the tracer provider.
2. Resource: Fleet's instance UID is merged into the resource as
service.instance.id.3. Export to Logfire:
- redaction goes under
RetryFewerSpansSpanExporter, so a span the retries make is redacted too- the gate goes above it, so each span is decided and counted once
- the log and metric exporters get gates too.
4. Start: the client gets the built providers. Every other exporter on them gets the gates (the console,
additional_span_processors,OTEL_EXPORTER_OTLP_*), and the client joins the fleet. A laterconfigure()is governed under the same client.None of this blocks or raises. Until Fleet answers, the last saved policy is in force, else the SDK's own settings. In these cases it warns with
LogfireFleetWarningand the SDK runs as it does today:LOGFIRE_FLEET_CONTRACT)Smaller changes:
fleet_enabledis added to the "Logfire configured" span.FleetOptionssurvives the executor round trip as a dict, like the other option dataclasses.logfire-apistubs are regenerated for the changed files only.The client side is pydantic/opamp-clients#127. Today that package's
configure_logfire()rebuilds these exporters fromlogfire._internalmodules. With this PR it no longer has to. pydantic/logfire-js#422 adds the same option to@pydantic/logfire-node.Before it can merge (why it's a draft)
logfire-fleet-otelwith the hook (#127) has to be published. Until thenuv lockcan't resolve thefleetextra, souv.lockisn't updated in this PR and CI's lock check will fail.Checks (local, Python 3.13)
tests/test_fleet.py(new, with a fake client) covers:- where each wrapper sits in the exporter chain
- the call order
-
LOGFIRE_FLEET- off by default
- each case where it runs unmanaged.
test_configure.pyandtest_logfire_api.pypass. The configuration span snapshot gainsfleet_enabled.- Two need Docker (MySQL, Celery) and were deselected.
- One unraisable-socket warning in
test_openai_agents.pypasses on its own.- The fourth is the stack of two xfails.
configure_logfire()and throughlogfire.configure(fleet=...)against an OpAMP server and a fake ingest. All pass, covering redaction, traces off, log levels, console governance, sampling, credentials file, zstd, reconfigure and exporter placement.ruffandpyrightare clean on the changed files.---
_Generated by Claude Code_
<!-- This is an auto-generated description by cubic. -->
<a href="https://cubic.dev/pr/pydantic/logfire/pull/2736?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. -->