diff options
author | ambrosin <ambrosin@google.com> | 2022-02-23 00:30:24 -0800 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-02-23 00:31:08 -0800 |
commit | 16cca6aba3d5a516f8e519dca8b47d4af9c903e4 (patch) | |
tree | 87dee192b03400349813082e4170bf18e4f898ad /cc/monitoring | |
parent | 8c3f1cdc3e9d3f7cc0fceda0dc118492d02b8b9e (diff) | |
download | tink-16cca6aba3d5a516f8e519dca8b47d4af9c903e4.tar.gz |
Add definition of `MonitoringContext` and `MonitoringEvent`.
PiperOrigin-RevId: 430387082
Diffstat (limited to 'cc/monitoring')
-rw-r--r-- | cc/monitoring/monitoring.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/cc/monitoring/monitoring.h b/cc/monitoring/monitoring.h index d690cf835..e31647500 100644 --- a/cc/monitoring/monitoring.h +++ b/cc/monitoring/monitoring.h @@ -94,6 +94,38 @@ class MonitoringKeySetInfo { const uint32_t primary_key_id_; }; +// Defines a context for monitoring events, wich includes the primitive and API +// used, and info on the keyset. +class MonitoringContext { + public: + // Construct a new constext for the given `primitive`, `api_function` and + // `keyset_info`. + MonitoringContext(absl::string_view primitive, absl::string_view api_function, + const MonitoringKeySetInfo& keyset_info) + : primitive_(primitive), + api_function_(api_function), + keyset_info_(keyset_info) {} + + // Returns the primitive. + std::string GetPrimitive() const { return primitive_; } + // Returns the API function. + std::string GetApi() const { return api_function_; } + // Returns a constant reference to the keyset info. + const MonitoringKeySetInfo& GetKeySetInfo() { return keyset_info_; } + + private: + const std::string primitive_; + const std::string api_function_; + const MonitoringKeySetInfo keyset_info_; +}; + +// A monitoring event, which includes the ID of the key used and the amount of +// data processed by this event. +struct MonitoringEvent { + int32_t key_id; + int64_t num_bytes_as_input; +}; + } // namespace tink } // namespace crypto |