Skip to content

Commit

Permalink
jinx: add metric for empty candidates
Browse files Browse the repository at this point in the history
As outlined in the linked bug, we have seen some odd behaviour with
candidates added to text suggestion requests when debugging. This CL
adds a new metric in light of this to ensure this is no a widespread
issue in our experiment user population.

BUG=b:284768533

Change-Id: I4f1fdb534f4eef1ea08b27f2323eec91175f5243
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4572745
Commit-Queue: Curtis McMullan <curtismcmullan@chromium.org>
Reviewed-by: Darren Shen <shend@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1150185}
  • Loading branch information
curtismcmullan authored and Chromium LUCI CQ committed May 29, 2023
1 parent 4ca8d9d commit 566299a
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
9 changes: 9 additions & 0 deletions chrome/browser/ash/input_method/suggestions_service_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "base/functional/bind.h"
#include "base/metrics/field_trial_params.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "chrome/browser/ash/input_method/suggestion_enums.h"
#include "chromeos/services/machine_learning/public/cpp/service_connection.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
Expand Down Expand Up @@ -105,6 +106,11 @@ void RecordRequestCandidates(
ToSuggestionType(suggestion_mode));
}

void RecordEmptyCandidate(const ime::AssistiveSuggestionMode& suggestion_mode) {
UMA_HISTOGRAM_ENUMERATION("InputMethod.Assistive.MultiWord.EmptyCandidate",
ToSuggestionType(suggestion_mode));
}

void RecordCandidatesGenerated(AssistiveSuggestionMode suggestion_mode) {
base::UmaHistogramEnumeration(
"InputMethod.Assistive.MultiWord.CandidatesGenerated",
Expand Down Expand Up @@ -155,6 +161,9 @@ void SuggestionsServiceClient::RequestSuggestions(
auto next_word_candidate = NextWordCompletionCandidate::New();
next_word_candidate->text = candidate.text;
next_word_candidate->normalized_score = candidate.score;
if (next_word_candidate->text.empty()) {
RecordEmptyCandidate(suggestion_mode);
}
query->next_word_candidates.push_back(std::move(next_word_candidate));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,36 @@ TEST_F(SuggestionsServiceClientTest,
/*expected_bucket_count=*/1);
}

TEST_F(SuggestionsServiceClientTest,
RecordsEmptyCandidateTextWhenCandidateTextMissing) {
SetTextSuggesterResult(SingleCandidate("hi there completion", 0.5f));

base::HistogramTester histogram_tester;
histogram_tester.ExpectTotalCount(
"InputMethod.Assistive.MultiWord.EmptyCandidate", 0);

client()->RequestSuggestions(
/*preceding_text=*/"hel",
/*suggestion_mode=*/AssistiveSuggestionMode::kCompletion,
/*completion_candidates=*/
std::vector<DecoderCompletionCandidate>{
DecoderCompletionCandidate{"hello", 0.1f},
DecoderCompletionCandidate{"", 0.01f},
DecoderCompletionCandidate{"", 0.001f},
},
/*callback=*/
base::BindLambdaForTesting(
[&](const std::vector<AssistiveSuggestion>& results) {}));
WaitForResults();

histogram_tester.ExpectTotalCount(
"InputMethod.Assistive.MultiWord.EmptyCandidate", 2);
histogram_tester.ExpectUniqueSample(
"InputMethod.Assistive.MultiWord.EmptyCandidate",
/*sample=*/MultiWordSuggestionType::kCompletion,
/*expected_bucket_count=*/2);
}

} // namespace
} // namespace input_method
} // namespace ash
13 changes: 13 additions & 0 deletions tools/metrics/histograms/metadata/input/histograms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,19 @@ chromium-metrics-reviews@google.com.
</summary>
</histogram>

<histogram name="InputMethod.Assistive.MultiWord.EmptyCandidate"
enum="IMEAssistiveMultiWordSuggestionType" expires_after="2023-10-01">
<owner>curtismcmullan@google.com</owner>
<owner>essential-inputs-team@google.com</owner>
<summary>
This histogram records when an empty completion candidate is added to a
suggestion generation request to the machine learning service. An empty
completion candidate in this context means a candidate with an empty string.
This is an invalid state and should never happen. The metric is recorded
once per empty candidate found.
</summary>
</histogram>

<histogram name="InputMethod.Assistive.MultiWord.ImplicitAcceptance"
enum="IMEAssistiveMultiWordSuggestionType" expires_after="2023-10-01">
<owner>curtismcmullan@google.com</owner>
Expand Down

0 comments on commit 566299a

Please sign in to comment.