Collects and publishes FsBroker metrics. More...
#include <MetricsHandler.h>
Public Member Functions | |
MetricsHandler (PropertiesPtr &props, const std::string &type) | |
Constructor. More... | |
virtual | ~MetricsHandler () |
Destructor. More... | |
void | start_collecting () |
Starts metrics collection. More... | |
void | stop_collecting () |
Stops metrics collection. More... | |
virtual void | handle (EventPtr &event) |
Collects and publishes metrics. More... | |
void | add_bytes_read (int64_t count) |
Adds bytes read. More... | |
void | add_bytes_written (int64_t count) |
Adds bytes written. More... | |
void | add_sync (int64_t latency_nsec) |
Adds sync information. More... | |
void | increment_error_count () |
Increments error count. More... | |
Public Member Functions inherited from Hypertable::DispatchHandler | |
virtual | ~DispatchHandler () |
Destructor. More... | |
Private Attributes | |
std::mutex | m_mutex |
Mutex for serializing access to members More... | |
Comm * | m_comm |
Comm layer pointer. More... | |
MetricsCollectorGangliaPtr | m_ganglia_collector |
Ganglia metrics collector. More... | |
MetricsProcess | m_metrics_process |
General process metrics tracker. More... | |
std::string | m_type |
FsBroker type (e.g. "local", "qfs", etc.) More... | |
int32_t | m_collection_interval |
Metrics collection interval More... | |
int64_t | m_last_timestamp |
Timestamp of last metrics collection More... | |
int64_t | m_bytes_written {} |
Bytes written since last metrics collection. More... | |
int64_t | m_bytes_read {} |
Bytes read since last metrics collection. More... | |
int32_t | m_sync_latency {} |
Cumulative sync latency since last metrics collection. More... | |
int32_t | m_syncs {} |
Syncs since last metrics collection. More... | |
int32_t | m_errors {} |
Error count since last metrics collection. More... | |
Collects and publishes FsBroker metrics.
This class acts as the timer dispatch handler for periodic metrics collection for FsBroker.
Definition at line 51 of file MetricsHandler.h.
MetricsHandler::MetricsHandler | ( | PropertiesPtr & | props, |
const std::string & | type | ||
) |
Constructor.
Initializes m_collection_interval to the property Hypertable.Monitoring.Interval
and allocates a Ganglia collector object, initializing it with "hyperspace" and Hypertable.Metrics.Ganglia.Port
. Lastly, calls Comm::set_timer() to register a timer for m_collection_interval milliseconds in the future and passes this
as the timer handler.
props | Properties object |
type | Type of broker (e.g. "local", "qfs", etc.) |
Definition at line 44 of file MetricsHandler.cc.
|
inlinevirtual |
|
inline |
Adds bytes read.
Adds count
to m_bytes_read.
count | Count of bytes read |
Definition at line 87 of file MetricsHandler.h.
|
inline |
Adds bytes written.
Adds count
to m_bytes_written.
count | Count of bytes written |
Definition at line 95 of file MetricsHandler.h.
|
inline |
Adds sync information.
Adds latency_nsec
to m_sync_latency and increments m_syncs.
latency_nsec | Latency of sync in nanoseconds |
Definition at line 104 of file MetricsHandler.h.
|
virtual |
Collects and publishes metrics.
This method updates the requests/s
and general process metrics and publishes them via m_ganglia_collector. After metrics have been collected, the timer is re-registered for m_collection_interval milliseconds in the future.
event | Comm layer timer event |
Implements Hypertable::DispatchHandler.
Definition at line 62 of file MetricsHandler.cc.
|
inline |
void MetricsHandler::start_collecting | ( | ) |
Starts metrics collection.
Definition at line 52 of file MetricsHandler.cc.
void MetricsHandler::stop_collecting | ( | ) |
Stops metrics collection.
Definition at line 58 of file MetricsHandler.cc.
|
private |
Bytes read since last metrics collection.
Definition at line 143 of file MetricsHandler.h.
|
private |
Bytes written since last metrics collection.
Definition at line 140 of file MetricsHandler.h.
|
private |
Metrics collection interval
Definition at line 134 of file MetricsHandler.h.
|
private |
Comm layer pointer.
Definition at line 122 of file MetricsHandler.h.
|
private |
Error count since last metrics collection.
Definition at line 152 of file MetricsHandler.h.
|
private |
Ganglia metrics collector.
Definition at line 125 of file MetricsHandler.h.
|
private |
Timestamp of last metrics collection
Definition at line 137 of file MetricsHandler.h.
|
private |
General process metrics tracker.
Definition at line 128 of file MetricsHandler.h.
|
private |
Mutex for serializing access to members
Definition at line 119 of file MetricsHandler.h.
|
private |
Cumulative sync latency since last metrics collection.
Definition at line 146 of file MetricsHandler.h.
|
private |
Syncs since last metrics collection.
Definition at line 149 of file MetricsHandler.h.
|
private |
FsBroker type (e.g. "local", "qfs", etc.)
Definition at line 131 of file MetricsHandler.h.