Fix single embed_sparse and embed_all gRPC request metrics - #919
Open
shoemoney wants to merge 1 commit into
Open
Fix single embed_sparse and embed_all gRPC request metrics#919shoemoney wants to merge 1 commit into
shoemoney wants to merge 1 commit into
Conversation
gRPC embed_sparse and embed_all incremented te_request_count
{method="single"} twice per request, once before inference and again
after a successful response, and never recorded te_request_success
{method="single"}. One successful request therefore counted as two, and
a success/error ratio derived from these counters reported a permanent
100% failure rate for sparse and all-embedding gRPC traffic.
Record the post-success event as te_request_success instead, matching
the sibling paths that already implement the count then success pair
correctly: the same file's embed method (grpc/server.rs:595 count, 606
success) and all HTTP embed handlers (http/server.rs 603/621, 792/808,
970/986, 1174/1192). Open PR huggingface#917 fixes the identical double-increment
in the HTTP /predict single arm and its body explicitly states "Batch
and gRPC paths are also outside this fix", naming the sibling it did
not fix.
The counter calls move into record_single_request and
record_single_success helpers with a recorder-backed unit test that
needs no model or network, the same pattern PR huggingface#917 uses.
Related to huggingface#879.
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.
What does this PR do?
The gRPC
embed_sparseandembed_allhandlers incrementte_request_count{method="single"}twice per request, once before inference and again after a successful response, and never recordte_request_success{method="single"}. One successful request therefore counts as two, and a success/error ratio derived from these counters reports a permanent 100% failure rate for sparse and all-embedding gRPC traffic.This PR records the post-success event as
te_request_successinstead, atrouter/src/grpc/server.rs:647androuter/src/grpc/server.rs:689on main. The sibling paths already implement the count then success pair correctly: the same file'sembedmethod (grpc/server.rs 595/606) and the HTTP embed handlers (http/server.rs 603/621, 792/808, 970/986, 1174/1192). #917 fixes the identical double-increment in the HTTP/predictsingle arm and its description explicitly leaves the gRPC paths out of scope; this PR covers that named remainder.Following the pattern of #917, the two counter calls move into
record_single_request/record_single_successhelpers with a recorder-backed unit test that needs no model, network, or accelerator. With the buggy counter name in place the test fails with count=2 and success=0; with this fix it passes. The already-correctembed, predict, rerank, and batch call sites are intentionally unchanged to keep the diff minimal.Related to #879.
Validation
cargo test -p text-embeddings-router --no-default-features --features grpc,candle --lib(1 passed)rustfmt --check router/src/grpc/server.rs --edition 2021cargo clippy -p text-embeddings-router --no-default-features --features grpc,candle --lib(passes; only pre-existing warnings, includingresult_large_erron the untouched auth closure at grpc/server.rs:1484)Before submitting
instasnapshots? Added a recorder-backed unit test; no snapshot changes needed.