Generated file

Copy as Markdown

Other Tools

// AUTOGENERATED BY glean_parser. DO NOT EDIT.
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_GleanDomMediaWebspeechMetrics_h
#define mozilla_GleanDomMediaWebspeechMetrics_h
#include "mozilla/glean/bindings/MetricTypes.h"
namespace mozilla::glean {
namespace media_speech_recognition {
/**
* generated from media.speech_recognition.availability
*/
enum class AvailabilityLabel: uint16_t {
eUnavailable = 0,
eDownloadable = 1,
eDownloading = 2,
eAvailable = 3,
e__Other__,
};
/**
* The number of times SpeechRecognition.available() resolved, keyed by the AvailabilityStatus it resolved with. Shows how often pages find the model missing rather than ready.
*/
constexpr impl::Labeled<impl::CounterMetric<impl::CounterType::eBaseOrLabeled>, AvailabilityLabel> availability(4371);
/**
* generated from media.speech_recognition.error
*/
enum class ErrorLabel: uint16_t {
eNoSpeech = 0,
eAborted = 1,
eAudioCapture = 2,
eNetwork = 3,
eNotAllowed = 4,
eServiceNotAllowed = 5,
eBadGrammar = 6,
eLanguageNotSupported = 7,
ePhrasesNotSupported = 8,
e__Other__,
};
/**
* The number of `error` events fired at a SpeechRecognition object, keyed by error code. Only a subset of the codes defined by the spec is currently reachable, so a count on any of the others is itself noteworthy.
* This does not reconcile with the `error` outcomes of `session_ended`, by construction: an error can be fired before the session reaches [[started]], and such a session records neither `session_started` nor `session_ended`. This metric therefore normally exceeds those outcomes, and `init_failure` accounts for the difference.
* The codes the spec makes us fire are also coarser than the causes behind them - four distinct causes all surface as `service-not-allowed` - so `init_failure` is what tells those apart.
*/
constexpr impl::Labeled<impl::CounterMetric<impl::CounterType::eBaseOrLabeled>, ErrorLabel> error(4372);
/**
* generated from media.speech_recognition.inference_realtime_factor
* The mean of how much faster than real time the audio chunks in a session were processed, as a multiple of real time times 100: 400 means 4x faster than real time. Under 100 means the recognizer fell behind. One sample is recorded per session in the inference process.
* The range reaches 100x because hardware that handles this model comfortably sits well above 20x, which would otherwise pile every such session into the top bucket and saturate the high percentiles. These bounds also put a bucket boundary exactly at 100, so "fell behind real time" is a clean cut rather than a threshold buried mid-bucket.
*/
constexpr impl::CustomDistributionMetric inference_realtime_factor(4373);
/**
* generated from media.speech_recognition.init_failure
*/
enum class InitFailureLabel: uint16_t {
eLanguageNotSupported = 0,
eModelInstallUnavailable = 1,
eBackendCreationFailed = 2,
eConcurrentSession = 3,
eNoUtilityProcess = 4,
eModelNotInstalled = 5,
eModelFetchFailed = 6,
eModelFdFailed = 7,
eThreadCreationFailed = 8,
eEngineLibraryLoadFailed = 9,
eModelLoadFailed = 10,
eStreamBeginFailed = 11,
e__Other__,
};
/**
* Why a recognition session failed to start, recorded wherever the cause is still known: the content process for the first three labels, the inference process for the rest. The spec-mandated DOM error code is coarser than this, so this is what tells apart the causes that share one: `concurrent_session`, `language_not_supported`, `model_install_unavailable` and `backend_creation_failed` all reach content as `service-not-allowed`, and every inference-process failure below reaches it as `network`.
* `language_not_supported` is recorded before the session reaches [[started]], so it has no `session_started` and no `session_ended`; it is exactly the count that makes `error` and `session_ended` disagree.
* The labels name the step that failed rather than a category, so that a spike says where init broke and not merely that it did.
*/
constexpr impl::Labeled<impl::CounterMetric<impl::CounterType::eBaseOrLabeled>, InitFailureLabel> init_failure(4374);
/**
* generated from media.speech_recognition.model_load_time
* How long the engine took to load the model, which reads the whole GGUF into memory. Recorded in the inference process.
* Only recorded when the load succeeds, so read it against `init_failure.model_load_failed` rather than alone.
*/
constexpr impl::TimingDistributionMetric model_load_time(4375);
/**
* generated from media.speech_recognition.result_latency
* The mean end-to-end latency of results in a recognition session, from the capture time of the audio each result covers to the moment the `result` event is dispatched in the content process. One sample per session that produced results.
*/
constexpr impl::TimingDistributionMetric result_latency(4376);
/**
* generated from media.speech_recognition.session_ended
*/
struct SessionEndedExtra {
mozilla::Maybe<uint32_t> duration;
mozilla::Maybe<nsCString> errorCode;
mozilla::Maybe<nsCString> outcome;
mozilla::Maybe<nsCString> sessionId;
std::tuple<nsTArray<nsCString>, nsTArray<nsCString>> ToFfiExtra() const {
nsTArray<nsCString> extraKeys;
nsTArray<nsCString> extraValues;
if (duration) {
extraKeys.AppendElement()->AssignASCII("duration");
extraValues.AppendElement()->AppendInt(duration.value());
}
if (errorCode) {
extraKeys.AppendElement()->AssignASCII("error_code");
extraValues.EmplaceBack(errorCode.value());
}
if (outcome) {
extraKeys.AppendElement()->AssignASCII("outcome");
extraValues.EmplaceBack(outcome.value());
}
if (sessionId) {
extraKeys.AppendElement()->AssignASCII("session_id");
extraValues.EmplaceBack(sessionId.value());
}
return std::make_tuple(std::move(extraKeys), std::move(extraValues));
}
};
/**
* Recorded when a speech recognition session that had reached [[started]] tears down, whatever the reason. Does not record any recognized text or audio.
*/
constexpr impl::EventMetric<SessionEndedExtra> session_ended(4377);
/**
* generated from media.speech_recognition.session_init_time
* The duration between start() and the time the model is ready for recognition.
* Only recorded when init succeeds, so read it against the `init_failure` totals rather than alone: a regression that turns slow inits into outright failures makes this metric look better.
*/
constexpr impl::TimingDistributionMetric session_init_time(4378);
/**
* generated from media.speech_recognition.session_started
*/
struct SessionStartedExtra {
mozilla::Maybe<nsCString> lang;
mozilla::Maybe<nsCString> langSource;
mozilla::Maybe<nsCString> modelId;
mozilla::Maybe<nsCString> modelLocale;
mozilla::Maybe<nsCString> sessionId;
std::tuple<nsTArray<nsCString>, nsTArray<nsCString>> ToFfiExtra() const {
nsTArray<nsCString> extraKeys;
nsTArray<nsCString> extraValues;
if (lang) {
extraKeys.AppendElement()->AssignASCII("lang");
extraValues.EmplaceBack(lang.value());
}
if (langSource) {
extraKeys.AppendElement()->AssignASCII("lang_source");
extraValues.EmplaceBack(langSource.value());
}
if (modelId) {
extraKeys.AppendElement()->AssignASCII("model_id");
extraValues.EmplaceBack(modelId.value());
}
if (modelLocale) {
extraKeys.AppendElement()->AssignASCII("model_locale");
extraValues.EmplaceBack(modelLocale.value());
}
if (sessionId) {
extraKeys.AppendElement()->AssignASCII("session_id");
extraValues.EmplaceBack(sessionId.value());
}
return std::make_tuple(std::move(extraKeys), std::move(extraValues));
}
};
/**
* Recorded when a speech recognition session reaches the spec's [[started]] state, that is once the backend has been created and start() has not thrown. It does not record any recognized text or audio.
* Paired with `session_ended`; a `session_started` without a matching `session_ended` indicates a session lost to a crash or a disorderly shutdown.
*/
constexpr impl::EventMetric<SessionStartedExtra> session_started(4379);
}
} // namespace mozilla::glean
#endif // mozilla_GleanDomMediaWebspeechMetrics_h