// Copyright 2017 Google Inc. All Rights Reserved. // // This file contains the declarations for the Metric class and related // types. #ifndef WVCDM_METRICS_METRIC_PUBLISHER_H_ #define WVCDM_METRICS_METRIC_PUBLISHER_H_ namespace wvcdm { namespace metrics { // The MetricNotification is implemented by the code that instantiates // MetricPublisher instances. The caller provides this MetricNotification // instance to MetricPublisher::Publish. In turn, Publish will make a call to // UpdateMetric for each value to be published. The Metric may contain zero or // more values to be updated. class MetricNotification { public: virtual ~MetricNotification() {}; // The metric_id is the metric name, plus the metric part name, and the // metric field name/value string. E.g. // name: "drm/cdm/decrypt/duration" // part: "mean" // field name/value string: "{error_code:0&buffer_size:1024}" // becomes: "drm/cdm/decrypt/duration/mean/{error_code:0&buffer_size:1024}". virtual void UpdateString(const std::string& metric_id, const std::string& value) = 0; virtual void UpdateInt32(const std::string& metric_id, int32_t value) = 0; virtual void UpdateInt64(const std::string& metric_id, int64_t value) = 0; virtual void UpdateDouble(const std::string& metric_id, double value) = 0; }; // This abstract class merely provides the definition for publishing the value // of the metric. class MetricPublisher { public: virtual ~MetricPublisher() { } // Publish metric values to the MetricNotification. |subscriber| must // not be null and is owned by the caller. virtual void Publish(MetricNotification* subscriber) = 0; }; } // namespace metrics } // namespace wvcdm #endif // WVCDM_METRICS_METRIC_PUBLISHER_H_