[PCLF] Add possibility to use new perf metrics api in NetworkQualityMetricsReporter
Bug: b/246095034 Change-Id: I5198d73aaf2b32b59c9c15504628d0edd2bd9885 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/276201 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Artem Titov <titovartem@webrtc.org> Cr-Commit-Position: refs/heads/main@{#38146}
This commit is contained in:

committed by
WebRTC LUCI CQ

parent
e11d5e378c
commit
86f2022f0e
@ -853,6 +853,8 @@ if (!build_with_chromium) {
|
|||||||
"../../../api:peer_connection_quality_test_fixture_api",
|
"../../../api:peer_connection_quality_test_fixture_api",
|
||||||
"../../../api:rtc_stats_api",
|
"../../../api:rtc_stats_api",
|
||||||
"../../../api:track_id_stream_info_map",
|
"../../../api:track_id_stream_info_map",
|
||||||
|
"../../../api/test/metrics:metric",
|
||||||
|
"../../../api/test/metrics:metrics_logger_and_exporter",
|
||||||
"../../../api/units:data_size",
|
"../../../api/units:data_size",
|
||||||
"../../../rtc_base:criticalsection",
|
"../../../rtc_base:criticalsection",
|
||||||
"../../../rtc_base:rtc_event",
|
"../../../rtc_base:rtc_event",
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include "api/stats/rtc_stats.h"
|
#include "api/stats/rtc_stats.h"
|
||||||
#include "api/stats/rtcstats_objects.h"
|
#include "api/stats/rtcstats_objects.h"
|
||||||
|
#include "api/test/metrics/metric.h"
|
||||||
#include "rtc_base/event.h"
|
#include "rtc_base/event.h"
|
||||||
#include "system_wrappers/include/field_trial.h"
|
#include "system_wrappers/include/field_trial.h"
|
||||||
#include "test/testsupport/perf_test.h"
|
#include "test/testsupport/perf_test.h"
|
||||||
@ -21,6 +22,9 @@ namespace webrtc {
|
|||||||
namespace webrtc_pc_e2e {
|
namespace webrtc_pc_e2e {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
using ::webrtc::test::ImprovementDirection;
|
||||||
|
using ::webrtc::test::Unit;
|
||||||
|
|
||||||
constexpr TimeDelta kStatsWaitTimeout = TimeDelta::Seconds(1);
|
constexpr TimeDelta kStatsWaitTimeout = TimeDelta::Seconds(1);
|
||||||
|
|
||||||
// Field trial which controls whether to report standard-compliant bytes
|
// Field trial which controls whether to report standard-compliant bytes
|
||||||
@ -109,19 +113,22 @@ void NetworkQualityMetricsReporter::ReportStats(
|
|||||||
const std::string& network_label,
|
const std::string& network_label,
|
||||||
std::unique_ptr<EmulatedNetworkStats> stats,
|
std::unique_ptr<EmulatedNetworkStats> stats,
|
||||||
int64_t packet_loss) {
|
int64_t packet_loss) {
|
||||||
|
if (metrics_logger_ == nullptr) {
|
||||||
ReportResult("bytes_sent", network_label, stats->BytesSent().bytes(),
|
ReportResult("bytes_sent", network_label, stats->BytesSent().bytes(),
|
||||||
"sizeInBytes");
|
"sizeInBytes");
|
||||||
ReportResult("packets_sent", network_label, stats->PacketsSent(), "unitless");
|
ReportResult("packets_sent", network_label, stats->PacketsSent(),
|
||||||
ReportResult(
|
"unitless");
|
||||||
"average_send_rate", network_label,
|
ReportResult("average_send_rate", network_label,
|
||||||
stats->PacketsSent() >= 2 ? stats->AverageSendRate().bytes_per_sec() : 0,
|
stats->PacketsSent() >= 2
|
||||||
|
? stats->AverageSendRate().bytes_per_sec()
|
||||||
|
: 0,
|
||||||
"bytesPerSecond");
|
"bytesPerSecond");
|
||||||
ReportResult("bytes_discarded_no_receiver", network_label,
|
ReportResult("bytes_discarded_no_receiver", network_label,
|
||||||
stats->BytesDropped().bytes(), "sizeInBytes");
|
stats->BytesDropped().bytes(), "sizeInBytes");
|
||||||
ReportResult("packets_discarded_no_receiver", network_label,
|
ReportResult("packets_discarded_no_receiver", network_label,
|
||||||
stats->PacketsDropped(), "unitless");
|
stats->PacketsDropped(), "unitless");
|
||||||
ReportResult("bytes_received", network_label, stats->BytesReceived().bytes(),
|
ReportResult("bytes_received", network_label,
|
||||||
"sizeInBytes");
|
stats->BytesReceived().bytes(), "sizeInBytes");
|
||||||
ReportResult("packets_received", network_label, stats->PacketsReceived(),
|
ReportResult("packets_received", network_label, stats->PacketsReceived(),
|
||||||
"unitless");
|
"unitless");
|
||||||
ReportResult("average_receive_rate", network_label,
|
ReportResult("average_receive_rate", network_label,
|
||||||
@ -130,14 +137,55 @@ void NetworkQualityMetricsReporter::ReportStats(
|
|||||||
: 0,
|
: 0,
|
||||||
"bytesPerSecond");
|
"bytesPerSecond");
|
||||||
ReportResult("sent_packets_loss", network_label, packet_loss, "unitless");
|
ReportResult("sent_packets_loss", network_label, packet_loss, "unitless");
|
||||||
|
} else {
|
||||||
|
metrics_logger_->LogSingleValueMetric(
|
||||||
|
"bytes_sent", network_label, stats->BytesSent().bytes(), Unit::kBytes,
|
||||||
|
ImprovementDirection::kNeitherIsBetter);
|
||||||
|
metrics_logger_->LogSingleValueMetric(
|
||||||
|
"packets_sent", network_label, stats->PacketsSent(), Unit::kUnitless,
|
||||||
|
ImprovementDirection::kNeitherIsBetter);
|
||||||
|
metrics_logger_->LogSingleValueMetric(
|
||||||
|
"average_send_rate", network_label,
|
||||||
|
stats->PacketsSent() >= 2 ? stats->AverageSendRate().kbps() : 0,
|
||||||
|
Unit::kKilobitsPerSecond, ImprovementDirection::kNeitherIsBetter);
|
||||||
|
metrics_logger_->LogSingleValueMetric(
|
||||||
|
"bytes_discarded_no_receiver", network_label,
|
||||||
|
stats->BytesDropped().bytes(), Unit::kBytes,
|
||||||
|
ImprovementDirection::kNeitherIsBetter);
|
||||||
|
metrics_logger_->LogSingleValueMetric(
|
||||||
|
"packets_discarded_no_receiver", network_label, stats->PacketsDropped(),
|
||||||
|
Unit::kUnitless, ImprovementDirection::kNeitherIsBetter);
|
||||||
|
metrics_logger_->LogSingleValueMetric(
|
||||||
|
"bytes_received", network_label, stats->BytesReceived().bytes(),
|
||||||
|
Unit::kBytes, ImprovementDirection::kNeitherIsBetter);
|
||||||
|
metrics_logger_->LogSingleValueMetric(
|
||||||
|
"packets_received", network_label, stats->PacketsReceived(),
|
||||||
|
Unit::kUnitless, ImprovementDirection::kNeitherIsBetter);
|
||||||
|
metrics_logger_->LogSingleValueMetric(
|
||||||
|
"average_receive_rate", network_label,
|
||||||
|
stats->PacketsReceived() >= 2 ? stats->AverageReceiveRate().kbps() : 0,
|
||||||
|
Unit::kKilobitsPerSecond, ImprovementDirection::kNeitherIsBetter);
|
||||||
|
metrics_logger_->LogSingleValueMetric(
|
||||||
|
"sent_packets_loss", network_label, packet_loss, Unit::kUnitless,
|
||||||
|
ImprovementDirection::kNeitherIsBetter);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkQualityMetricsReporter::ReportPCStats(const std::string& pc_label,
|
void NetworkQualityMetricsReporter::ReportPCStats(const std::string& pc_label,
|
||||||
const PCStats& stats) {
|
const PCStats& stats) {
|
||||||
|
if (metrics_logger_ == nullptr) {
|
||||||
ReportResult("payload_bytes_received", pc_label,
|
ReportResult("payload_bytes_received", pc_label,
|
||||||
stats.payload_received.bytes(), "sizeInBytes");
|
stats.payload_received.bytes(), "sizeInBytes");
|
||||||
ReportResult("payload_bytes_sent", pc_label, stats.payload_sent.bytes(),
|
ReportResult("payload_bytes_sent", pc_label, stats.payload_sent.bytes(),
|
||||||
"sizeInBytes");
|
"sizeInBytes");
|
||||||
|
} else {
|
||||||
|
metrics_logger_->LogSingleValueMetric(
|
||||||
|
"payload_bytes_received", pc_label, stats.payload_received.bytes(),
|
||||||
|
Unit::kBytes, ImprovementDirection::kNeitherIsBetter);
|
||||||
|
metrics_logger_->LogSingleValueMetric(
|
||||||
|
"payload_bytes_sent", pc_label, stats.payload_sent.bytes(),
|
||||||
|
Unit::kBytes, ImprovementDirection::kNeitherIsBetter);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkQualityMetricsReporter::ReportResult(
|
void NetworkQualityMetricsReporter::ReportResult(
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "absl/strings/string_view.h"
|
#include "absl/strings/string_view.h"
|
||||||
|
#include "api/test/metrics/metrics_logger_and_exporter.h"
|
||||||
#include "api/test/network_emulation_manager.h"
|
#include "api/test/network_emulation_manager.h"
|
||||||
#include "api/test/peerconnection_quality_test_fixture.h"
|
#include "api/test/peerconnection_quality_test_fixture.h"
|
||||||
#include "api/test/track_id_stream_info_map.h"
|
#include "api/test/track_id_stream_info_map.h"
|
||||||
@ -29,7 +30,15 @@ class NetworkQualityMetricsReporter
|
|||||||
public:
|
public:
|
||||||
NetworkQualityMetricsReporter(EmulatedNetworkManagerInterface* alice_network,
|
NetworkQualityMetricsReporter(EmulatedNetworkManagerInterface* alice_network,
|
||||||
EmulatedNetworkManagerInterface* bob_network)
|
EmulatedNetworkManagerInterface* bob_network)
|
||||||
: alice_network_(alice_network), bob_network_(bob_network) {}
|
: NetworkQualityMetricsReporter(alice_network,
|
||||||
|
bob_network,
|
||||||
|
/*metrics_logger=*/nullptr) {}
|
||||||
|
NetworkQualityMetricsReporter(EmulatedNetworkManagerInterface* alice_network,
|
||||||
|
EmulatedNetworkManagerInterface* bob_network,
|
||||||
|
test::MetricsLoggerAndExporter* metrics_logger)
|
||||||
|
: alice_network_(alice_network),
|
||||||
|
bob_network_(bob_network),
|
||||||
|
metrics_logger_(metrics_logger) {}
|
||||||
~NetworkQualityMetricsReporter() override = default;
|
~NetworkQualityMetricsReporter() override = default;
|
||||||
|
|
||||||
// Network stats must be empty when this method will be invoked.
|
// Network stats must be empty when this method will be invoked.
|
||||||
@ -62,8 +71,9 @@ class NetworkQualityMetricsReporter
|
|||||||
|
|
||||||
std::string test_case_name_;
|
std::string test_case_name_;
|
||||||
|
|
||||||
EmulatedNetworkManagerInterface* alice_network_;
|
EmulatedNetworkManagerInterface* const alice_network_;
|
||||||
EmulatedNetworkManagerInterface* bob_network_;
|
EmulatedNetworkManagerInterface* const bob_network_;
|
||||||
|
test::MetricsLoggerAndExporter* const metrics_logger_;
|
||||||
Mutex lock_;
|
Mutex lock_;
|
||||||
std::map<std::string, PCStats> pc_stats_ RTC_GUARDED_BY(lock_);
|
std::map<std::string, PCStats> pc_stats_ RTC_GUARDED_BY(lock_);
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user