gd_node.performance_metrics package

Submodules

gd_node.performance_metrics.collector module

Copyright (C) Mov.ai - All Rights Reserved Unauthorized copying of this file, via any medium is strictly prohibited Proprietary and confidential

Performance metrics collector for GD_Node

class gd_node.performance_metrics.collector.InfluxDBMetricsCollector(node_name: str | None = None, instance_name: str | None = None, host: str | None = None, dbname: str | None = None)

Bases: MetricsCollector

Collector that saves metrics to InfluxDB

save_metrics() None

Write metrics to InfluxDB. Time values are stored as floats in seconds.

class gd_node.performance_metrics.collector.MetricsCollector(node_name: str | None = None, instance_name: str | None = None)

Bases: ABC

Collects and stores performance metrics for GD_Node execution. Time measurements are stored in seconds throughout the system. Only collects metrics if PLATFORM_METRICS environment variable is set.

calculate_durations() Dict[str, float]

Calculate time durations from stored timestamps. These values are stored as floats to maintain precision.

Returns:

Dictionary of duration measurements in seconds

Return type:

Dict[str, float]

static create(*args: Any, **kwargs: Any) NullMetricsCollector | InfluxDBMetricsCollector

Factory method that returns appropriate collector based on environment

mark_running() None

Mark node as running after initialization is complete

mark_terminated(exit_code: int = 0, reason: str = 'normal') None

Mark node as terminated with optional exit details

Parameters:
  • exit_code (int) – Exit code of the node process

  • reason (str) – Reason for termination

record_timestamp(event: MetricsEvent | str) None

Record timestamp for a given event in RAM

Parameters:

event (Union[MetricsEvent, str]) – Event to record either as MetricsEvent enum or legacy string

abstract save_metrics() None

Save metrics using the appropriate storage method

update_info(node_name: str, instance_name: str, transports: List[str] | None = None) None

Update node and instance names after argument parsing

Parameters:
  • node_name (str) – Name of the node

  • instance_name (str) – Name of the instance

  • transports (List[str], optional) – List of active transports

gd_node.performance_metrics.events module

Copyright (C) Mov.ai - All Rights Reserved Unauthorized copying of this file, via any medium is strictly prohibited Proprietary and confidential

Lightweight event and state enums for metrics collection. This file has no external dependencies to avoid import overhead.

class gd_node.performance_metrics.events.MetricsEvent(value)

Bases: Enum

Events that can be recorded during GD_Node lifecycle

IMPORTS_DONE = 'imports_done'
INIT_DONE = 'init_done'
INIT_START = 'init_start'
RUNTIME_START = 'runtime_start'
START = 'start'
TERMINATE_DONE = 'terminate_done'
TERMINATE_START = 'terminate_start'
class gd_node.performance_metrics.events.NodeState(value)

Bases: Enum

States of a GD_Node during its lifecycle

RUNNING = 'running'
STARTING = 'starting'
TERMINATED = 'terminated'

gd_node.performance_metrics.null_collector module

Copyright (C) Mov.ai - All Rights Reserved Unauthorized copying of this file, via any medium is strictly prohibited Proprietary and confidential

Empty stub collector used when PLATFORM_METRICS is disabled to avoid loading heavy dependencies.

class gd_node.performance_metrics.null_collector.NullMetricsCollector(*args: Any, **kwargs: Any)

Bases: object

No-op metrics collector when metrics are disabled.

Note: Does not inherit from MetricsCollector to avoid importing collector.py and its heavy dependencies when metrics are disabled.

calculate_durations(*args: Any, **kwargs: Any) Dict[str, float]

No-op for NullMetricsCollector

mark_running(*args: Any, **kwargs: Any) None

No-op for NullMetricsCollector

mark_terminated(*args: Any, **kwargs: Any) None

No-op for NullMetricsCollector

record_timestamp(*args: Any, **kwargs: Any) None

No-op for NullMetricsCollector

save_metrics(*args: Any, **kwargs: Any) None

No-op for NullMetricsCollector

update_info(*args: Any, **kwargs: Any) None

No-op for NullMetricsCollector

Module contents