Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
|
MetricGroups may be organised hierarchically as a tree. More...
#include <metrics.h>
Public Member Functions | |
MetricGroup (const std::string &name) | |
template<typename M > | |
M * | RegisterMetric (M *metric) |
template<typename T > | |
SimpleMetric< T > * | AddGauge (const std::string &key, const T &value, const TUnit::type unit=TUnit::NONE, const std::string &description="") |
Create a gauge metric object with given key and initial value (owned by this object) More... | |
template<typename T > | |
SimpleMetric< T, TMetricKind::PROPERTY > * | AddProperty (const std::string &key, const T &value, const std::string &description="") |
template<typename T > | |
SimpleMetric< T, TMetricKind::COUNTER > * | AddCounter (const std::string &key, const T &value, const TUnit::type unit=TUnit::UNIT, const std::string &description="") |
template<typename M > | |
M * | FindMetricForTesting (const std::string &key) |
Used for testing only. More... | |
Status | Init (Webserver *webserver) |
void | ToJson (bool include_children, rapidjson::Document *document, rapidjson::Value *out_val) |
Converts this metric group (and optionally all of its children recursively) to JSON. More... | |
MetricGroup * | GetChildGroup (const std::string &name) |
Creates or returns an already existing child metric group. More... | |
std::string | DebugString () |
Useful for debuggers, returns the output of CMCompatibleCallback(). More... | |
const std::string & | name () const |
Private Types | |
typedef std::map< std::string, Metric * > | MetricMap |
Contains all Metric objects, indexed by key. More... | |
typedef std::map< std::string, MetricGroup * > | ChildGroupMap |
All child metric groups. More... | |
Private Member Functions | |
void | TemplateCallback (const Webserver::ArgumentMap &args, rapidjson::Document *document) |
void | CMCompatibleCallback (const Webserver::ArgumentMap &args, rapidjson::Document *document) |
Private Attributes | |
boost::scoped_ptr< ObjectPool > | obj_pool_ |
Pool containing all metric objects. More... | |
std::string | name_ |
Name of this metric group. More... | |
boost::mutex | lock_ |
Guards metric_map_ and children_. More... | |
MetricMap | metric_map_ |
ChildGroupMap | children_ |
MetricGroups may be organised hierarchically as a tree.
Container for a set of metrics. A MetricGroup owns the memory for every metric contained within it (see Add*() to create commonly used metric types). Metrics are 'registered' with a MetricGroup, once registered they cannot be deleted.Typically a metric object is cached by its creator after registration. If a metric must be retrieved without an available pointer, FindMetricForTesting() will search the MetricGroup and all its descendent MetricGroups in turn. TODO: Hierarchical naming: that is, resolve "group1.group2.metric-name" to a path through the metric tree.
|
private |
|
private |
MetricGroup::MetricGroup | ( | const std::string & | name | ) |
Definition at line 55 of file metrics.cc.
|
inline |
Definition at line 239 of file metrics.h.
References RegisterMetric().
Referenced by impala::CgroupsMgr::CgroupsMgr(), impala::ImpaladMetrics::CreateMetrics(), impala::AdmissionController::GetPoolMetrics(), impala::MemTracker::RegisterMetrics(), impala::ResourceBroker::ResourceBroker(), impala::TEST(), and impala::ThriftServer::ThriftServer().
|
inline |
Create a gauge metric object with given key and initial value (owned by this object)
Definition at line 223 of file metrics.h.
References RegisterMetric().
Referenced by impala::ImpaladMetrics::CreateMetrics(), impala::AdmissionController::GetPoolMetrics(), impala::ClientCacheHelper::InitMetrics(), impala::MemTracker::RegisterMetrics(), impala::ResourceBroker::ResourceBroker(), impala::ThreadMgr::StartInstrumentation(), impala::Statestore::Statestore(), impala::StatestoreSubscriber::StatestoreSubscriber(), impala::TEST(), and impala::ThriftServer::ThriftServer().
|
inline |
Definition at line 231 of file metrics.h.
References RegisterMetric().
Referenced by impala::ImpaladMetrics::CreateMetrics(), impala::ResourceBroker::ResourceBroker(), impala::StatestoreSubscriber::StatestoreSubscriber(), and impala::TEST().
|
private |
Legacy webpage callback for CM 5.0 and earlier. Produces a flattened map of (key, value) pairs for all metrics in this hierarchy. If args contains a paramater 'metric', only the json for that metric is returned.
Definition at line 73 of file metrics.cc.
References children_, lock_, and metric_map_.
Referenced by Init().
string MetricGroup::DebugString | ( | ) |
Useful for debuggers, returns the output of CMCompatibleCallback().
Definition at line 178 of file metrics.cc.
References TemplateCallback().
|
inline |
Used for testing only.
Returns a metric by key. All MetricGroups reachable from this group are searched in depth-first order, starting with the root group. Returns NULL if there is no metric with that key. This is not a very cheap operation; the result should be cached where possible.
Definition at line 253 of file metrics.h.
References children_, lock_, and metric_map_.
Referenced by TEST(), and impala::TEST().
MetricGroup * MetricGroup::GetChildGroup | ( | const std::string & | name | ) |
Creates or returns an already existing child metric group.
Definition at line 169 of file metrics.cc.
References children_, lock_, name(), and obj_pool_.
Referenced by impala::ImpalaServer::ImpalaServer(), impala::RegisterMemoryMetrics(), and impala::TEST().
Register page callbacks with the webserver. Only the root of any metric group hierarchy needs to do this.
Definition at line 58 of file metrics.cc.
References CMCompatibleCallback(), impala::Status::OK, impala::Webserver::RegisterUrlCallback(), and TemplateCallback().
|
inline |
|
inline |
Registers a new metric. Ownership of the metric will be transferred to this MetricGroup object, so callers should take care not to destroy the Metric they pass in. It is an error to call twice with metrics with the same key. The template parameter M must be a subclass of Metric.
Definition at line 211 of file metrics.h.
References lock_, metric_map_, and obj_pool_.
Referenced by AddCounter(), AddGauge(), AddProperty(), impala::StatestoreSubscriber::AddTopic(), impala::CatalogServer::CatalogServer(), impala::RpcEventHandler::getContext(), impala::JvmMetric::InitMetrics(), impala::RegisterMemoryMetrics(), impala::RequestPoolService::RequestPoolService(), impala::ResourceBroker::ResourceBroker(), impala::Statestore::Statestore(), impala::StatestoreSubscriber::StatestoreSubscriber(), and impala::TEST().
|
private |
Webserver callback for /metrics. Produces a tree of JSON values, each representing a metric group, and each including a list of metrics, and a list of immediate children. If args contains a paramater 'metric', only the json for that metric is returned.
Definition at line 103 of file metrics.cc.
References children_, lock_, and ToJson().
Referenced by DebugString(), and Init().
void MetricGroup::ToJson | ( | bool | include_children, |
rapidjson::Document * | document, | ||
rapidjson::Value * | out_val | ||
) |
Converts this metric group (and optionally all of its children recursively) to JSON.
Definition at line 145 of file metrics.cc.
References children_, metric_map_, and name_.
Referenced by TemplateCallback(), and impala::TEST().
|
private |
Definition at line 301 of file metrics.h.
Referenced by CMCompatibleCallback(), FindMetricForTesting(), GetChildGroup(), TemplateCallback(), and ToJson().
|
private |
Guards metric_map_ and children_.
Definition at line 293 of file metrics.h.
Referenced by CMCompatibleCallback(), FindMetricForTesting(), GetChildGroup(), RegisterMetric(), and TemplateCallback().
|
private |
Definition at line 297 of file metrics.h.
Referenced by CMCompatibleCallback(), FindMetricForTesting(), RegisterMetric(), and ToJson().
|
private |
|
private |
Pool containing all metric objects.
Definition at line 287 of file metrics.h.
Referenced by GetChildGroup(), and RegisterMetric().