Skip to content

starknet_transaction_prover: HTTP request count + latency + in-flight metrics - #14169

Open
avi-starkware wants to merge 2 commits into
avi/prover-v3/job-metricsfrom
avi/prover-v3/http-metrics
Open

starknet_transaction_prover: HTTP request count + latency + in-flight metrics#14169
avi-starkware wants to merge 2 commits into
avi/prover-v3/job-metricsfrom
avi/prover-v3/http-metrics

Conversation

@avi-starkware

Copy link
Copy Markdown
Collaborator

Adds HttpMetricsLayer placed between the monitoring endpoints and the
rest of the stack so probes/scrapes don't distort the request-latency
distribution. Records request count by bounded method/status labels,
end-to-end latency, and in-flight gauge. Also adds a shared test recorder
helper that installs the global Prometheus recorder once across the
test binary.

Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com

@cursor

cursor Bot commented May 24, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Observability-only middleware with bounded labels; layer ordering is documented and covered by tests, with no changes to proving or auth paths.

Overview
Adds HttpMetricsLayer to the shared prover_http_middleware! stack so JSON-RPC traffic gets Prometheus request counts, end-to-end latency histograms, and an in-flight gauge, with bounded method / status labels and no user-controlled cardinality.

The layer sits below HealthLayer and MetricsLayer, so GET /health and GET /metrics are not counted in those series. Startup calls preregister_http_metrics and configures HTTP_DURATION_BUCKETS for prover_http_request_duration_seconds; in-flight tracking uses a new GaugeGuard RAII helper in metrics.rs. README documents the three new metrics; unit tests assert recording and probe/scrape exclusion.

Reviewed by Cursor Bugbot for commit 17f4f71. Bugbot is set up for automated code reviews on this repo. Configure here.

avi-starkware commented May 24, 2026

Copy link
Copy Markdown
Collaborator Author

@reviewable-StarkWare

Copy link
Copy Markdown

This change is Reviewable

@avi-starkware
avi-starkware force-pushed the avi/prover-v3/job-metrics branch from 7d179cb to a0e7299 Compare May 24, 2026 16:48
@avi-starkware
avi-starkware force-pushed the avi/prover-v3/http-metrics branch 2 times, most recently from 6c02d2b to 2af08ad Compare May 26, 2026 08:43
@avi-starkware
avi-starkware force-pushed the avi/prover-v3/job-metrics branch 2 times, most recently from 00671e6 to 68683f0 Compare May 26, 2026 12:16
@avi-starkware
avi-starkware force-pushed the avi/prover-v3/http-metrics branch 2 times, most recently from 47068b1 to eea5655 Compare May 26, 2026 12:17
@avi-starkware
avi-starkware force-pushed the avi/prover-v3/job-metrics branch from 00f7551 to b51be4a Compare May 26, 2026 12:58
@avi-starkware
avi-starkware force-pushed the avi/prover-v3/http-metrics branch from eea5655 to df42f2f Compare May 26, 2026 12:58
@avi-starkware
avi-starkware force-pushed the avi/prover-v3/http-metrics branch from df42f2f to 83d004c Compare May 26, 2026 16:14
@avi-starkware
avi-starkware force-pushed the avi/prover-v3/job-metrics branch from b51be4a to 396774b Compare May 26, 2026 16:14
@avi-starkware
avi-starkware force-pushed the avi/prover-v3/http-metrics branch from 83d004c to 9122417 Compare May 26, 2026 16:47
@avi-starkware
avi-starkware force-pushed the avi/prover-v3/job-metrics branch 2 times, most recently from 6f17bb1 to fb01d37 Compare May 26, 2026 16:59
@avi-starkware
avi-starkware force-pushed the avi/prover-v3/http-metrics branch from 9122417 to 23731d6 Compare May 26, 2026 16:59
@avi-starkware
avi-starkware force-pushed the avi/prover-v3/job-metrics branch from fb01d37 to f1b98e4 Compare May 27, 2026 10:01
@avi-starkware
avi-starkware force-pushed the avi/prover-v3/job-metrics branch from 4486906 to 89add21 Compare July 9, 2026 12:29
@avi-starkware
avi-starkware force-pushed the avi/prover-v3/http-metrics branch from dc79487 to d9dd37a Compare July 12, 2026 12:39
@avi-starkware
avi-starkware force-pushed the avi/prover-v3/job-metrics branch from 89add21 to e069793 Compare July 12, 2026 12:39
@avi-starkware
avi-starkware force-pushed the avi/prover-v3/http-metrics branch from d9dd37a to dce9c4b Compare July 13, 2026 11:45
@avi-starkware
avi-starkware force-pushed the avi/prover-v3/job-metrics branch from e069793 to 39763da Compare July 13, 2026 11:45
@avi-starkware
avi-starkware force-pushed the avi/prover-v3/http-metrics branch from dce9c4b to 511c82e Compare July 19, 2026 12:24
@avi-starkware
avi-starkware force-pushed the avi/prover-v3/job-metrics branch from 39763da to 8f4079d Compare July 19, 2026 12:24
@avi-starkware
avi-starkware force-pushed the avi/prover-v3/http-metrics branch from 511c82e to ed936b5 Compare July 19, 2026 12:31
@avi-starkware
avi-starkware force-pushed the avi/prover-v3/job-metrics branch from 8f4079d to 5889543 Compare July 19, 2026 12:31
@avi-starkware
avi-starkware force-pushed the avi/prover-v3/http-metrics branch from ed936b5 to 935d7ae Compare July 19, 2026 13:15
@avi-starkware
avi-starkware force-pushed the avi/prover-v3/job-metrics branch from 5889543 to 91aef4f Compare July 19, 2026 13:15
@avi-starkware
avi-starkware force-pushed the avi/prover-v3/job-metrics branch from 91aef4f to 3757a1e Compare August 25, 2026 08:23
@avi-starkware
avi-starkware force-pushed the avi/prover-v3/http-metrics branch from 935d7ae to 278e99a Compare August 25, 2026 08:23
@avi-starkware
avi-starkware force-pushed the avi/prover-v3/job-metrics branch from 3757a1e to 72e94de Compare August 25, 2026 10:14
@avi-starkware
avi-starkware force-pushed the avi/prover-v3/http-metrics branch from 278e99a to 8cc0720 Compare August 25, 2026 10:14
@avi-starkware
avi-starkware force-pushed the avi/prover-v3/job-metrics branch from 72e94de to cfb4202 Compare August 25, 2026 19:09
@avi-starkware
avi-starkware force-pushed the avi/prover-v3/http-metrics branch 2 times, most recently from 553107d to ce52272 Compare August 26, 2026 09:54

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ce52272. Configure here.

);

// The gauge is back at zero, so the guard ran for every request.
assert_eq!(metric_value(&scrape, names::IN_FLIGHT_REQUESTS), 0.0);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky absolute in-flight gauge assert

Low Severity

The in-flight check uses an absolute scrape value of 0.0, while this file’s own header notes that the Prometheus recorder is process-global and other tests (including ones that drive HttpMetricsLayer) run in parallel. A concurrent in-flight request can make this assertion fail intermittently, and a steady 0 also does not prove GaugeGuard ran because preregistration already sets the gauge to zero.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit ce52272. Configure here.

@avi-starkware
avi-starkware force-pushed the avi/prover-v3/http-metrics branch from ce52272 to e8c7c31 Compare August 26, 2026 13:15
@avi-starkware
avi-starkware force-pushed the avi/prover-v3/job-metrics branch 2 times, most recently from 51e5b16 to fd9f317 Compare August 26, 2026 13:39
@avi-starkware
avi-starkware force-pushed the avi/prover-v3/http-metrics branch 2 times, most recently from 8db9f7a to 5a282cd Compare August 26, 2026 14:04
avi-starkware and others added 2 commits August 26, 2026 18:33
… metrics

Adds `HttpMetricsLayer` between the monitoring endpoints and the rest of the
stack, so probes and scrapes don't distort the request-latency distribution. It
records request count by bounded method/status labels, end-to-end latency, and
an in-flight gauge. A shared test recorder helper installs the global Prometheus
recorder once across the test binary.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…xclusion

Gives the HTTP latency histogram explicit bucket bounds so it exports as a
histogram rather than a summary, replaces `InFlightGuard` with a shared
`GaugeGuard` that owns the increment as well as the decrement, and pre-registers
the 4xx/5xx series so an error-rate alert doesn't read an absent one. A new test
pins the probe exclusion, which layer order alone had been enforcing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants