Merge "Add extra OEMCrypto metrics"
This commit is contained in:
@@ -227,8 +227,7 @@ void CryptoSession::Init() {
|
|||||||
sts = OEMCrypto_SetSandbox(
|
sts = OEMCrypto_SetSandbox(
|
||||||
reinterpret_cast<const uint8_t*>(sandbox_id.c_str()),
|
reinterpret_cast<const uint8_t*>(sandbox_id.c_str()),
|
||||||
sandbox_id.length());
|
sandbox_id.length());
|
||||||
// TODO(blueeyes): it might be worth saving the sandbox id in a
|
metrics_->oemcrypto_set_sandbox_.Record(sandbox_id);
|
||||||
// metric.
|
|
||||||
}
|
}
|
||||||
M_TIME(sts = OEMCrypto_Initialize(), metrics_, oemcrypto_initialize_,
|
M_TIME(sts = OEMCrypto_Initialize(), metrics_, oemcrypto_initialize_,
|
||||||
sts);
|
sts);
|
||||||
@@ -1868,6 +1867,7 @@ bool CryptoSession::GetResourceRatingTier(SecurityLevel security_level,
|
|||||||
}
|
}
|
||||||
WithOecReadLock("GetResourceRatingTier", [&] {
|
WithOecReadLock("GetResourceRatingTier", [&] {
|
||||||
*tier = OEMCrypto_ResourceRatingTier(security_level);
|
*tier = OEMCrypto_ResourceRatingTier(security_level);
|
||||||
|
metrics_->oemcrypto_resource_rating_tier_.Record(*tier);
|
||||||
});
|
});
|
||||||
if (*tier < RESOURCE_RATING_TIER_LOW || *tier > RESOURCE_RATING_TIER_HIGH) {
|
if (*tier < RESOURCE_RATING_TIER_LOW || *tier > RESOURCE_RATING_TIER_HIGH) {
|
||||||
uint32_t api_version;
|
uint32_t api_version;
|
||||||
@@ -1938,6 +1938,7 @@ CdmResponseType CryptoSession::SetDecryptHash(
|
|||||||
sts = OEMCrypto_SetDecryptHash(
|
sts = OEMCrypto_SetDecryptHash(
|
||||||
oec_session_id_, frame_number,
|
oec_session_id_, frame_number,
|
||||||
reinterpret_cast<const uint8_t*>(hash.data()), hash.size());
|
reinterpret_cast<const uint8_t*>(hash.data()), hash.size());
|
||||||
|
metrics_->oemcrypto_set_decrypt_hash_.Increment(sts);
|
||||||
});
|
});
|
||||||
|
|
||||||
return MapOEMCryptoResult(sts, SET_DECRYPT_HASH_ERROR, "SetDecryptHash");
|
return MapOEMCryptoResult(sts, SET_DECRYPT_HASH_ERROR, "SetDecryptHash");
|
||||||
@@ -2279,6 +2280,7 @@ CdmResponseType CryptoSession::CreateUsageTableHeader(
|
|||||||
reinterpret_cast<uint8_t*>(
|
reinterpret_cast<uint8_t*>(
|
||||||
const_cast<char*>(usage_table_header->data())),
|
const_cast<char*>(usage_table_header->data())),
|
||||||
&usage_table_header_size);
|
&usage_table_header_size);
|
||||||
|
metrics_->oemcrypto_create_usage_table_header_.Increment(result);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (result == OEMCrypto_ERROR_SHORT_BUFFER) {
|
if (result == OEMCrypto_ERROR_SHORT_BUFFER) {
|
||||||
@@ -2289,6 +2291,7 @@ CdmResponseType CryptoSession::CreateUsageTableHeader(
|
|||||||
reinterpret_cast<uint8_t*>(
|
reinterpret_cast<uint8_t*>(
|
||||||
const_cast<char*>(usage_table_header->data())),
|
const_cast<char*>(usage_table_header->data())),
|
||||||
&usage_table_header_size);
|
&usage_table_header_size);
|
||||||
|
metrics_->oemcrypto_create_usage_table_header_.Increment(result);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2310,6 +2313,7 @@ CdmResponseType CryptoSession::LoadUsageTableHeader(
|
|||||||
requested_security_level_,
|
requested_security_level_,
|
||||||
reinterpret_cast<const uint8_t*>(usage_table_header.data()),
|
reinterpret_cast<const uint8_t*>(usage_table_header.data()),
|
||||||
usage_table_header.size());
|
usage_table_header.size());
|
||||||
|
metrics_->oemcrypto_load_usage_table_header_.Increment(result);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (result != OEMCrypto_SUCCESS) {
|
if (result != OEMCrypto_SUCCESS) {
|
||||||
@@ -2352,6 +2356,7 @@ CdmResponseType CryptoSession::CreateUsageEntry(uint32_t* entry_number) {
|
|||||||
OEMCryptoResult result;
|
OEMCryptoResult result;
|
||||||
WithOecWriteLock("CreateUsageEntry", [&] {
|
WithOecWriteLock("CreateUsageEntry", [&] {
|
||||||
result = OEMCrypto_CreateNewUsageEntry(oec_session_id_, entry_number);
|
result = OEMCrypto_CreateNewUsageEntry(oec_session_id_, entry_number);
|
||||||
|
metrics_->oemcrypto_create_new_usage_entry_.Increment(result);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (result != OEMCrypto_SUCCESS) {
|
if (result != OEMCrypto_SUCCESS) {
|
||||||
@@ -2382,13 +2387,14 @@ CdmResponseType CryptoSession::LoadUsageEntry(
|
|||||||
oec_session_id_, entry_number,
|
oec_session_id_, entry_number,
|
||||||
reinterpret_cast<const uint8_t*>(usage_entry.data()),
|
reinterpret_cast<const uint8_t*>(usage_entry.data()),
|
||||||
usage_entry.size());
|
usage_entry.size());
|
||||||
|
metrics_->oemcrypto_load_usage_entry_.Increment(result);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (result != OEMCrypto_SUCCESS) {
|
if (result != OEMCrypto_SUCCESS) {
|
||||||
if (result == OEMCrypto_WARNING_GENERATION_SKEW) {
|
if (result == OEMCrypto_WARNING_GENERATION_SKEW) {
|
||||||
LOGW("LoadUsageEntry: OEMCrypto_LoadUsageEntry warning: generation skew");
|
LOGW("LoadUsageEntry: OEMCrypto_LoadUsageEntry warning: generation skew");
|
||||||
} else {
|
} else {
|
||||||
LOGE("LoadUsageTableHeader: OEMCrypto_LoadUsageEntry error: %d", result);
|
LOGE("LoadUsageEntry: OEMCrypto_LoadUsageEntry error: %d", result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2474,6 +2480,7 @@ CdmResponseType CryptoSession::ShrinkUsageTableHeader(
|
|||||||
result = OEMCrypto_ShrinkUsageTableHeader(
|
result = OEMCrypto_ShrinkUsageTableHeader(
|
||||||
requested_security_level_, new_entry_count, NULL,
|
requested_security_level_, new_entry_count, NULL,
|
||||||
&usage_table_header_len);
|
&usage_table_header_len);
|
||||||
|
metrics_->oemcrypto_shrink_usage_table_header_.Increment(result);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (result == OEMCrypto_ERROR_SHORT_BUFFER) {
|
if (result == OEMCrypto_ERROR_SHORT_BUFFER) {
|
||||||
@@ -2485,6 +2492,7 @@ CdmResponseType CryptoSession::ShrinkUsageTableHeader(
|
|||||||
reinterpret_cast<uint8_t*>(
|
reinterpret_cast<uint8_t*>(
|
||||||
const_cast<char*>(usage_table_header->data())),
|
const_cast<char*>(usage_table_header->data())),
|
||||||
&usage_table_header_len);
|
&usage_table_header_len);
|
||||||
|
metrics_->oemcrypto_shrink_usage_table_header_.Increment(result);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2502,6 +2510,7 @@ CdmResponseType CryptoSession::MoveUsageEntry(uint32_t new_entry_number) {
|
|||||||
OEMCryptoResult result;
|
OEMCryptoResult result;
|
||||||
WithOecWriteLock("MoveUsageEntry", [&] {
|
WithOecWriteLock("MoveUsageEntry", [&] {
|
||||||
result = OEMCrypto_MoveEntry(oec_session_id_, new_entry_number);
|
result = OEMCrypto_MoveEntry(oec_session_id_, new_entry_number);
|
||||||
|
metrics_->oemcrypto_move_entry_.Increment(result);
|
||||||
});
|
});
|
||||||
|
|
||||||
return MapOEMCryptoResult(
|
return MapOEMCryptoResult(
|
||||||
@@ -2550,6 +2559,7 @@ bool CryptoSession::CreateOldUsageEntry(
|
|||||||
reinterpret_cast<uint8_t*>(const_cast<char*>(client_mac_key.data())),
|
reinterpret_cast<uint8_t*>(const_cast<char*>(client_mac_key.data())),
|
||||||
reinterpret_cast<const uint8_t*>(provider_session_token.data()),
|
reinterpret_cast<const uint8_t*>(provider_session_token.data()),
|
||||||
provider_session_token.size());
|
provider_session_token.size());
|
||||||
|
metrics_->oemcrypto_create_old_usage_entry_.Increment(result);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (result != OEMCrypto_SUCCESS) {
|
if (result != OEMCrypto_SUCCESS) {
|
||||||
@@ -2570,6 +2580,7 @@ CdmResponseType CryptoSession::CopyOldUsageEntry(
|
|||||||
oec_session_id_,
|
oec_session_id_,
|
||||||
reinterpret_cast<const uint8_t*>(provider_session_token.data()),
|
reinterpret_cast<const uint8_t*>(provider_session_token.data()),
|
||||||
provider_session_token.size());
|
provider_session_token.size());
|
||||||
|
metrics_->oemcrypto_copy_old_usage_entry_.Increment(result);
|
||||||
});
|
});
|
||||||
|
|
||||||
return MapOEMCryptoResult(
|
return MapOEMCryptoResult(
|
||||||
|
|||||||
@@ -254,6 +254,26 @@ class CryptoMetrics {
|
|||||||
oemcrypto_update_usage_table_;
|
oemcrypto_update_usage_table_;
|
||||||
CounterMetric<kOemCryptoResultFieldNumber, OEMCryptoResult>
|
CounterMetric<kOemCryptoResultFieldNumber, OEMCryptoResult>
|
||||||
oemcrypto_update_usage_entry_;
|
oemcrypto_update_usage_entry_;
|
||||||
|
CounterMetric<kOemCryptoResultFieldNumber, OEMCryptoResult>
|
||||||
|
oemcrypto_create_usage_table_header_;
|
||||||
|
CounterMetric<kOemCryptoResultFieldNumber, OEMCryptoResult>
|
||||||
|
oemcrypto_load_usage_table_header_;
|
||||||
|
CounterMetric<kOemCryptoResultFieldNumber, OEMCryptoResult>
|
||||||
|
oemcrypto_shrink_usage_table_header_;
|
||||||
|
CounterMetric<kOemCryptoResultFieldNumber, OEMCryptoResult>
|
||||||
|
oemcrypto_create_new_usage_entry_;
|
||||||
|
CounterMetric<kOemCryptoResultFieldNumber, OEMCryptoResult>
|
||||||
|
oemcrypto_load_usage_entry_;
|
||||||
|
CounterMetric<kOemCryptoResultFieldNumber, OEMCryptoResult>
|
||||||
|
oemcrypto_move_entry_;
|
||||||
|
CounterMetric<kOemCryptoResultFieldNumber, OEMCryptoResult>
|
||||||
|
oemcrypto_create_old_usage_entry_;
|
||||||
|
CounterMetric<kOemCryptoResultFieldNumber, OEMCryptoResult>
|
||||||
|
oemcrypto_copy_old_usage_entry_;
|
||||||
|
ValueMetric<std::string> oemcrypto_set_sandbox_;
|
||||||
|
CounterMetric<kOemCryptoResultFieldNumber, OEMCryptoResult>
|
||||||
|
oemcrypto_set_decrypt_hash_;
|
||||||
|
ValueMetric<uint32_t> oemcrypto_resource_rating_tier_;
|
||||||
};
|
};
|
||||||
|
|
||||||
// This class contains session-scoped metrics. All properties and
|
// This class contains session-scoped metrics. All properties and
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ message WvCdmMetrics {
|
|||||||
|
|
||||||
// This contains metrics that were captured at the CryptoSession level. These
|
// This contains metrics that were captured at the CryptoSession level. These
|
||||||
// include CryptoSession metrics and most OEMCrypto metrics.
|
// include CryptoSession metrics and most OEMCrypto metrics.
|
||||||
// next id: 62
|
// next id: 73
|
||||||
message CryptoMetrics {
|
message CryptoMetrics {
|
||||||
// Crypto Session Metrics.
|
// Crypto Session Metrics.
|
||||||
optional ValueMetric crypto_session_security_level = 1;
|
optional ValueMetric crypto_session_security_level = 1;
|
||||||
@@ -162,6 +162,17 @@ message WvCdmMetrics {
|
|||||||
optional ValueMetric oemcrypto_usage_table_support = 54;
|
optional ValueMetric oemcrypto_usage_table_support = 54;
|
||||||
repeated CounterMetric oemcrypto_update_usage_table = 55;
|
repeated CounterMetric oemcrypto_update_usage_table = 55;
|
||||||
repeated CounterMetric oemcrypto_update_usage_entry = 57;
|
repeated CounterMetric oemcrypto_update_usage_entry = 57;
|
||||||
|
repeated CounterMetric oemcrypto_create_usage_table_header = 62;
|
||||||
|
repeated CounterMetric oemcrypto_load_usage_table_header = 63;
|
||||||
|
repeated CounterMetric oemcrypto_shrink_usage_table_header = 64;
|
||||||
|
repeated CounterMetric oemcrypto_create_new_usage_entry = 65;
|
||||||
|
repeated CounterMetric oemcrypto_load_usage_entry = 66;
|
||||||
|
repeated CounterMetric oemcrypto_move_entry = 67;
|
||||||
|
repeated CounterMetric oemcrypto_create_old_usage_entry = 68;
|
||||||
|
repeated CounterMetric oemcrypto_copy_old_usage_entry = 69;
|
||||||
|
optional ValueMetric oemcrypto_set_sandbox = 70;
|
||||||
|
repeated CounterMetric oemcrypto_set_decrypt_hash = 71;
|
||||||
|
optional ValueMetric oemcrypto_resource_rating_tier = 72;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This contains metrics that were captured within a CdmSession. This contains
|
// This contains metrics that were captured within a CdmSession. This contains
|
||||||
|
|||||||
@@ -161,7 +161,29 @@ void CryptoMetrics::Serialize(WvCdmMetrics::CryptoMetrics *crypto_metrics)
|
|||||||
oemcrypto_update_usage_table_.ToProto(
|
oemcrypto_update_usage_table_.ToProto(
|
||||||
crypto_metrics->mutable_oemcrypto_update_usage_table());
|
crypto_metrics->mutable_oemcrypto_update_usage_table());
|
||||||
oemcrypto_update_usage_entry_.ToProto(
|
oemcrypto_update_usage_entry_.ToProto(
|
||||||
crypto_metrics->mutable_oemcrypto_update_usage_entry());
|
crypto_metrics->mutable_oemcrypto_update_usage_entry());
|
||||||
|
oemcrypto_create_usage_table_header_.ToProto(
|
||||||
|
crypto_metrics->mutable_oemcrypto_create_usage_table_header());
|
||||||
|
oemcrypto_load_usage_table_header_.ToProto(
|
||||||
|
crypto_metrics->mutable_oemcrypto_load_usage_table_header());
|
||||||
|
oemcrypto_shrink_usage_table_header_.ToProto(
|
||||||
|
crypto_metrics->mutable_oemcrypto_shrink_usage_table_header());
|
||||||
|
oemcrypto_create_new_usage_entry_.ToProto(
|
||||||
|
crypto_metrics->mutable_oemcrypto_create_new_usage_entry());
|
||||||
|
oemcrypto_load_usage_entry_.ToProto(
|
||||||
|
crypto_metrics->mutable_oemcrypto_load_usage_entry());
|
||||||
|
oemcrypto_move_entry_.ToProto(
|
||||||
|
crypto_metrics->mutable_oemcrypto_move_entry());
|
||||||
|
oemcrypto_create_old_usage_entry_.ToProto(
|
||||||
|
crypto_metrics->mutable_oemcrypto_create_old_usage_entry());
|
||||||
|
oemcrypto_copy_old_usage_entry_.ToProto(
|
||||||
|
crypto_metrics->mutable_oemcrypto_copy_old_usage_entry());
|
||||||
|
crypto_metrics->set_allocated_oemcrypto_set_sandbox(
|
||||||
|
oemcrypto_set_sandbox_.ToProto());
|
||||||
|
oemcrypto_set_decrypt_hash_.ToProto(
|
||||||
|
crypto_metrics->mutable_oemcrypto_set_decrypt_hash());
|
||||||
|
crypto_metrics->set_allocated_oemcrypto_resource_rating_tier(
|
||||||
|
oemcrypto_resource_rating_tier_.ToProto());
|
||||||
}
|
}
|
||||||
|
|
||||||
SessionMetrics::SessionMetrics() : session_id_(""), completed_(false) {}
|
SessionMetrics::SessionMetrics() : session_id_(""), completed_(false) {}
|
||||||
|
|||||||
@@ -413,6 +413,26 @@ TEST_F(CryptoMetricsTest, AllCryptoMetrics) {
|
|||||||
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED);
|
.Record(1.0, OEMCrypto_ERROR_INIT_FAILED);
|
||||||
crypto_metrics.oemcrypto_update_usage_table_
|
crypto_metrics.oemcrypto_update_usage_table_
|
||||||
.Increment(OEMCrypto_ERROR_INIT_FAILED);
|
.Increment(OEMCrypto_ERROR_INIT_FAILED);
|
||||||
|
crypto_metrics.oemcrypto_create_usage_table_header_
|
||||||
|
.Increment(OEMCrypto_ERROR_INIT_FAILED);
|
||||||
|
crypto_metrics.oemcrypto_load_usage_table_header_
|
||||||
|
.Increment(OEMCrypto_ERROR_INIT_FAILED);
|
||||||
|
crypto_metrics.oemcrypto_shrink_usage_table_header_
|
||||||
|
.Increment(OEMCrypto_ERROR_INIT_FAILED);
|
||||||
|
crypto_metrics.oemcrypto_create_new_usage_entry_
|
||||||
|
.Increment(OEMCrypto_ERROR_INIT_FAILED);
|
||||||
|
crypto_metrics.oemcrypto_load_usage_entry_
|
||||||
|
.Increment(OEMCrypto_ERROR_INIT_FAILED);
|
||||||
|
crypto_metrics.oemcrypto_move_entry_
|
||||||
|
.Increment(OEMCrypto_ERROR_INIT_FAILED);
|
||||||
|
crypto_metrics.oemcrypto_create_old_usage_entry_
|
||||||
|
.Increment(OEMCrypto_ERROR_INIT_FAILED);
|
||||||
|
crypto_metrics.oemcrypto_copy_old_usage_entry_
|
||||||
|
.Increment(OEMCrypto_ERROR_INIT_FAILED);
|
||||||
|
crypto_metrics.oemcrypto_set_sandbox_.Record("sandbox");
|
||||||
|
crypto_metrics.oemcrypto_set_decrypt_hash_
|
||||||
|
.Increment(OEMCrypto_ERROR_INIT_FAILED);
|
||||||
|
crypto_metrics.oemcrypto_resource_rating_tier_.Record(123);
|
||||||
|
|
||||||
WvCdmMetrics::CryptoMetrics actual;
|
WvCdmMetrics::CryptoMetrics actual;
|
||||||
crypto_metrics.Serialize(&actual);
|
crypto_metrics.Serialize(&actual);
|
||||||
@@ -481,6 +501,17 @@ TEST_F(CryptoMetricsTest, AllCryptoMetrics) {
|
|||||||
EXPECT_EQ(123, actual.oemcrypto_security_patch_level().int_value());
|
EXPECT_EQ(123, actual.oemcrypto_security_patch_level().int_value());
|
||||||
EXPECT_GT(actual.oemcrypto_select_key_time_us_size(), 0);
|
EXPECT_GT(actual.oemcrypto_select_key_time_us_size(), 0);
|
||||||
EXPECT_GT(actual.oemcrypto_update_usage_table_size(), 0);
|
EXPECT_GT(actual.oemcrypto_update_usage_table_size(), 0);
|
||||||
|
EXPECT_GT(actual.oemcrypto_create_usage_table_header_size(), 0);
|
||||||
|
EXPECT_GT(actual.oemcrypto_load_usage_table_header_size(), 0);
|
||||||
|
EXPECT_GT(actual.oemcrypto_shrink_usage_table_header_size(), 0);
|
||||||
|
EXPECT_GT(actual.oemcrypto_create_new_usage_entry_size(), 0);
|
||||||
|
EXPECT_GT(actual.oemcrypto_load_usage_entry_size(), 0);
|
||||||
|
EXPECT_GT(actual.oemcrypto_move_entry_size(), 0);
|
||||||
|
EXPECT_GT(actual.oemcrypto_create_old_usage_entry_size(), 0);
|
||||||
|
EXPECT_GT(actual.oemcrypto_copy_old_usage_entry_size(), 0);
|
||||||
|
EXPECT_EQ("sandbox", actual.oemcrypto_set_sandbox().string_value());
|
||||||
|
EXPECT_GT(actual.oemcrypto_set_decrypt_hash_size(), 0);
|
||||||
|
EXPECT_EQ(123, actual.oemcrypto_resource_rating_tier().int_value());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace metrics
|
} // namespace metrics
|
||||||
|
|||||||
Reference in New Issue
Block a user