Repository navigation
[api] tag every sandbox API metric with the bounded client id - #1343
Merged
Merged
Conversation
nikhilbirmiwal-pplx
approved these changes
Nov 2, 2026
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.
Summary
Operators can't break down the sandbox API's operational metrics by caller. Only the limiter decision counter and the connect-handler reconnect metrics carry
client_idtoday (#1058). Route latency and errors, step latency and errors, and the create counter for create, connect, pause, resume, kill, timeout and the other routes are tagged only byopandsurface.After this change, every
sandbox.api.*metric built from an API metric identity carriesclient_id, and so doessandbox.api.created:X-Client-IDonce. It resolves the header with the limiter's newClientConcurrencyLimiter::client_id_tag, which checks only the staticSPACE_API_CLIENT_CONCURRENCY_KNOWN_CLIENTSallowlist, and stamps the result on the route metric identity. This coverssandbox.api.latency_msandsandbox.api.request_error.scope_request_client_id).api_identity_tagsuses that scope when an identity has no client ID of its own. Step latency and errors (sandbox.api.step.latency_ms,sandbox.api.error, including the create steps), restore-claim laps, wake-coalescer outcomes, template selection and dormant activation pick upclient_idthis way, with no edits at the roughly 90 places that build identities.ClientIdTagmoves tosandbox/api/client_id.rs, next to the new scope. As a result,api.rsshrinks from 1111 to 1094 code lines.Cardinality
The tag value is always a
ClientIdTag: an allowlisted ID, orunknownfor anything else. The raw header never becomes a tag. The route middleware skips the Eppo override map, so it adds no per-request flag evaluation and can never produceoverflow. Each affected series multiplies by at most the number of allowlisted clients plus one.Not covered
These report
unknown:docs/observability.mddocuments this.Validation
cargo test -p pplx-space-metrics --lib sandbox::apicovers four cases:sandbox.api.createdinherit the request scope, and reportunknownoutside it.cargo test -p pplx-space-api --lib client_concurrency::tests::client_id_tagchecks that only allowlisted headers are named, and that missing, empty and unlisted headers readunknown.cargo clippy --locked -p pplx-space-metrics -p pplx-space-api --all-features --tests -- -D warningspasses.Severity and risk
Severity: observability gap. On-call can't tell which caller is driving create, connect or kill latency and error spikes.
Risk: the tag set grows on existing metrics, which is bounded as described above. Datadog queries that don't group by
client_idare unaffected. Every sandbox route now runs one header read and one allowlist lookup. Roll back by reverting this PR.