0

Deleted Audio service connection duration UMA logging

Metrics have not been monitored for a while.

Bug: 1384869
Change-Id: I73cde3bb7741c0389fb1dba9199c7bde2410ffb9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4085422
Auto-Submit: Olga Sharonova <olka@chromium.org>
Commit-Queue: Olga Sharonova <olka@chromium.org>
Reviewed-by: Fredrik Hernqvist <fhernqvist@google.com>
Commit-Queue: Fredrik Hernqvist <fhernqvist@google.com>
Cr-Commit-Position: refs/heads/main@{#1080291}
This commit is contained in:
Olga Sharonova
2022-12-07 12:47:37 +00:00
committed by Chromium LUCI CQ
parent 0022631eb8
commit 9d5c8e3ec7
6 changed files with 0 additions and 159 deletions

@ -60,8 +60,6 @@ source_set("audio") {
"service.h",
"service_factory.cc",
"service_factory.h",
"service_metrics.cc",
"service_metrics.h",
"snooper_node.cc",
"snooper_node.h",
"stream_factory.cc",
@ -174,7 +172,6 @@ source_set("tests") {
"public/cpp/input_ipc_unittest.cc",
"public/cpp/output_device_unittest.cc",
"realtime_audio_thread_test.cc",
"service_metrics_unittest.cc",
"snooper_node_unittest.cc",
"sync_reader_unittest.cc",
"test/audio_system_to_service_adapter_test.cc",

@ -23,7 +23,6 @@
#include "services/audio/debug_recording.h"
#include "services/audio/device_notifier.h"
#include "services/audio/log_factory_manager.h"
#include "services/audio/service_metrics.h"
#include "services/audio/system_info.h"
#if BUILDFLAG(IS_APPLE)
@ -64,17 +63,12 @@ Service::Service(std::unique_ptr<AudioManagerAccessor> audio_manager_accessor,
audio_manager_accessor_->GetAudioManager()->SetAecDumpRecordingManager(
aecdump_recording_manager_->AsWeakPtr());
#endif
metrics_ =
std::make_unique<ServiceMetrics>(base::DefaultTickClock::GetInstance());
}
Service::~Service() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
TRACE_EVENT0("audio", "audio::Service::~Service");
metrics_.reset();
// Stop all streams cleanly before shutting down the audio manager.
stream_factory_.reset();

@ -38,7 +38,6 @@ namespace audio {
class DebugRecording;
class DeviceNotifier;
class LogFactoryManager;
class ServiceMetrics;
class SystemInfo;
class Service final : public mojom::AudioService {
@ -132,7 +131,6 @@ class Service final : public mojom::AudioService {
absl::optional<StreamFactory> stream_factory_;
std::unique_ptr<DeviceNotifier> device_notifier_;
std::unique_ptr<LogFactoryManager> log_factory_manager_;
std::unique_ptr<ServiceMetrics> metrics_;
};
} // namespace audio

@ -1,50 +0,0 @@
// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "services/audio/service_metrics.h"
#include "base/metrics/histogram_macros.h"
#include "base/time/tick_clock.h"
#include "base/trace_event/trace_event.h"
namespace audio {
ServiceMetrics::ServiceMetrics(const base::TickClock* clock) : clock_(clock) {}
ServiceMetrics::~ServiceMetrics() {
LogHasNoConnectionsDuration();
}
void ServiceMetrics::HasConnections() {
TRACE_EVENT_NESTABLE_ASYNC_BEGIN0("audio", "Audio service has connections",
TRACE_ID_LOCAL(this));
has_connections_start_ = clock_->NowTicks();
LogHasNoConnectionsDuration();
}
void ServiceMetrics::HasNoConnections() {
TRACE_EVENT_NESTABLE_ASYNC_END0("audio", "Audio service has connections",
TRACE_ID_LOCAL(this));
has_no_connections_start_ = clock_->NowTicks();
DCHECK_NE(base::TimeTicks(), has_connections_start_);
UMA_HISTOGRAM_CUSTOM_TIMES("Media.AudioService.HasConnectionsDuration",
clock_->NowTicks() - has_connections_start_,
base::TimeDelta(), base::Days(7), 50);
has_connections_start_ = base::TimeTicks();
}
void ServiceMetrics::LogHasNoConnectionsDuration() {
// Service shuts down without having accepted any connections in its lifetime
// or with active connections, meaning there is no "no connection" interval in
// progress.
if (has_no_connections_start_.is_null())
return;
UMA_HISTOGRAM_CUSTOM_TIMES("Media.AudioService.HasNoConnectionsDuration",
clock_->NowTicks() - has_no_connections_start_,
base::TimeDelta(), base::Minutes(10), 50);
has_no_connections_start_ = base::TimeTicks();
}
} // namespace audio

@ -1,39 +0,0 @@
// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SERVICES_AUDIO_SERVICE_METRICS_H_
#define SERVICES_AUDIO_SERVICE_METRICS_H_
#include "base/memory/raw_ptr.h"
#include "base/time/time.h"
namespace base {
class TickClock;
}
namespace audio {
class ServiceMetrics {
public:
explicit ServiceMetrics(const base::TickClock* clock);
ServiceMetrics(const ServiceMetrics&) = delete;
ServiceMetrics& operator=(const ServiceMetrics&) = delete;
~ServiceMetrics();
void HasConnections();
void HasNoConnections();
private:
void LogHasNoConnectionsDuration();
raw_ptr<const base::TickClock> clock_;
base::TimeTicks has_connections_start_;
base::TimeTicks has_no_connections_start_;
};
} // namespace audio
#endif // SERVICES_AUDIO_SERVICE_METRICS_H_

@ -1,59 +0,0 @@
// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "services/audio/service_metrics.h"
#include <memory>
#include "base/metrics/histogram_macros.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/simple_test_tick_clock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace audio {
TEST(AudioServiceMetricsTest, CreateDestroy_LogsUptime) {
base::SimpleTestTickClock test_clock;
test_clock.SetNowTicks(base::TimeTicks::Now());
base::HistogramTester histogram_tester;
std::unique_ptr<ServiceMetrics> metrics =
std::make_unique<ServiceMetrics>(&test_clock);
test_clock.Advance(base::Days(6));
metrics.reset();
}
TEST(AudioServiceMetricsTest, AddRemoveConnection_LogsHasConnectionDuration) {
base::SimpleTestTickClock test_clock;
test_clock.SetNowTicks(base::TimeTicks::Now());
base::HistogramTester histogram_tester;
ServiceMetrics metrics(&test_clock);
metrics.HasConnections();
test_clock.Advance(base::Minutes(42));
metrics.HasNoConnections();
histogram_tester.ExpectTimeBucketCount(
"Media.AudioService.HasConnectionsDuration", base::Minutes(42), 1);
histogram_tester.ExpectTotalCount("Media.AudioService.HasConnectionsDuration",
1);
}
TEST(AudioServiceMetricsTest, RemoveAddConnection_LogsHasNoConnectionDuration) {
base::SimpleTestTickClock test_clock;
test_clock.SetNowTicks(base::TimeTicks::Now());
base::HistogramTester histogram_tester;
ServiceMetrics metrics(&test_clock);
metrics.HasConnections();
test_clock.Advance(base::Minutes(5));
metrics.HasNoConnections();
test_clock.Advance(base::Milliseconds(10));
metrics.HasConnections();
histogram_tester.ExpectTimeBucketCount(
"Media.AudioService.HasNoConnectionsDuration", base::Milliseconds(10), 1);
histogram_tester.ExpectTotalCount(
"Media.AudioService.HasNoConnectionsDuration", 1);
}
} // namespace audio