Skip to content

feat: Instrument pre-completion chat availability#173

Merged
noahpodgurski merged 10 commits into
mainfrom
chat-availability-sli
Jun 18, 2026
Merged

feat: Instrument pre-completion chat availability#173
noahpodgurski merged 10 commits into
mainfrom
chat-availability-sli

Conversation

@randy-concepcion

Copy link
Copy Markdown
Contributor

What's New

Adds pre-completion coverage to mlpa_chat_availability_total, so auth rejections and user-provisioning failures show up in the chat availability signal.

A chat request terminates at one of four points and records exactly one outcome:

  1. Auth (authorize_chat_request) - all excluded:
    • invalid_service_type_for_model
    • auth_rejected
    • invalid_auth_request
  2. User provisioning (get_or_create_user_for_completion):
    • signup_cap_exceeded (excluded)
    • provisioning_failure (failure, 5xx only)
  3. Blocked check: blocked (excluded)
  4. Model call (get_completion / stream_completion): already instrumented

Notes

  • The auth wrapper catches only HTTPException and records only 401 and 400. Everything else, including App Attest's explicit 500, is re-raised without recording.
  • Shared-call 400s use invalid_auth_request rather than invalid_purpose because malformed App Attest base64 reaches the same path as purpose validation.
  • auth_system_failure is defined but not emitted. See the limitation below.
  • Reference: Availability RFC and SLI Inventory.

Known Limitation

This is an interim measurement. For FxA and Play Integrity, the same 401 response is returned whether the request was correctly rejected (such as an expired token) or the authentication system itself had a problem (such as an outage). Since they can't be distinguished, all of these are counted as expected rejections and left out of the ratio for now.

This means that real authentication-system failures are not yet counted as failures. This is a known gap, already noted in the Availability RFC and the SLI Inventory, and it will be addressed once those failures can be identified separately.

The availability ratio is success / (success + failure), and excluded and abort are held out.

@randy-concepcion

Copy link
Copy Markdown
Contributor Author

/build-pr

@randy-concepcion

Copy link
Copy Markdown
Contributor Author

Manual verification done in dev, in addition to the unit tests.

Verified manually

  • The three auth-stage excluded reasons, triggered with crafted requests and confirmed recording with the right labels and outcome="excluded"
    • auth_rejected (valid service-type, invalid auth)
    • invalid_service_type_for_model (valid model with a service-type it does not allow)
    • invalid_auth_request (invalid purpose)
  • Real dev traffic exercised success and upstream_error, so the availability ratio is live, currently around 99% with dips that line up with upstream_error clusters
  • Confirmed the counter is scraped into Prometheus and queryable

Not verified manually
provisioning_failure, signup_cap_exceeded, and blocked need specific user or system state, so they were not triggered in dev. They are covered by the unit tests. auth_system_failure is defined but not emitted, which is the known auth limitation in the description.

Dashboard
Test dashboard built in Yardstick to validate the metric and compare against the existing success-rate panels.
[TEST] MLPA Availability

image

@randy-concepcion randy-concepcion force-pushed the chat-availability-sli branch 2 times, most recently from 024ccc6 to 2d6922c Compare June 13, 2026 05:10
@randy-concepcion randy-concepcion requested review from a team, noahpodgurski and subpath and removed request for a team June 13, 2026 05:12
@randy-concepcion randy-concepcion marked this pull request as ready for review June 13, 2026 14:25
@randy-concepcion randy-concepcion requested a review from a team as a code owner June 13, 2026 14:25
@randy-concepcion randy-concepcion removed the request for review from a team June 13, 2026 14:26
@randy-concepcion

Copy link
Copy Markdown
Contributor Author

I've also added the same panels to our main Grafana dashboard so once these changes are deployed, we can start seeing them in Prod.

MLPA Availability Panels (Prod) - No data available until deployed.
image

@noahpodgurski noahpodgurski left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks really good 🙌 just a few comments :)

Comment thread src/mlpa/core/prometheus_metrics.py Outdated
Comment thread src/mlpa/core/prometheus_metrics.py
Comment thread src/mlpa/core/completions.py Outdated
Comment thread src/mlpa/core/completions.py
Comment thread src/mlpa/core/completions.py Outdated
Comment thread src/mlpa/core/auth/authorize.py Outdated
Comment thread src/mlpa/core/auth/authorize.py
Comment thread src/mlpa/core/errors.py

@randy-concepcion randy-concepcion left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review @noahpodgurski! I replied to each comment inline. I'll make some of these changes now and adjust according to your responses.

Comment thread src/mlpa/core/auth/authorize.py Outdated
Comment thread src/mlpa/core/auth/authorize.py
Comment thread src/mlpa/core/completions.py Outdated
Comment thread src/mlpa/core/completions.py
Comment thread src/mlpa/core/completions.py Outdated
Comment thread src/mlpa/core/errors.py
Comment thread src/mlpa/core/prometheus_metrics.py Outdated
Comment thread src/mlpa/core/prometheus_metrics.py
@randy-concepcion

Copy link
Copy Markdown
Contributor Author

@noahpodgurski Thanks again for the feedback! I've pushed changes and is ready for another round of review when you have a chance! 🙏

@randy-concepcion

Copy link
Copy Markdown
Contributor Author

/build-pr

@randy-concepcion

randy-concepcion commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

Manually verified on dev. Grafana link for 2026-06-17 time window.

Prometheus: Metrics Explorer
image

MLPA Availability in Grafana (includes failures)
image

Comment thread src/mlpa/core/auth/authorize.py Outdated
Comment thread src/mlpa/core/auth/authorize.py Outdated
Comment thread src/mlpa/core/middleware/request_size.py Outdated
Comment thread src/mlpa/core/auth/authorize.py Outdated
@noahpodgurski noahpodgurski merged commit a56bb9a into main Jun 18, 2026
1 check passed
@noahpodgurski noahpodgurski deleted the chat-availability-sli branch June 18, 2026 16:30
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