Repository navigation
Telemetry off: no repository size reads around retention runs, no pool acquire events - #901
Merged
Merged
Conversation
…l acquire events Two measurements cost work with the metrics off (#549): - The retention worker read the repository's size before every claimed run and again after one that deleted something, only to feed `forge.retention.freed`. It now reads the size only when the metrics record (`forge_telemetry::enabled()`), and then not for a dry run or a disabled policy, which free nothing. - `forge_db::connect_with` had sqlx emit a `TRACE` event per acquire, and `main` always installed the `AcquireTimes` layer for it. The pool now emits the event, and `main` installs the layer (`telemetry::acquire_times()`), only with the metrics on. A slow acquire still logs its `WARN`. Tests: `retention_metrics_off.rs` and `telemetry_off.rs` are binaries without the metrics, where a run sends no size query and the server's pool emits no acquire event; `retention_metrics.rs` and `telemetry.rs` show the two size reads with the freed bytes, and the acquire times in `db.client.connection.wait_time`, with the metrics on. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012e6DJYg356rtc9YTDE6RrF
The statement recorder is a bare `tracing::Subscriber` instead of a `tracing-subscriber` layer, so forge-core gains no dev-dependency and the lockfile stays as on main. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012e6DJYg356rtc9YTDE6RrF
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Nov 17, 2026
Member
Author
|
The merge queue removed this pull request after its That is I do not think this change causes it:
I have not changed the test here: it belongs to #763, and a fix for it (more slack in Generated by Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #549
Telemetry is off by default, but two of its measurements cost work regardless. Both are now gated on whether the metrics record (
forge_telemetry::enabled()).What changed
Retention size reads (
crates/core/src/retention/worker.rs)repository_size()before every claimed run and again after a run that deleted something, only to feedforge.retention.freed. It now reads the size only with the metrics on.dry_run_only) and a disabled policy (enabled: false) no longer read it either: they free nothing, and the issue names both. They still count inforge.retention.runs, with 0 bytes freed, as before.Pool acquire events (
crates/db/src/pool.rs,crates/server/src/main.rs,crates/server/src/telemetry.rs)forge_db::connect_withasks sqlx for the per-acquireTRACEevent only with the metrics on; without them it keeps sqlx's default (no event). A slow acquire (2 s) still logs itsWARNeither way.maininstalls theAcquireTimeslayer only with the metrics on, through the newtelemetry::acquire_times(). Without it the subscriber's level is no longer raised toTRACEfor that target.forge_telemetry::enabled(), so they depend onmain's existing order:Telemetry::install()before the subscriber and before the database connection. The doc comments say so.Nothing in the exporter setup (
Telemetry::new) is touched, to stay clear of #558 (#900). No admin API changes, so no web UI screen.Tests
Metrics are a process-wide switch, so the "off" cases are test binaries of their own:
crates/core/tests/retention_metrics_off.rs: a run that deletes a version sends no size querycrates/core/tests/retention_metrics.rs: the same run sends exactly two size queries andforge.retention.freedcounts the deleted bytes; a dry run and a disabled policy send nonecrates/server/tests/telemetry_off.rs:acquire_times()isNone, and the server's pool (connect_with) emits no acquire event to a subscriber that asks for them atTRACE; a pool told to emit them does reach that subscriber, so the check can failcrates/server/tests/telemetry.rs: five acquires on the server's pool add five todb.client.connection.wait_timeThe retention tests count size queries from sqlx's own statement log (
sqlx::queryevents), recognising a statement that starts withSELECT COALESCE(SUM(, which all threerepository_sizequeries do.Verification
Run locally, all passing:
cargo xtask check(fmt and clippy with-D warnings)cargo xtask unused,cargo xtask doc-check,cargo xtask changelog --check.github/scripts/test-parallel.sh --workspace: 137 test binaries, 2066 tests passed, 0 failed, 2 ignored (Docker with testcontainers, images throughmirror.gcr.io)Not run:
cargo xtask e2eand the client e2e scripts (oci-e2e,raw-e2e,apt-e2e,npm-e2e, image smoke), and nothing measured the saved work on a large repository or a busy pool.The tests were built with
CARGO_PROFILE_DEV_DEBUG=0to fit the session's disk; that changes debug info only.Changelog and milestone
docs/changes/2.2.0/549.fixed.md. The issue was inBacklog; since the fix ships in the next release, I moved it to the2.2.0milestone.Generated by Claude Code