Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
impala::Metric Class Referenceabstract

TODO: Add ToThrift() for conversion to an RPC-friendly format. More...

#include <metrics.h>

Inheritance diagram for impala::Metric:
Collaboration diagram for impala::Metric:

Public Member Functions

virtual ~Metric ()
 Empty virtual destructor. More...
 
virtual void ToJson (rapidjson::Document *document, rapidjson::Value *val)=0
 name, value, human_readable, description More...
 
virtual void ToLegacyJson (rapidjson::Document *document)=0
 This method is kept for backwards-compatibility with CM5.0. More...
 
virtual std::string ToHumanReadable ()=0
 
const std::string & key () const
 
const std::string & description () const
 

Protected Member Functions

 Metric (const std::string &key, const std::string &description)
 
void AddStandardFields (rapidjson::Document *document, rapidjson::Value *val)
 

Protected Attributes

const std::string key_
 Unique key identifying this metric. More...
 
const std::string description_
 

Friends

class MetricGroup
 

Detailed Description

TODO: Add ToThrift() for conversion to an RPC-friendly format.

A metric is a container for some value, identified by a string key. Most metrics are numeric, but this metric base-class is general enough such that metrics may be lists, maps, histograms or other arbitrary structures. Metrics must be able to convert themselves to JSON (for integration with our monitoring tools, and for rendering in webpages). See ToJson(), and also ToLegacyJson() which ensures backwards compatibility with older versions of CM. Metrics should be supplied with a description, which is included in JSON output for display by monitoring systems / Impala's webpages.

Definition at line 50 of file metrics.h.

Constructor & Destructor Documentation

virtual impala::Metric::~Metric ( )
inlinevirtual

Empty virtual destructor.

Definition at line 53 of file metrics.h.

impala::Metric::Metric ( const std::string &  key,
const std::string &  description 
)
inlineprotected

Definition at line 84 of file metrics.h.

Member Function Documentation

void Metric::AddStandardFields ( rapidjson::Document *  document,
rapidjson::Value *  val 
)
protected

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().

const std::string& impala::Metric::description ( ) const
inline

Definition at line 72 of file metrics.h.

References description_.

const std::string& impala::Metric::key ( ) const
inline

Definition at line 71 of file metrics.h.

References key_.

Referenced by impala::SimpleMetric< T, metric_kind >::Increment().

virtual std::string impala::Metric::ToHumanReadable ( )
pure virtual

Writes a human-readable representation of this metric to 'out'. This is the representation that is often displayed in webpages etc.

Implemented in impala::StatsMetric< T >, impala::StatsMetric< double >, impala::SimpleMetric< T, metric_kind >, impala::SetMetric< T >, impala::SetMetric< std::string >, and impala::TimerMetric.

virtual void impala::Metric::ToJson ( rapidjson::Document *  document,
rapidjson::Value *  val 
)
pure virtual

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:

Implemented in impala::SimpleMetric< T, metric_kind >, impala::StatsMetric< T >, impala::StatsMetric< double >, impala::SetMetric< T >, impala::SetMetric< std::string >, and impala::TimerMetric.

virtual void impala::Metric::ToLegacyJson ( rapidjson::Document *  document)
pure virtual

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"

Implemented in impala::SimpleMetric< T, metric_kind >, impala::StatsMetric< T >, impala::StatsMetric< double >, impala::SetMetric< T >, impala::SetMetric< std::string >, and impala::TimerMetric.

Friends And Related Function Documentation

friend class MetricGroup
friend

Definition at line 82 of file metrics.h.

Member Data Documentation

const std::string impala::Metric::description_
protected

Description of this metric. TODO: share one copy amongst metrics with the same description.

Definition at line 80 of file metrics.h.

Referenced by description().

const std::string impala::Metric::key_
protected

The documentation for this class was generated from the following files: