-
Notifications
You must be signed in to change notification settings - Fork 0
Count publish index-lookup downgrade events (#68) #133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
e4e5d73
Count publish index-lookup downgrade events
leynos 7ff8dee
Extract _emit_downgrade_success to cut method length
leynos f994311
Make metrics atexit flush explicit and broaden test coverage
leynos 0ef7736
Add Hypothesis property tests for the metrics accumulator
leynos 2547eaf
Document metrics output under a users-guide Observability section
leynos cdcacf9
Fix developers-guide merge artifacts from rebase
leynos 9ced3a8
Address review feedback on downgrade metric docs and tests
leynos cfacc5c
Close TOCTOU race in register_summary_atexit
leynos 3e9ae95
Tighten atexit registration locking and metric docs
leynos da1b2e4
Instrument lockfile discovery, refresh, and validation (#91) (#134)
leynos 08ec163
Pin Ruff to 0.15.12 in the Makefile and CI
leynos dca9f40
Record metrics backend in an ADR and harden atexit registration
leynos 2095e20
Address metrics review: guard zero-count, harden tests, dedup properties
leynos 96985c4
Align ADR-004 with the ADR template and document the Ruff pin
leynos 84c3dcf
Guard increment_counter against zero-amount writes
leynos a634f9d
Add regression tests for the zero-amount increment no-op
leynos c638d71
Document RUFF_VERSION/RUFF in the developers guide
leynos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| # ADR-004: In-process metrics accumulator flushed at exit | ||
|
|
||
| ## Status | ||
|
|
||
| Accepted. | ||
|
|
||
| ## Date | ||
|
|
||
| 2026-06-14 | ||
|
|
||
| ## Context and problem statement | ||
|
|
||
| `lading` needs to count operational events so maintainers can see how often a | ||
| release relied on a particular code path — for example, how often a crates.io | ||
| index-lookup failure was downgraded to a warning under | ||
| `--allow-unpublished-workspace-deps`, or how lockfile discovery, refresh, and | ||
| validation behaved during a `bump`. | ||
|
|
||
| A `lading` invocation is a short-lived command-line process, not a long-running | ||
| service. There is no scrape endpoint to expose and no daemon lifetime over | ||
| which a time series would accumulate. Adding an exporter such as | ||
| `prometheus_client` or `statsd` would introduce a runtime dependency and a | ||
| network target with no consumer, and would still need a flush at process exit | ||
| to be useful for a one-shot command. The logs a `lading` run already emits are | ||
| the established operational boundary. | ||
|
|
||
| ## Decision | ||
|
|
||
| Record metrics in an in-process accumulator, `lading.utils.metrics`, and flush | ||
| them as a single structured JSON log line at interpreter exit. | ||
|
|
||
| - Labelled counters are recorded with `increment_counter(name, **labels)` and | ||
| duration aggregates with `observe_duration(name, seconds, **labels)`. | ||
| - `emit_summary` renders the accumulated counters and duration aggregates as | ||
| one `INFO` log line (`lading metrics summary: [...]`). Runs that record | ||
| nothing emit nothing. | ||
| - The flush is registered with `atexit` from explicit application bootstrap | ||
| (`lading.cli.main` calls `register_summary_atexit`) rather than as an | ||
| import-time side effect, so the exit-time behaviour is a visible lifecycle | ||
| decision. Registration is idempotent and sets its guard flag only after | ||
| `atexit.register` succeeds. | ||
| - The registry doubles as a deterministic test seam through `counter_value`, | ||
| `duration_stats`, `snapshot`, and `reset`. | ||
|
|
||
| The metric contracts are documented in the developer guide; the | ||
| `publish.index_lookup_downgrade` counter carries `subcommand` (`package` or | ||
| `publish`) and `missing_crate` labels. | ||
|
|
||
| Label values, including `missing_crate`, are recorded verbatim rather than | ||
| bucketed, hashed, or capped. The accumulator is process-local and flushed once, | ||
| so its cardinality is bounded by the work a single run performs (at most the | ||
| number of distinct crates in that publish run), not by an unbounded external | ||
| key space. The crate name is the actionable detail an operator needs, so | ||
| collapsing it to a bucket such as `other` would remove the metric's value | ||
| without removing a real cost. | ||
|
|
||
| ## Consequences | ||
|
|
||
| - Metrics are dependency-free and add no network target; they are visible only | ||
| in the run's logs, which is where short-lived CLI output is already | ||
| aggregated. | ||
| - The verbatim `missing_crate` label is acceptable for the one-shot, | ||
| log-flushed design. If a future change exports these metrics to a long-lived | ||
| time-series backend, the cardinality decision must be revisited and label | ||
| values bucketed or aggregated at the export boundary at that time. | ||
| - New metrics should be added to the accumulator and documented in the | ||
| developer guide alongside the existing counters. |
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.