buildgrid.server.monitoring module

class buildgrid.server.monitoring.MonitoringOutputType(value)

Bases: Enum

An enumeration.

STDOUT = 'stdout'
FILE = 'file'
SOCKET = 'socket'
UDP = 'udp'
SILENT = 'silent'
class buildgrid.server.monitoring.MonitoringOutputFormat(value)

Bases: Enum

An enumeration.

BINARY = 'binary'
JSON = 'json'
STATSD = 'statsd'
class buildgrid.server.monitoring.StatsDTagFormat(value)

Bases: Enum

An enumeration.

NONE = 'none'
INFLUX_STATSD = 'influx-statsd'
DOG_STATSD = 'dogstatsd'
GRAPHITE = 'graphite'
class buildgrid.server.monitoring.UdpWrapper(endpoint_location: str)

Bases: object

Wraps socket sendto() in write() so it can be used polymorphically

write(message: bytes) None
close() None
class buildgrid.server.monitoring.MonitoringBus(endpoint_type: MonitoringOutputType = MonitoringOutputType.SOCKET, endpoint_location: str | None = None, metric_prefix: str = '', serialisation_format: MonitoringOutputFormat = MonitoringOutputFormat.STATSD, tag_format: StatsDTagFormat = StatsDTagFormat.NONE)

Bases: object

property is_enabled: bool

Whether monitoring is enabled.

The send_record methods perform this check so clients don’t need to check this before sending a record to the monitoring bus, but it is provided for convenience.

property prints_records: bool

Whether or not messages are printed to standard output.

property is_silent: bool

Whether or not this is a silent monitoring bus.

process_should_exit() bool

Whether the streaming worker process should exit.

The streaming worker process should exit if explicitly told to by the _stop_streaming_worker event or if it has been orphaned by the parent.

start() None

Starts the monitoring bus worker task.

stop() None

Cancels the monitoring bus worker task.

prefix_record_nowait(record: MetricRecord) MetricRecord

Prefix the record’s metric name. This is the same as prefix_record, but called synchronously.

See the prefix_record docstring for notes on the prefixing rules.

Parameters:

record (Message) – The record to prefix.

send_record_nowait(record: MetricRecord | LogRecord) None

Publishes a record onto the bus synchronously.

Parameters:

record (Message) – The record to send.

buildgrid.server.monitoring.set_monitoring_bus(monitoring_bus: MonitoringBus) None
buildgrid.server.monitoring.get_monitoring_bus() MonitoringBus