aerospike_helpers.metrics package

Classes used for metrics.

ConnectionStats, NodeMetrics, Node, and Cluster do not have a constructor because they are not meant to be created by the user. They are only meant to be returned from MetricsListeners callbacks for reading data about the server and client.

class aerospike_helpers.metrics.Cluster

Bases: object

Cluster of server nodes.

cluster_name

Expected cluster name for all nodes. May be None.

Type:

Optional[str]

invalid_node_count

Count of add node failures in the most recent cluster tend iteration.

Type:

int

tran_count

Transaction count. The value is cumulative and not reset per metrics interval.

Type:

int

retry_count

Transaction retry count. There can be multiple retries for a single transaction. The value is cumulative and not reset per metrics interval.

Type:

int

nodes

Active nodes in cluster.

Type:

list[Node]

__weakref__

list of weak references to the object

class aerospike_helpers.metrics.ConnectionStats

Bases: object

Connection statistics.

in_use

Connections actively being used in database transactions on this node. There can be multiple pools per node. This value is a summary of those pools on this node.

Type:

int

in_pool

Connections residing in pool(s) on this node. There can be multiple pools per node. This value is a summary of those pools on this node.

Type:

int

opened

Total number of node connections opened since node creation.

Type:

int

closed

Total number of node connections closed since node creation.

Type:

int

__weakref__

list of weak references to the object

class aerospike_helpers.metrics.MetricsListeners(enable_listener: Callable[[], None], snapshot_listener: Callable[[Cluster], None], node_close_listener: Callable[[Node], None], disable_listener: Callable[[Cluster], None])

Bases: object

Metrics listener callbacks.

All callbacks must be set.

enable_listener

Periodic extended metrics has been enabled for the given cluster.

Type:

Callable[[], None]

snapshot_listener

A metrics snapshot has been requested for the given cluster.

Type:

Callable[[Cluster], None]

node_close_listener

A node is being dropped from the cluster.

Type:

Callable[[Node], None]

disable_listener

Periodic extended metrics has been disabled for the given cluster.

Type:

Callable[[Cluster], None]

__init__(enable_listener: Callable[[], None], snapshot_listener: Callable[[Cluster], None], node_close_listener: Callable[[Node], None], disable_listener: Callable[[Cluster], None])
__weakref__

list of weak references to the object

class aerospike_helpers.metrics.MetricsPolicy(metrics_listeners: MetricsListeners | None = None, report_dir: str = '.', report_size_limit: int = 0, interval: int = 30, latency_columns: int = 7, latency_shift: int = 1)

Bases: object

Client periodic metrics configuration.

metrics_listeners

Listeners that handles metrics notification events. If set to None, the default listener implementation will be used, which writes the metrics snapshot to a file which can later be read and forwarded to OpenTelemetry by a separate offline application. Otherwise, use all listeners set in the class instance.

The listener could be overridden to send the metrics snapshot directly to OpenTelemetry.

Type:

Optional[MetricsListeners]

report_dir

Directory path to write metrics log files for listeners that write logs.

Type:

str

report_size_limit

Metrics file size soft limit in bytes for listeners that write logs. When report_size_limit is reached or exceeded, the current metrics file is closed and a new metrics file is created with a new timestamp. If report_size_limit is zero, the metrics file size is unbounded and the file will only be closed when disable_metrics() or close() is called.

Type:

int

interval

Number of cluster tend iterations between metrics notification events. One tend iteration is defined as "tend_interval" in the client config plus the time to tend all nodes.

Type:

int

latency_columns

Number of elapsed time range buckets in latency histograms.

Type:

int

latency_shift

Power of 2 multiple between each range bucket in latency histograms starting at column 3. The bucket units are in milliseconds. The first 2 buckets are “<=1ms” and “>1ms”.

Example:

# latencyColumns=7 latencyShift=1
# <=1ms >1ms >2ms >4ms >8ms >16ms >32ms

# latencyColumns=5 latencyShift=3
# <=1ms >1ms >8ms >64ms >512ms
Type:

int

__init__(metrics_listeners: MetricsListeners | None = None, report_dir: str = '.', report_size_limit: int = 0, interval: int = 30, latency_columns: int = 7, latency_shift: int = 1)
__weakref__

list of weak references to the object

class aerospike_helpers.metrics.Node

Bases: object

Server node representation.

name

The name of the node.

Type:

str

address

The IP address / host name of the node (not including the port number).

Type:

str

port

Port number of the node’s address.

Type:

int

conns

Synchronous connection stats on this node.

Type:

ConnectionStats

error_count

Transaction error count since node was initialized. If the error is retryable, multiple errors per transaction may occur.

Type:

int

timeout_count

Transaction timeout count since node was initialized. If the timeout is retryable (ie socketTimeout), multiple timeouts per transaction may occur.

Type:

int

metrics

Node metrics

Type:

NodeMetrics

__weakref__

list of weak references to the object

class aerospike_helpers.metrics.NodeMetrics

Bases: object

Each type of latency has a list of latency buckets.

Latency bucket counts are cumulative and not reset on each metrics snapshot interval.

conn_latency
Type:

list[int]

write_latency
Type:

list[int]

read_latency
Type:

list[int]

batch_latency
Type:

list[int]

query_latency
Type:

list[int]

__weakref__

list of weak references to the object