-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added UMA telemetry for Format Queries
Modifies the existing class `media::FormatSupportQueryMetrics` to report latency stats to UMA histograms, and does so on Gold builds. The existing log reporting has been retained for non-Gold builds. Added basic unit tests to verify that the UMA histograms are being reported correctly. b/329439820 Change-Id: Ie7f4e2e6c518d1c6c058fcbf62f046b56ea5f298
- Loading branch information
Showing
6 changed files
with
179 additions
and
29 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// Copyright 2024 The Cobalt Authors. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include "cobalt/media/base/format_support_query_metrics.h" | ||
|
||
#include <memory> | ||
|
||
#include "base/test/metrics/histogram_tester.h" | ||
#include "base/test/simple_test_tick_clock.h" | ||
#include "base/time/tick_clock.h" | ||
#include "base/time/time.h" | ||
#include "starboard/media.h" | ||
#include "testing/gtest/include/gtest/gtest.h" | ||
|
||
namespace cobalt { | ||
namespace media { | ||
namespace { | ||
|
||
constexpr char kUmaPrefix[] = "Cobalt.Media."; | ||
|
||
class FormatSupportQueryMetricsTest : public ::testing::Test { | ||
protected: | ||
FormatSupportQueryMetricsTest() : metrics_(&clock_) {} | ||
|
||
void SetUp() override { clock_.SetNowTicks(base::TimeTicks()); } | ||
|
||
base::HistogramTester histogram_tester_; | ||
base::SimpleTestTickClock clock_; | ||
|
||
FormatSupportQueryMetrics metrics_; | ||
}; | ||
|
||
TEST_F(FormatSupportQueryMetricsTest, | ||
ReportsMediaSourceIsTypeSupportedLatencyToUMA) { | ||
clock_.Advance(base::TimeDelta::FromMicroseconds(50)); | ||
|
||
metrics_.RecordAndLogQuery( | ||
FormatSupportQueryAction::MEDIA_SOURCE_IS_TYPE_SUPPORTED, "", "", | ||
kSbMediaSupportTypeNotSupported); | ||
|
||
auto counts = histogram_tester_.GetTotalCountsForPrefix(kUmaPrefix); | ||
EXPECT_EQ(1, counts.size()); | ||
|
||
histogram_tester_.ExpectUniqueSample( | ||
std::string(kUmaPrefix) + "MediaSource.IsTypeSupported.Timing", 50, 1); | ||
} | ||
|
||
TEST_F(FormatSupportQueryMetricsTest, | ||
ReportsHTMLMediaElementCanPlayTypeLatencyToUMA) { | ||
clock_.Advance(base::TimeDelta::FromMicroseconds(50)); | ||
|
||
metrics_.RecordAndLogQuery( | ||
FormatSupportQueryAction::HTML_MEDIA_ELEMENT_CAN_PLAY_TYPE, "", "", | ||
kSbMediaSupportTypeNotSupported); | ||
|
||
auto counts = histogram_tester_.GetTotalCountsForPrefix(kUmaPrefix); | ||
EXPECT_EQ(1, counts.size()); | ||
|
||
histogram_tester_.ExpectUniqueSample( | ||
std::string(kUmaPrefix) + "HTMLMediaElement.CanPlayType.Timing", 50, 1); | ||
} | ||
|
||
} // namespace | ||
} // namespace media | ||
} // namespace cobalt |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,6 +67,28 @@ Always run the pretty print utility on this file after editing: | |
</summary> | ||
</histogram> | ||
|
||
<histogram name="Cobalt.Media.HTMLMediaElement.CanPlayType.Timing" | ||
units="microseconds" expires_after="never"> | ||
<!-- expires-never: Needed for long-term tracking of format query latency. --> | ||
|
||
<owner>[email protected]</owner> | ||
<owner>[email protected]</owner> | ||
<summary> | ||
Timing data for calls to `HTMLMediaElement.canPlayType`. | ||
</summary> | ||
</histogram> | ||
|
||
<histogram name="Cobalt.Media.MediaSource.IsTypeSupported.Timing" | ||
units="microseconds" expires_after="never"> | ||
<!-- expires-never: Needed for long-term tracking of format query latency. --> | ||
|
||
<owner>[email protected]</owner> | ||
<owner>[email protected]</owner> | ||
<summary> | ||
Timing data for calls to `MediaSource.isTypeSupported`. | ||
</summary> | ||
</histogram> | ||
|
||
<histogram name="Cobalt.Media.PipelineStatus.AudioOnly" enum="PipelineStatus" | ||
expires_after="never"> | ||
<!-- expires-never: Needed for baseline Media pipeline health metric. --> | ||
|