Source release 15.0.0
This commit is contained in:
@@ -80,6 +80,22 @@ void SetAttributeField<drm_metrics::Attributes::kKeyRequestTypeFieldNumber,
|
||||
attributes->set_key_request_type(key_request_type);
|
||||
}
|
||||
|
||||
template <>
|
||||
void SetAttributeField<drm_metrics::Attributes::kLicenseTypeFieldNumber,
|
||||
CdmLicenseType>(
|
||||
const CdmLicenseType &license_type,
|
||||
drm_metrics::Attributes *attributes) {
|
||||
attributes->set_license_type(license_type);
|
||||
}
|
||||
|
||||
template <>
|
||||
void SetAttributeField<drm_metrics::Attributes::kErrorDetailFieldNumber,
|
||||
int32_t>(
|
||||
const int32_t &error_detail,
|
||||
drm_metrics::Attributes *attributes) {
|
||||
attributes->set_error_detail(error_detail);
|
||||
}
|
||||
|
||||
template <>
|
||||
void SetAttributeField<0, util::Unused>(const util::Unused &,
|
||||
drm_metrics::Attributes *) {
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace metrics {
|
||||
|
||||
void BaseCounterMetric::Increment(const std::string &counter_key,
|
||||
int64_t value) {
|
||||
AutoLock lock(internal_lock_);
|
||||
std::unique_lock<std::mutex> lock(internal_lock_);
|
||||
|
||||
if (value_map_.find(counter_key) == value_map_.end()) {
|
||||
value_map_[counter_key] = value;
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace wvcdm {
|
||||
namespace metrics {
|
||||
|
||||
BaseEventMetric::~BaseEventMetric() {
|
||||
AutoLock lock(internal_lock_);
|
||||
std::unique_lock<std::mutex> lock(internal_lock_);
|
||||
|
||||
for (std::map<std::string, Distribution *>::iterator it = value_map_.begin();
|
||||
it != value_map_.end(); it++) {
|
||||
@@ -19,7 +19,7 @@ BaseEventMetric::~BaseEventMetric() {
|
||||
}
|
||||
|
||||
void BaseEventMetric::Record(const std::string &key, double value) {
|
||||
AutoLock lock(internal_lock_);
|
||||
std::unique_lock<std::mutex> lock(internal_lock_);
|
||||
|
||||
Distribution *distribution;
|
||||
|
||||
|
||||
@@ -46,6 +46,10 @@ message Attributes {
|
||||
optional uint32 event_type = 15;
|
||||
// Contains the CdmKeyRequestType defined in wv_cdm_types.h.
|
||||
optional uint32 key_request_type = 16;
|
||||
// Contains the CdmLicenseType defined in wv_cdm_types.h.
|
||||
optional uint32 license_type = 17;
|
||||
// Error detail supplemental to the error_code field.
|
||||
optional int32 error_detail = 18;
|
||||
}
|
||||
|
||||
// The Counter message is used to store a count value with an associated
|
||||
@@ -155,7 +159,7 @@ message WvCdmMetrics {
|
||||
|
||||
// This contains metrics that were captured within a CdmSession. This contains
|
||||
// nested CryptoMetrics that were captured in the context of the session.
|
||||
// next id: 8
|
||||
// next id: 9
|
||||
message SessionMetrics {
|
||||
optional ValueMetric session_id = 1;
|
||||
optional CryptoMetrics crypto_metrics = 2;
|
||||
@@ -164,11 +168,12 @@ message WvCdmMetrics {
|
||||
repeated CounterMetric cdm_session_restore_offline_session = 5;
|
||||
repeated CounterMetric cdm_session_restore_usage_session = 6;
|
||||
repeated DistributionMetric cdm_session_license_request_latency_ms = 7;
|
||||
optional ValueMetric oemcrypto_build_info = 8;
|
||||
}
|
||||
|
||||
// These are metrics recorded at the Engine level. This includes CryptoSession
|
||||
// metrics that were captured in the context of the engine.
|
||||
// next id: 29
|
||||
// next id: 31
|
||||
message EngineMetrics {
|
||||
optional CryptoMetrics crypto_metrics = 1;
|
||||
|
||||
@@ -200,6 +205,9 @@ message WvCdmMetrics {
|
||||
repeated CounterMetric cdm_engine_remove_usage_info = 26;
|
||||
repeated DistributionMetric cdm_engine_restore_key_time_us = 27;
|
||||
repeated CounterMetric cdm_engine_unprovision = 28;
|
||||
// OEMCrypto Initialize Metrics.
|
||||
optional ValueMetric level3_oemcrypto_initialization_error = 29;
|
||||
optional ValueMetric previous_oemcrypto_initialization_failure = 30;
|
||||
}
|
||||
|
||||
optional EngineMetrics engine_metrics = 1;
|
||||
|
||||
@@ -13,13 +13,15 @@ using ::google::protobuf::RepeatedPtrField;
|
||||
using ::wvcdm::metrics::EventMetric;
|
||||
|
||||
namespace {
|
||||
|
||||
// Helper struct for comparing session ids.
|
||||
struct CompareSessionIds {
|
||||
const std::string &target_;
|
||||
|
||||
CompareSessionIds(const wvcdm::CdmSessionId &target) : target_(target){};
|
||||
|
||||
bool operator()(const wvcdm::metrics::SessionMetrics *metrics) const {
|
||||
bool operator()(const std::shared_ptr<wvcdm::metrics::SessionMetrics> metrics)
|
||||
const {
|
||||
return metrics->GetSessionId() == target_;
|
||||
}
|
||||
};
|
||||
@@ -152,7 +154,7 @@ void CryptoMetrics::Serialize(WvCdmMetrics::CryptoMetrics *crypto_metrics)
|
||||
crypto_metrics->mutable_oemcrypto_update_usage_entry());
|
||||
}
|
||||
|
||||
SessionMetrics::SessionMetrics() {}
|
||||
SessionMetrics::SessionMetrics() : session_id_(""), completed_(false) {}
|
||||
|
||||
void SessionMetrics::Serialize(WvCdmMetrics::SessionMetrics *session_metrics)
|
||||
const {
|
||||
@@ -177,35 +179,55 @@ void SessionMetrics::SerializeSessionMetrics(
|
||||
session_metrics->mutable_cdm_session_restore_usage_session());
|
||||
cdm_session_license_request_latency_ms_.ToProto(
|
||||
session_metrics->mutable_cdm_session_license_request_latency_ms());
|
||||
session_metrics->set_allocated_oemcrypto_build_info(
|
||||
oemcrypto_build_info_.ToProto());
|
||||
}
|
||||
|
||||
OemCryptoDynamicAdapterMetrics::OemCryptoDynamicAdapterMetrics()
|
||||
: oemcrypto_initialization_mode_(),
|
||||
: level3_oemcrypto_initialization_error_(),
|
||||
oemcrypto_initialization_mode_(),
|
||||
previous_oemcrypto_initialization_failure_(),
|
||||
oemcrypto_l1_api_version_(),
|
||||
oemcrypto_l1_min_api_version_() {}
|
||||
|
||||
void OemCryptoDynamicAdapterMetrics::SetInitializationMode(
|
||||
OEMCryptoInitializationMode mode) {
|
||||
AutoLock lock(adapter_lock_);
|
||||
std::unique_lock<std::mutex> lock(adapter_lock_);
|
||||
oemcrypto_initialization_mode_.Record(mode);
|
||||
}
|
||||
|
||||
void OemCryptoDynamicAdapterMetrics::SetLevel3InitializationError(
|
||||
OEMCryptoInitializationMode mode) {
|
||||
std::unique_lock<std::mutex> lock(adapter_lock_);
|
||||
level3_oemcrypto_initialization_error_.Record(mode);
|
||||
}
|
||||
|
||||
void OemCryptoDynamicAdapterMetrics::SetPreviousInitializationFailure(
|
||||
OEMCryptoInitializationMode mode) {
|
||||
std::unique_lock<std::mutex> lock(adapter_lock_);
|
||||
previous_oemcrypto_initialization_failure_.Record(mode);
|
||||
}
|
||||
|
||||
void OemCryptoDynamicAdapterMetrics::SetL1ApiVersion(uint32_t version) {
|
||||
AutoLock lock(adapter_lock_);
|
||||
std::unique_lock<std::mutex> lock(adapter_lock_);
|
||||
oemcrypto_l1_api_version_.Record(version);
|
||||
}
|
||||
|
||||
void OemCryptoDynamicAdapterMetrics::SetL1MinApiVersion(uint32_t version) {
|
||||
AutoLock lock(adapter_lock_);
|
||||
std::unique_lock<std::mutex> lock(adapter_lock_);
|
||||
oemcrypto_l1_min_api_version_.Record(version);
|
||||
}
|
||||
|
||||
void OemCryptoDynamicAdapterMetrics::Serialize(
|
||||
WvCdmMetrics::EngineMetrics *engine_metrics) const {
|
||||
AutoLock lock(adapter_lock_);
|
||||
std::unique_lock<std::mutex> lock(adapter_lock_);
|
||||
|
||||
engine_metrics->set_allocated_level3_oemcrypto_initialization_error(
|
||||
oemcrypto_initialization_mode_.ToProto());
|
||||
engine_metrics->set_allocated_oemcrypto_initialization_mode(
|
||||
oemcrypto_initialization_mode_.ToProto());
|
||||
engine_metrics->set_allocated_previous_oemcrypto_initialization_failure(
|
||||
oemcrypto_initialization_mode_.ToProto());
|
||||
engine_metrics->set_allocated_oemcrypto_l1_api_version(
|
||||
oemcrypto_l1_api_version_.ToProto());
|
||||
engine_metrics->set_allocated_oemcrypto_l1_min_api_version(
|
||||
@@ -213,9 +235,11 @@ void OemCryptoDynamicAdapterMetrics::Serialize(
|
||||
}
|
||||
|
||||
void OemCryptoDynamicAdapterMetrics::Clear() {
|
||||
AutoLock lock(adapter_lock_);
|
||||
std::unique_lock<std::mutex> lock(adapter_lock_);
|
||||
|
||||
level3_oemcrypto_initialization_error_.Clear();
|
||||
oemcrypto_initialization_mode_.Clear();
|
||||
previous_oemcrypto_initialization_failure_.Clear();
|
||||
oemcrypto_l1_api_version_.Clear();
|
||||
oemcrypto_l1_min_api_version_.Clear();
|
||||
}
|
||||
@@ -235,36 +259,65 @@ EngineMetrics::EngineMetrics() {
|
||||
}
|
||||
|
||||
EngineMetrics::~EngineMetrics() {
|
||||
AutoLock lock(session_metrics_lock_);
|
||||
std::vector<SessionMetrics *>::iterator i;
|
||||
if (!session_metrics_list_.empty()) {
|
||||
LOGV("EngineMetrics::~EngineMetrics. Session count: %d",
|
||||
session_metrics_list_.size());
|
||||
std::unique_lock<std::mutex> lock(session_metrics_lock_);
|
||||
if (!active_session_metrics_list_.empty()
|
||||
|| !completed_session_metrics_list_.empty()) {
|
||||
LOGV("EngineMetrics::~EngineMetrics. Session counts: "
|
||||
"active %d. completed %d.", active_session_metrics_list_.size(),
|
||||
completed_session_metrics_list_.size());
|
||||
}
|
||||
for (i = session_metrics_list_.begin(); i != session_metrics_list_.end();
|
||||
i++) {
|
||||
delete *i;
|
||||
}
|
||||
session_metrics_list_.clear();
|
||||
}
|
||||
|
||||
SessionMetrics *EngineMetrics::AddSession() {
|
||||
AutoLock lock(session_metrics_lock_);
|
||||
SessionMetrics *metrics = new SessionMetrics();
|
||||
session_metrics_list_.push_back(metrics);
|
||||
return metrics;
|
||||
std::shared_ptr<SessionMetrics> EngineMetrics::AddSession() {
|
||||
std::unique_lock<std::mutex> lock(session_metrics_lock_);
|
||||
active_session_metrics_list_.push_back(std::make_shared<SessionMetrics>());
|
||||
return active_session_metrics_list_.back();
|
||||
}
|
||||
|
||||
void EngineMetrics::RemoveSession(wvcdm::CdmSessionId session_id) {
|
||||
AutoLock lock(session_metrics_lock_);
|
||||
session_metrics_list_.erase(
|
||||
std::remove_if(session_metrics_list_.begin(), session_metrics_list_.end(),
|
||||
std::unique_lock<std::mutex> lock(session_metrics_lock_);
|
||||
active_session_metrics_list_.erase(
|
||||
std::remove_if(active_session_metrics_list_.begin(),
|
||||
active_session_metrics_list_.end(),
|
||||
CompareSessionIds(session_id)),
|
||||
session_metrics_list_.end());
|
||||
active_session_metrics_list_.end());
|
||||
completed_session_metrics_list_.erase(
|
||||
std::remove_if(completed_session_metrics_list_.begin(),
|
||||
completed_session_metrics_list_.end(),
|
||||
CompareSessionIds(session_id)),
|
||||
completed_session_metrics_list_.end());
|
||||
}
|
||||
|
||||
void EngineMetrics::ConsolidateSessions() {
|
||||
auto completed_filter =
|
||||
[] (const std::shared_ptr<SessionMetrics>& session_metrics) {
|
||||
return session_metrics->IsCompleted();
|
||||
};
|
||||
|
||||
std::unique_lock<std::mutex> lock(session_metrics_lock_);
|
||||
std::copy_if(active_session_metrics_list_.begin(),
|
||||
active_session_metrics_list_.end(),
|
||||
std::back_inserter(completed_session_metrics_list_),
|
||||
completed_filter);
|
||||
active_session_metrics_list_.erase(
|
||||
std::remove_if(active_session_metrics_list_.begin(),
|
||||
active_session_metrics_list_.end(),
|
||||
completed_filter),
|
||||
active_session_metrics_list_.end());
|
||||
|
||||
// TODO(b/118664842): Add support to merge older metrics into one
|
||||
// consolidated metric.
|
||||
int excess_completed = completed_session_metrics_list_.size()
|
||||
- kMaxCompletedSessions;
|
||||
if (excess_completed > 0) {
|
||||
completed_session_metrics_list_.erase(
|
||||
completed_session_metrics_list_.begin(),
|
||||
completed_session_metrics_list_.begin() + excess_completed);
|
||||
}
|
||||
}
|
||||
|
||||
void EngineMetrics::Serialize(WvCdmMetrics *wv_metrics) const {
|
||||
AutoLock lock(session_metrics_lock_);
|
||||
std::unique_lock<std::mutex> lock(session_metrics_lock_);
|
||||
WvCdmMetrics::EngineMetrics *engine_metrics =
|
||||
wv_metrics->mutable_engine_metrics();
|
||||
// Serialize the most recent metrics from the OemCyrpto dynamic adapter.
|
||||
@@ -277,8 +330,12 @@ void EngineMetrics::Serialize(WvCdmMetrics *wv_metrics) const {
|
||||
}
|
||||
SerializeEngineMetrics(engine_metrics);
|
||||
|
||||
for (std::vector<metrics::SessionMetrics *>::const_iterator it =
|
||||
session_metrics_list_.begin(); it != session_metrics_list_.end(); it++) {
|
||||
for (auto it = completed_session_metrics_list_.begin();
|
||||
it != completed_session_metrics_list_.end(); it++) {
|
||||
(*it)->Serialize(wv_metrics->add_session_metrics());
|
||||
}
|
||||
for (auto it = active_session_metrics_list_.begin();
|
||||
it != active_session_metrics_list_.end(); it++) {
|
||||
(*it)->Serialize(wv_metrics->add_session_metrics());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,39 +1,23 @@
|
||||
#include "timer_metric.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
namespace wvcdm {
|
||||
namespace metrics {
|
||||
|
||||
void TimerMetric::Start() {
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
sec_ = tv.tv_sec;
|
||||
usec_ = tv.tv_usec;
|
||||
start_ = clock_.now();
|
||||
is_started_ = true;
|
||||
}
|
||||
|
||||
void TimerMetric::Clear() {
|
||||
is_started_ = false;
|
||||
sec_ = 0;
|
||||
usec_ = 0;
|
||||
}
|
||||
|
||||
double TimerMetric::AsMs() const {
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
return usec_ > tv.tv_usec ?
|
||||
(tv.tv_sec - sec_ - 1) * 1000.0 + (tv.tv_usec - usec_ + 1000000.0) / 1000.0 :
|
||||
(tv.tv_sec - sec_) * 1000.0 + (tv.tv_usec - usec_) / 1000.0;
|
||||
return (clock_.now() - start_) / std::chrono::milliseconds(1);
|
||||
}
|
||||
|
||||
double TimerMetric::AsUs() const {
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
return usec_ > tv.tv_usec ?
|
||||
(tv.tv_sec - sec_ - 1) * 1000000.0 + (tv.tv_usec - usec_ + 1000000.0) :
|
||||
(tv.tv_sec - sec_) * 1000000.0 + (tv.tv_usec - usec_);
|
||||
return (clock_.now() - start_) / std::chrono::microseconds(1);
|
||||
}
|
||||
|
||||
} // namespace metrics
|
||||
|
||||
@@ -53,6 +53,12 @@ void SetValue<unsigned long>(drm_metrics::ValueMetric *value_proto,
|
||||
value_proto->set_int_value((int64_t)value);
|
||||
}
|
||||
|
||||
template <>
|
||||
void SetValue<unsigned long long>(drm_metrics::ValueMetric *value_proto,
|
||||
const unsigned long long &value) {
|
||||
value_proto->set_int_value((int64_t)value);
|
||||
}
|
||||
|
||||
template <>
|
||||
void SetValue<bool>(drm_metrics::ValueMetric *value_proto,
|
||||
const bool &value) {
|
||||
|
||||
Reference in New Issue
Block a user