Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
|
#include <metrics.h>
Public Member Functions | |
SimpleMetric (const std::string &key, const TUnit::type unit, const T &initial_value, const std::string &description="") | |
SimpleMetric (const std::string &key, const TUnit::type unit, const std::string &description="") | |
virtual | ~SimpleMetric () |
T | value () |
Returns the current value, updating it if necessary. Thread-safe. More... | |
void | set_value (const T &value) |
Sets the current value. Thread-safe. More... | |
void | Increment (const T &delta) |
Adds 'delta' to the current value atomically. More... | |
virtual void | ToJson (rapidjson::Document *document, rapidjson::Value *val) |
name, value, human_readable, description More... | |
virtual std::string | ToHumanReadable () |
virtual void | ToLegacyJson (rapidjson::Document *document) |
This method is kept for backwards-compatibility with CM5.0. More... | |
const TUnit::type | unit () const |
const TMetricKind::type | kind () const |
const std::string & | key () const |
const std::string & | description () const |
Protected Member Functions | |
virtual void | CalculateValue () |
void | AddStandardFields (rapidjson::Document *document, rapidjson::Value *val) |
Protected Attributes | |
const TUnit::type | unit_ |
Units of this metric. More... | |
boost::mutex | lock_ |
Guards access to value_. More... | |
T | value_ |
The current value of the metric. More... | |
const std::string | key_ |
Unique key identifying this metric. More... | |
const std::string | description_ |
A SimpleMetric has a value which is a simple primitive type: e.g. integers, strings and floats. It is parameterised not only by the type of its value, but by both the unit (e.g. bytes/s), drawn from TUnit and the 'kind' of the metric itself. The kind can be one of: 'gauge', which may increase or decrease over time, a 'counter' which is increasing only over time, or a 'property' which is not numeric. SimpleMetrics return their current value through the value() method. Access to value() is thread-safe. TODO: We can use type traits to select a more efficient lock-free implementation of value() etc. where it is safe to do so.
|
inline |
|
inline |
|
inlinevirtual |
|
protectedinherited |
Convenience method to add standard fields (name, description, human readable string) to 'val'.
Definition at line 46 of file metrics.cc.
References impala::name.
Referenced by impala::SetMetric< std::string >::ToJson(), impala::StatsMetric< double >::ToJson(), and impala::SimpleMetric< T, metric_kind >::ToJson().
|
inlineprotectedvirtual |
Called to compute value_ if necessary during calls to value(). The more natural approach would be to have virtual T value(), but that's not possible in C++. TODO: Should be cheap to have a blank implementation, but if required we can cause the compiler to avoid calling this entirely through a compile-time constant.
Definition at line 175 of file metrics.h.
Referenced by impala::SimpleMetric< T, metric_kind >::value().
|
inlineinherited |
Definition at line 72 of file metrics.h.
References impala::Metric::description_.
|
inline |
Adds 'delta' to the current value atomically.
Definition at line 131 of file metrics.h.
References impala::Metric::key(), impala::SimpleMetric< T, metric_kind >::kind(), impala::SimpleMetric< T, metric_kind >::lock_, and impala::SimpleMetric< T, metric_kind >::value_.
|
inlineinherited |
Definition at line 71 of file metrics.h.
References impala::Metric::key_.
Referenced by impala::SimpleMetric< T, metric_kind >::Increment().
|
inline |
Definition at line 167 of file metrics.h.
Referenced by impala::SimpleMetric< T, metric_kind >::Increment(), and impala::SimpleMetric< T, metric_kind >::ToJson().
|
inline |
Sets the current value. Thread-safe.
Definition at line 125 of file metrics.h.
References impala::SimpleMetric< T, metric_kind >::lock_, impala::SimpleMetric< T, metric_kind >::value(), and impala::SimpleMetric< T, metric_kind >::value_.
|
inlinevirtual |
Writes a human-readable representation of this metric to 'out'. This is the representation that is often displayed in webpages etc.
Implements impala::Metric.
Definition at line 156 of file metrics.h.
References impala::PrettyPrinter::Print(), impala::SimpleMetric< T, metric_kind >::unit(), and impala::SimpleMetric< T, metric_kind >::value().
|
inlinevirtual |
name, value, human_readable, description
Builds a new Value into 'val', using (if required) the allocator from 'document'. Should set the following fields where appropriate:
Implements impala::Metric.
Definition at line 140 of file metrics.h.
References impala::Metric::AddStandardFields(), impala::SimpleMetric< T, metric_kind >::kind(), impala::PrintTMetricKind(), impala::PrintTUnit(), impala::ToJsonValue(), impala::SimpleMetric< T, metric_kind >::unit(), and impala::SimpleMetric< T, metric_kind >::value().
|
inlinevirtual |
This method is kept for backwards-compatibility with CM5.0.
Adds a new json value directly to 'document' of the form: "name" : "human-readable-string"
Implements impala::Metric.
Definition at line 160 of file metrics.h.
References impala::Metric::key_, impala::ToJsonValue(), and impala::SimpleMetric< T, metric_kind >::value().
|
inline |
Definition at line 166 of file metrics.h.
References impala::SimpleMetric< T, metric_kind >::unit_.
Referenced by impala::SimpleMetric< T, metric_kind >::ToHumanReadable(), and impala::SimpleMetric< T, metric_kind >::ToJson().
|
inline |
Returns the current value, updating it if necessary. Thread-safe.
Definition at line 118 of file metrics.h.
References impala::SimpleMetric< T, metric_kind >::CalculateValue(), impala::SimpleMetric< T, metric_kind >::lock_, and impala::SimpleMetric< T, metric_kind >::value_.
Referenced by impala::SimpleMetric< T, metric_kind >::set_value(), impala::SimpleMetric< T, metric_kind >::ToHumanReadable(), impala::SimpleMetric< T, metric_kind >::ToJson(), and impala::SimpleMetric< T, metric_kind >::ToLegacyJson().
|
protectedinherited |
Description of this metric. TODO: share one copy amongst metrics with the same description.
Definition at line 80 of file metrics.h.
Referenced by impala::Metric::description().
|
protectedinherited |
Unique key identifying this metric.
Definition at line 76 of file metrics.h.
Referenced by impala::Metric::key(), impala::SetMetric< std::string >::ToLegacyJson(), impala::StatsMetric< double >::ToLegacyJson(), and impala::SimpleMetric< T, metric_kind >::ToLegacyJson().
|
protected |
Guards access to value_.
Definition at line 181 of file metrics.h.
Referenced by impala::SimpleMetric< T, metric_kind >::Increment(), impala::SimpleMetric< T, metric_kind >::set_value(), and impala::SimpleMetric< T, metric_kind >::value().
|
protected |
Units of this metric.
Definition at line 178 of file metrics.h.
Referenced by impala::SimpleMetric< T, metric_kind >::unit().
|
protected |
The current value of the metric.
Definition at line 184 of file metrics.h.
Referenced by impala::SimpleMetric< T, metric_kind >::Increment(), impala::SimpleMetric< T, metric_kind >::set_value(), and impala::SimpleMetric< T, metric_kind >::value().