Creates a new license request latency metric
Previously, we did not have a license request latency metric. This is a notable limitation in our metrics. This adds a metric that captures the timing between a GenerateKeyRequest and an AddKey operation. Bug: 72994956 Test: New unit tests. Google Play Change-Id: If99c187399c02f9b5d4c355732af7588bbbefb11
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#include "file_store.h"
|
||||
#include "license_request.h"
|
||||
#include "log.h"
|
||||
#include "metrics.pb.h"
|
||||
#include "OEMCryptoCENC.h"
|
||||
#include "properties.h"
|
||||
#include "scoped_ptr.h"
|
||||
@@ -26,6 +27,9 @@
|
||||
|
||||
namespace wvcdm {
|
||||
|
||||
using drm_metrics::WvCdmMetrics;
|
||||
using drm_metrics::DistributionMetric;
|
||||
|
||||
namespace {
|
||||
|
||||
// Http OK response code.
|
||||
@@ -460,12 +464,43 @@ class WvCdmEngineTest : public WvCdmEnginePreProvTest {
|
||||
CdmKeySetId key_set_id;
|
||||
EXPECT_EQ(KEY_ADDED,
|
||||
cdm_engine_.AddKey(session_id_, resp, &key_set_id));
|
||||
VerifyLicenseRequestLatency(CdmKeyRequestType::kKeyRequestTypeInitial,
|
||||
*cdm_engine_.GetMetrics());
|
||||
}
|
||||
|
||||
void VerifyRenewalKeyResponse(const std::string& server_url,
|
||||
const std::string& client_auth) {
|
||||
std::string resp = GetKeyRequestResponse(server_url, client_auth);
|
||||
EXPECT_EQ(KEY_ADDED, cdm_engine_.RenewKey(session_id_, resp));
|
||||
VerifyLicenseRequestLatency(CdmKeyRequestType::kKeyRequestTypeRenewal,
|
||||
*cdm_engine_.GetMetrics());
|
||||
}
|
||||
|
||||
void VerifyLicenseRequestLatency(
|
||||
CdmKeyRequestType key_request_type,
|
||||
const metrics::EngineMetrics& engine_metrics) {
|
||||
WvCdmMetrics metrics_proto;
|
||||
engine_metrics.Serialize(&metrics_proto);
|
||||
bool has_request_type = false;
|
||||
for (int i = 0; i < metrics_proto.session_metrics_size(); i++) {
|
||||
WvCdmMetrics::SessionMetrics session_metrics =
|
||||
metrics_proto.session_metrics(i);
|
||||
for (int j = 0;
|
||||
j < session_metrics.cdm_session_license_request_latency_ms_size();
|
||||
j++) {
|
||||
DistributionMetric latency_distribution =
|
||||
session_metrics.cdm_session_license_request_latency_ms(j);
|
||||
if (latency_distribution.attributes().key_request_type()
|
||||
== key_request_type && latency_distribution.operation_count() > 0) {
|
||||
has_request_type = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
std::string serialized_metrics;
|
||||
ASSERT_TRUE(metrics_proto.SerializeToString(&serialized_metrics));
|
||||
EXPECT_TRUE(has_request_type)
|
||||
<< "Expected request type " << key_request_type << " was not found. "
|
||||
<< "metrics: " << wvcdm::b2a_hex(serialized_metrics);
|
||||
}
|
||||
|
||||
std::string server_url_;
|
||||
|
||||
Reference in New Issue
Block a user