titanfe.apps.brick_runner.metrics module

Handle creation of metric data and streaming it to Kafka

class titanfe.apps.brick_runner.metrics.BrickMetrics(flow: str = 'FlowName?', brick: str = 'BrickName?', brick_type: str = 'BrickType?', brick_family: str = 'BrickFamily?', runner: str = 'RunnerUid?', host: str = 'build-19467538-project-510666-titanfe', timestamp: str = <factory>, content_type: str = 'titan-brick-metrics', execution_time: float = 0.0)[source]

Bases: titanfe.apps.brick_runner.metrics.MetricsBase

Metric data for brick executions

content_type: str = 'titan-brick-metrics'
execution_time: float = 0.0
class titanfe.apps.brick_runner.metrics.MetricEmitter(metrics_metadata, logger)[source]

Bases: object

The MetricEmitter encapsulates creation of metric data and sending them to a Kafka instance

Parameters:
  • metrics_metadata (dict) – base meta data of metrics emitted

  • logger (logging.logger) – the parent’s logger instance

async classmethod create_from_brick_runner(runner)titanfe.apps.brick_runner.metrics.MetricEmitter[source]

Creates, starts and returns a MetricEmitter instance

async emit(metrics_dict)[source]
async emit_brick_metrics(execution_time)[source]
async emit_packet_metrics(packet, duration)[source]
async emit_queue_metrics(queue_name, queue_length)[source]
set_metadata_from_runner(runner)[source]

assigns flowname and brickname after brickrunner has gotten his assignment

async start()[source]

creates and starts the internal Kafka producer

async stop()[source]
class titanfe.apps.brick_runner.metrics.MetricsBase(flow: str = 'FlowName?', brick: str = 'BrickName?', brick_type: str = 'BrickType?', brick_family: str = 'BrickFamily?', runner: str = 'RunnerUid?', host: str = 'build-19467538-project-510666-titanfe', timestamp: str = <factory>)[source]

Bases: titanfe.utils.DictConvertable, abc.ABC

Information that every “metric” should contain

brick: str = 'BrickName?'
brick_family: str = 'BrickFamily?'
brick_type: str = 'BrickType?'
static extract_from_runner(runner)[source]

extract the basic information from a brick runner instance

flow: str = 'FlowName?'
host: str = 'build-19467538-project-510666-titanfe'
runner: str = 'RunnerUid?'
timestamp: str
class titanfe.apps.brick_runner.metrics.PacketMetricsAtBrick(flow: str = 'FlowName?', brick: str = 'BrickName?', brick_type: str = 'BrickType?', brick_family: str = 'BrickFamily?', runner: str = 'RunnerUid?', host: str = 'build-19467538-project-510666-titanfe', timestamp: str = <factory>, content_type: str = 'titan-packet-metrics', packet: str = 'PacketUid?', execution_time: float = 0.0, traveling_time: float = 0.0, time_in_input: float = 0.0, time_in_output: float = 0.0, time_on_wire: float = 0.0, at_outlet: bool = False)[source]

Bases: titanfe.apps.brick_runner.metrics.MetricsBase

Metric data for a packet being processed at a Brick

at_outlet: bool = False
content_type: str = 'titan-packet-metrics'
execution_time: float = 0.0
packet: str = 'PacketUid?'
time_in_input: float = 0.0
time_in_output: float = 0.0
time_on_wire: float = 0.0
traveling_time: float = 0.0
class titanfe.apps.brick_runner.metrics.QueueMetrics(flow: str = 'FlowName?', brick: str = 'BrickName?', brick_type: str = 'BrickType?', brick_family: str = 'BrickFamily?', runner: str = 'RunnerUid?', host: str = 'build-19467538-project-510666-titanfe', timestamp: str = <factory>, content_type: str = 'titan-queue-metrics', queue_name: str = 'QueueName?', queue_length: int = 0)[source]

Bases: titanfe.apps.brick_runner.metrics.MetricsBase

Metric data for Input/Output-queues

content_type: str = 'titan-queue-metrics'
queue_length: int = 0
queue_name: str = 'QueueName?'
class titanfe.apps.brick_runner.metrics.QueueWithMetrics(emitter, name, interval=0.1, maxsize=0)[source]

Bases: asyncio.queues.Queue

an ayncio.Queue that emits metrics (queue length)

async close()[source]
async emit_metrics(emitter, interval=0.1)[source]

automatically scheduled as task

async put(item)[source]

Put an item into the queue.

Put an item into the queue. If the queue is full, wait until a free slot is available before adding item.

property unfinished_tasks