Module quasardb.stats
Functions
def by_node(conn: Cluster) ‑> Dict[str, Dict[str, Any]]-
Expand source code
def by_node(conn: Cluster) -> Dict[str, Dict[str, Any]]: """ Returns statistic grouped by node URI. Parameters: conn: quasardb.Cluster Active connection to the QuasarDB cluster """ return {x: of_node(conn.node(x)) for x in conn.endpoints()}Returns statistic grouped by node URI.
Parameters: conn: quasardb.Cluster Active connection to the QuasarDB cluster
def is_cumulative_stat(s: str) ‑> bool-
Expand source code
def is_cumulative_stat(s: str) -> bool: # NOTE(leon): It's quite difficult to express in Python that you don't want any # regex to _end_ with uid_[0-9]+, because Python's regex engine doesn't support # variable width look-behind. # # An alternative would be to use the PyPi regex library (for POSIX regexes), but # want to stay light on dependencies# # # As such, we define a 'cumulative' stat as anything that's not a user stat. # Simple but effective. return user_pattern.match(s) is None def is_user_stat(s: str) ‑> bool-
Expand source code
def is_user_stat(s: str) -> bool: return user_pattern.match(s) is not None def of_node(dconn: Node) ‑> Dict[str, Any]-
Expand source code
def of_node(dconn: Node) -> Dict[str, Any]: """ Returns statistic for a single node. Parameters: dconn: quasardb.Node Direct node connection to the node we wish to connect to """ start = datetime.now() ks = _get_all_keys(dconn) idx = _index_keys(dconn, ks) raw = {k: _get_stat_value(dconn, k) for k in ks} ret: Dict[str, Any] = { "by_uid": _by_uid(raw, idx), "cumulative": _cumulative(raw, idx), } check_duration = datetime.now() - start ret["cumulative"]["check.online"] = { "value": 1, "type": Type.ACCUMULATOR, "unit": Unit.NONE, } ret["cumulative"]["check.duration_ms"] = { "value": int(check_duration.total_seconds() * 1000), "type": Type.ACCUMULATOR, "unit": Unit.MILLISECONDS, } return retReturns statistic for a single node.
Parameters: dconn: quasardb.Node Direct node connection to the node we wish to connect to
def stat_type(stat_id: str) ‑> None-
Expand source code
def stat_type(stat_id: str) -> None: """ Returns the statistic type by a stat id. Returns one of: - 'gauge' - 'counter' - None in case of unrecognized statistics This is useful for determining which value should be reported in a dashboard. """ import warnings warnings.warn( "The 'stat_type' method is deprecated and will be removed in a future release." "The stat type and unit are now part of the return value of invocations to the 'of_node' and 'by_node' methods.", DeprecationWarning, stacklevel=2, ) return NoneReturns the statistic type by a stat id. Returns one of:
- 'gauge'
- 'counter'
- None in case of unrecognized statistics
This is useful for determining which value should be reported in a dashboard.
Classes
class Type (value, names=None, *, module=None, qualname=None, type=None, start=1)-
Expand source code
class Type(Enum): ACCUMULATOR = 1 GAUGE = 2 LABEL = 3An enumeration.
Ancestors
- enum.Enum
Class variables
var ACCUMULATORvar GAUGEvar LABEL
class Unit (value, names=None, *, module=None, qualname=None, type=None, start=1)-
Expand source code
class Unit(Enum): NONE = 0 COUNT = 1 # Size units BYTES = 32 # Time/duration units EPOCH = 64 NANOSECONDS = 65 MICROSECONDS = 66 MILLISECONDS = 67 SECONDS = 68An enumeration.
Ancestors
- enum.Enum
Class variables
var BYTESvar COUNTvar EPOCHvar MICROSECONDSvar MILLISECONDSvar NANOSECONDSvar NONEvar SECONDS