Skip to content

Middleware and metric to track per-database HTTP response egress - #5611

Open
gefjon wants to merge 2 commits into
masterfrom
phoebe/http-egress-middleware
Open

Middleware and metric to track per-database HTTP response egress#5611
gefjon wants to merge 2 commits into
masterfrom
phoebe/http-egress-middleware

Conversation

@gefjon

@gefjon gefjon commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Description of Changes

This commit adds a new Prometheus metric, spacetime_http_response_size_bytes_total, which tracks bytes sent as responses to HTTP requests related to the database. This includes the sql and call routes, guest-defined HTTP handlers, logs, plus some misc. management routes. Notably, the subscribe route, which initiates a long-lived WebSocket connection, is not counted by the new metric, as we already track its egress separately.

The new metric is tracked by an Axum middleware.

API and ABI breaking changes

N/a

Expected complexity level and risk

1 or 2? I don't have a huge amount of confidence any time I touch our Axum stuff, but this is just metrics, and (at least currently) not billed metrics.

Testing

  • New unit tests which assert that the middleware functions correctly when used with a mocked router.
  • I don't know how to integration-test metrics.

This commit adds a new Prometheus metric,
`spacetime_http_response_size_bytes_total`,
which tracks bytes sent as responses to HTTP requests related to the database.
This includes the `sql` and `call` routes, guest-defined HTTP handlers,
logs, plus some misc. management routes.
Notably, the `subscribe` route, which initiates a long-lived WebSocket connection,
is not counted by the new metric, as we already track its egress separately.

The new metric is tracked by an Axum middleware.
@gefjon
gefjon requested a review from joshua-spacetime July 28, 2026 21:28
@gefjon gefjon added the release-any Can land in any release window. Will not block a release deployment. label Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-any Can land in any release window. Will not block a release deployment.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant