Bug 1695378: add a telemetry probe to measure A/V call length. r=jib

Differential Revision: https://phabricator.services.mozilla.com/D106696
This commit is contained in:
Nils Ohlmeier [:drno] 2021-04-02 02:12:19 +00:00
parent 75950e479b
commit 4e07c4d3c3
3 changed files with 25 additions and 4 deletions

View File

@ -212,10 +212,16 @@ namespace mozilla {
void PeerConnectionAutoTimer::RegisterConnection() { mRefCnt++; }
void PeerConnectionAutoTimer::UnregisterConnection() {
void PeerConnectionAutoTimer::UnregisterConnection(bool aContainedAV) {
MOZ_ASSERT(mRefCnt);
mRefCnt--;
mUsedAV |= aContainedAV;
if (mRefCnt == 0) {
if (mUsedAV) {
Telemetry::Accumulate(
Telemetry::WEBRTC_AV_CALL_DURATION,
static_cast<uint32_t>((TimeStamp::Now() - mStart).ToSeconds()));
}
Telemetry::Accumulate(
Telemetry::WEBRTC_CALL_DURATION,
static_cast<uint32_t>((TimeStamp::Now() - mStart).ToSeconds()));
@ -2068,7 +2074,8 @@ void PeerConnectionImpl::RecordEndOfCallTelemetry() {
MOZ_RELEASE_ASSERT(mWindow);
auto found = sCallDurationTimers.find(mWindow->WindowID());
if (found != sCallDurationTimers.end()) {
found->second.UnregisterConnection();
found->second.UnregisterConnection((type & kAudioTypeMask) ||
(type & kVideoTypeMask));
if (found->second.IsStopped()) {
sCallDurationTimers.erase(found);
}

View File

@ -124,14 +124,16 @@ class PCUuidGenerator : public mozilla::JsepUuidGenerator {
// count and records the elapsed time when the count falls to zero. The
// elapsed time is recorded in seconds.
struct PeerConnectionAutoTimer {
PeerConnectionAutoTimer() : mRefCnt(0), mStart(TimeStamp::Now()){};
PeerConnectionAutoTimer()
: mRefCnt(0), mStart(TimeStamp::Now()), mUsedAV(false){};
void RegisterConnection();
void UnregisterConnection();
void UnregisterConnection(bool aContainedAV);
bool IsStopped();
private:
int64_t mRefCnt;
TimeStamp mStart;
bool mUsedAV;
};
// Enter an API call and check that the state is OK,

View File

@ -10817,6 +10817,18 @@
"description": "The length of time (in seconds) that a call lasted.",
"releaseChannelCollection": "opt-out"
},
"WEBRTC_AV_CALL_DURATION": {
"bug_numbers": [1695378],
"record_in_processes": ["content"],
"products": ["firefox", "fennec"],
"alert_emails": ["webrtc-telemetry-alerts@mozilla.com", "nohlmeier@mozilla.com"],
"expires_in_version": "never",
"kind": "exponential",
"high": 10000,
"n_buckets": 100,
"description": "The length of time (in seconds) that a call with audio or video in it lasted.",
"releaseChannelCollection": "opt-out"
},
"WEBRTC_CALL_COUNT_3": {
"record_in_processes": ["main", "content"],
"products": ["firefox", "fennec"],