зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1187760 - Add telemetry to record navigator.requestMediaKeySystemAccess latency. r=edwin,vladan
This commit is contained in:
Родитель
4ebdbb181a
Коммит
1dce7bcb10
|
@ -2841,8 +2841,11 @@ Navigator::RequestMediaKeySystemAccess(const nsAString& aKeySystem,
|
|||
EME_LOG(logMsg.get());
|
||||
|
||||
nsCOMPtr<nsIGlobalObject> go = do_QueryInterface(mWindow);
|
||||
nsRefPtr<DetailedPromise> promise = DetailedPromise::Create(go, aRv,
|
||||
NS_LITERAL_CSTRING("navigator.requestMediaKeySystemAccess"));
|
||||
nsRefPtr<DetailedPromise> promise =
|
||||
DetailedPromise::Create(go, aRv,
|
||||
NS_LITERAL_CSTRING("navigator.requestMediaKeySystemAccess"),
|
||||
Telemetry::VIDEO_EME_REQUEST_SUCCESS_LATENCY_MS,
|
||||
Telemetry::VIDEO_EME_REQUEST_FAILURE_LATENCY_MS);
|
||||
if (aRv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -16,12 +16,24 @@ DetailedPromise::DetailedPromise(nsIGlobalObject* aGlobal,
|
|||
: Promise(aGlobal)
|
||||
, mName(aName)
|
||||
, mResponded(false)
|
||||
, mStartTime(TimeStamp::Now())
|
||||
{
|
||||
}
|
||||
|
||||
DetailedPromise::DetailedPromise(nsIGlobalObject* aGlobal,
|
||||
const nsACString& aName,
|
||||
Telemetry::ID aSuccessLatencyProbe,
|
||||
Telemetry::ID aFailureLatencyProbe)
|
||||
: DetailedPromise(aGlobal, aName)
|
||||
{
|
||||
mSuccessLatencyProbe.Construct(aSuccessLatencyProbe);
|
||||
mFailureLatencyProbe.Construct(aFailureLatencyProbe);
|
||||
}
|
||||
|
||||
DetailedPromise::~DetailedPromise()
|
||||
{
|
||||
MOZ_ASSERT(mResponded == IsPending());
|
||||
MaybeReportTelemetry(Failed);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -31,7 +43,7 @@ DetailedPromise::MaybeReject(nsresult aArg, const nsACString& aReason)
|
|||
PromiseFlatCString(aReason).get());
|
||||
EME_LOG(msg.get());
|
||||
|
||||
mResponded = true;
|
||||
MaybeReportTelemetry(Failed);
|
||||
|
||||
LogToBrowserConsole(NS_ConvertUTF8toUTF16(msg));
|
||||
|
||||
|
@ -56,5 +68,35 @@ DetailedPromise::Create(nsIGlobalObject* aGlobal,
|
|||
return aRv.Failed() ? nullptr : promise.forget();
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<DetailedPromise>
|
||||
DetailedPromise::Create(nsIGlobalObject* aGlobal,
|
||||
ErrorResult& aRv,
|
||||
const nsACString& aName,
|
||||
Telemetry::ID aSuccessLatencyProbe,
|
||||
Telemetry::ID aFailureLatencyProbe)
|
||||
{
|
||||
nsRefPtr<DetailedPromise> promise = new DetailedPromise(aGlobal, aName, aSuccessLatencyProbe, aFailureLatencyProbe);
|
||||
promise->CreateWrapper(nullptr, aRv);
|
||||
return aRv.Failed() ? nullptr : promise.forget();
|
||||
}
|
||||
|
||||
void
|
||||
DetailedPromise::MaybeReportTelemetry(Status aStatus)
|
||||
{
|
||||
if (mResponded) {
|
||||
return;
|
||||
}
|
||||
mResponded = true;
|
||||
if (!mSuccessLatencyProbe.WasPassed() || !mFailureLatencyProbe.WasPassed()) {
|
||||
return;
|
||||
}
|
||||
uint32_t latency = (TimeStamp::Now() - mStartTime).ToMilliseconds();
|
||||
EME_LOG("%s %s latency %ums reported via telemetry", mName.get(),
|
||||
((aStatus == Succeeded) ? "succcess" : "failure"), latency);
|
||||
Telemetry::ID tid = (aStatus == Succeeded) ? mSuccessLatencyProbe.Value()
|
||||
: mFailureLatencyProbe.Value();
|
||||
Telemetry::Accumulate(tid, latency);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#define __DetailedPromise_h__
|
||||
|
||||
#include "mozilla/dom/Promise.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "EMEUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -22,13 +23,21 @@ class DetailedPromise : public Promise
|
|||
{
|
||||
public:
|
||||
static already_AddRefed<DetailedPromise>
|
||||
Create(nsIGlobalObject* aGlobal, ErrorResult& aRv, const nsACString& aName);
|
||||
Create(nsIGlobalObject* aGlobal,
|
||||
ErrorResult& aRv,
|
||||
const nsACString& aName);
|
||||
|
||||
static already_AddRefed<DetailedPromise>
|
||||
Create(nsIGlobalObject* aGlobal, ErrorResult& aRv,
|
||||
const nsACString& aName,
|
||||
Telemetry::ID aSuccessLatencyProbe,
|
||||
Telemetry::ID aFailureLatencyProbe);
|
||||
|
||||
template <typename T>
|
||||
void MaybeResolve(const T& aArg)
|
||||
{
|
||||
EME_LOG("%s promise resolved", mName.get());
|
||||
mResponded = true;
|
||||
MaybeReportTelemetry(Succeeded);
|
||||
Promise::MaybeResolve<T>(aArg);
|
||||
}
|
||||
|
||||
|
@ -39,11 +48,23 @@ public:
|
|||
void MaybeReject(ErrorResult&, const nsACString& aReason);
|
||||
|
||||
private:
|
||||
explicit DetailedPromise(nsIGlobalObject* aGlobal, const nsACString& aName);
|
||||
explicit DetailedPromise(nsIGlobalObject* aGlobal,
|
||||
const nsACString& aName);
|
||||
|
||||
explicit DetailedPromise(nsIGlobalObject* aGlobal,
|
||||
const nsACString& aName,
|
||||
Telemetry::ID aSuccessLatencyProbe,
|
||||
Telemetry::ID aFailureLatencyProbe);
|
||||
virtual ~DetailedPromise();
|
||||
|
||||
enum Status { Succeeded, Failed };
|
||||
void MaybeReportTelemetry(Status aStatus);
|
||||
|
||||
nsCString mName;
|
||||
bool mResponded;
|
||||
TimeStamp mStartTime;
|
||||
Optional<Telemetry::ID> mSuccessLatencyProbe;
|
||||
Optional<Telemetry::ID> mFailureLatencyProbe;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -9383,6 +9383,24 @@
|
|||
"releaseChannelCollection": "opt-out",
|
||||
"description": "Reason for reporting the Adobe CDM to be unsupported. (1 = NOT_WINDOWS; 2 = WINDOWS_VERSION)"
|
||||
},
|
||||
"VIDEO_EME_REQUEST_SUCCESS_LATENCY_MS": {
|
||||
"alert_emails": ["cpearce@mozilla.com"],
|
||||
"expires_in_version": "50",
|
||||
"kind": "exponential",
|
||||
"high": "60000",
|
||||
"n_buckets": 60,
|
||||
"releaseChannelCollection": "opt-out",
|
||||
"description": "Time spent waiting for a navigator.requestMediaKeySystemAccess call to succeed."
|
||||
},
|
||||
"VIDEO_EME_REQUEST_FAILURE_LATENCY_MS": {
|
||||
"alert_emails": ["cpearce@mozilla.com"],
|
||||
"expires_in_version": "50",
|
||||
"kind": "exponential",
|
||||
"high": "60000",
|
||||
"n_buckets": 60,
|
||||
"releaseChannelCollection": "opt-out",
|
||||
"description": "Time spent waiting for a navigator.requestMediaKeySystemAccess call to fail."
|
||||
},
|
||||
"FXA_CONFIGURED": {
|
||||
"alert_emails": ["fx-team@mozilla.com"],
|
||||
"expires_in_version": "45",
|
||||
|
|
Загрузка…
Ссылка в новой задаче