sentry-arroyo 2.27.0__py3-none-any.whl → 2.28.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- arroyo/processing/processor.py +2 -3
- arroyo/processing/strategies/produce.py +14 -1
- arroyo/utils/metricDefs.json +1 -1
- arroyo/utils/metric_defs.py +2 -0
- arroyo/utils/metrics.py +1 -48
- {sentry_arroyo-2.27.0.dist-info → sentry_arroyo-2.28.1.dist-info}/METADATA +1 -1
- {sentry_arroyo-2.27.0.dist-info → sentry_arroyo-2.28.1.dist-info}/RECORD +11 -11
- tests/utils/test_metrics.py +2 -53
- {sentry_arroyo-2.27.0.dist-info → sentry_arroyo-2.28.1.dist-info}/WHEEL +0 -0
- {sentry_arroyo-2.27.0.dist-info → sentry_arroyo-2.28.1.dist-info}/licenses/LICENSE +0 -0
- {sentry_arroyo-2.27.0.dist-info → sentry_arroyo-2.28.1.dist-info}/top_level.txt +0 -0
arroyo/processing/processor.py
CHANGED
|
@@ -29,7 +29,7 @@ from arroyo.processing.strategies.abstract import (
|
|
|
29
29
|
)
|
|
30
30
|
from arroyo.types import BrokerValue, Message, Partition, Topic, TStrategyPayload
|
|
31
31
|
from arroyo.utils.logging import handle_internal_error
|
|
32
|
-
from arroyo.utils.metrics import
|
|
32
|
+
from arroyo.utils.metrics import get_metrics
|
|
33
33
|
|
|
34
34
|
logger = logging.getLogger(__name__)
|
|
35
35
|
|
|
@@ -90,7 +90,7 @@ ConsumerCounter = Literal[
|
|
|
90
90
|
|
|
91
91
|
class MetricsBuffer:
|
|
92
92
|
def __init__(self) -> None:
|
|
93
|
-
self.metrics =
|
|
93
|
+
self.metrics = get_metrics()
|
|
94
94
|
self.__timers: MutableMapping[ConsumerTiming, float] = defaultdict(float)
|
|
95
95
|
self.__counters: MutableMapping[ConsumerCounter, int] = defaultdict(int)
|
|
96
96
|
self.__reset()
|
|
@@ -195,7 +195,6 @@ class StreamProcessor(Generic[TStrategyPayload]):
|
|
|
195
195
|
def on_partitions_assigned(partitions: Mapping[Partition, int]) -> None:
|
|
196
196
|
logger.info("New partitions assigned: %r", partitions)
|
|
197
197
|
logger.info("Member id: %r", self.__consumer.member_id)
|
|
198
|
-
self.__metrics_buffer.metrics.consumer_member_id = self.__consumer.member_id
|
|
199
198
|
|
|
200
199
|
self.__metrics_buffer.metrics.increment(
|
|
201
200
|
"arroyo.consumer.partitions_assigned.count", len(partitions)
|
|
@@ -13,6 +13,7 @@ from arroyo.types import (
|
|
|
13
13
|
TStrategyPayload,
|
|
14
14
|
Value,
|
|
15
15
|
)
|
|
16
|
+
from arroyo.utils.metrics import get_metrics
|
|
16
17
|
|
|
17
18
|
logger = logging.getLogger(__name__)
|
|
18
19
|
|
|
@@ -43,6 +44,7 @@ class Produce(ProcessingStrategy[Union[FilteredPayload, TStrategyPayload]]):
|
|
|
43
44
|
next_step: ProcessingStrategy[Union[FilteredPayload, TStrategyPayload]],
|
|
44
45
|
max_buffer_size: int = 10000,
|
|
45
46
|
):
|
|
47
|
+
self.__metrics = get_metrics()
|
|
46
48
|
self.__producer = producer
|
|
47
49
|
self.__topic = topic
|
|
48
50
|
self.__next_step = next_step
|
|
@@ -71,9 +73,20 @@ class Produce(ProcessingStrategy[Union[FilteredPayload, TStrategyPayload]]):
|
|
|
71
73
|
if not future.done():
|
|
72
74
|
break
|
|
73
75
|
|
|
76
|
+
try:
|
|
77
|
+
result = future.result()
|
|
78
|
+
self.__metrics.increment(
|
|
79
|
+
"arroyo.producer.produce_status", tags={"status": "success"}
|
|
80
|
+
)
|
|
81
|
+
except Exception as e:
|
|
82
|
+
self.__metrics.increment(
|
|
83
|
+
"arroyo.producer.produce_status", tags={"status": "error"}
|
|
84
|
+
)
|
|
85
|
+
raise e
|
|
86
|
+
|
|
74
87
|
message = Message(
|
|
75
88
|
Value(
|
|
76
|
-
|
|
89
|
+
result.payload,
|
|
77
90
|
original_message.committable,
|
|
78
91
|
original_message.timestamp,
|
|
79
92
|
)
|
arroyo/utils/metricDefs.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"arroyo.strategies.run_task_with_multiprocessing.batch.size.msg": {"name": "arroyo.strategies.run_task_with_multiprocessing.batch.size.msg", "type": "Time", "description": "Number of messages in a multiprocessing batch"}, "arroyo.strategies.run_task_with_multiprocessing.batch.size.bytes": {"name": "arroyo.strategies.run_task_with_multiprocessing.batch.size.bytes", "type": "Time", "description": "Number of bytes in a multiprocessing batch"}, "arroyo.strategies.run_task_with_multiprocessing.output_batch.size.msg": {"name": "arroyo.strategies.run_task_with_multiprocessing.output_batch.size.msg", "type": "Time", "description": "Number of messages in a multiprocessing batch after the message transformation"}, "arroyo.strategies.run_task_with_multiprocessing.output_batch.size.bytes": {"name": "arroyo.strategies.run_task_with_multiprocessing.output_batch.size.bytes", "type": "Time", "description": "Number of bytes in a multiprocessing batch after the message transformation"}, "arroyo.consumer.run.count": {"name": "arroyo.consumer.run.count", "type": "Counter", "description": "Number of times the consumer is spinning"}, "arroyo.consumer.invalid_message.count": {"name": "arroyo.consumer.invalid_message.count", "type": "Counter", "description": "Number of times the consumer encountered an invalid message."}, "arroyo.strategies.reduce.batch_time": {"name": "arroyo.strategies.reduce.batch_time", "type": "Time", "description": "How long it took the Reduce step to fill up a batch"}, "arroyo.strategies.run_task_with_multiprocessing.batch.backpressure": {"name": "arroyo.strategies.run_task_with_multiprocessing.batch.backpressure", "type": "Counter", "description": "Incremented when a strategy after multiprocessing applies\nbackpressure to multiprocessing. May be a reason why CPU cannot be\nsaturated."}, "arroyo.strategies.run_task_with_multiprocessing.batch.input.overflow": {"name": "arroyo.strategies.run_task_with_multiprocessing.batch.input.overflow", "type": "Counter", "description": "Incremented when multiprocessing cannot fill the input batch\nbecause not enough memory was allocated. This results in batches smaller\nthan configured. Increase `input_block_size` to fix."}, "arroyo.strategies.run_task_with_multiprocessing.batch.output.overflow": {"name": "arroyo.strategies.run_task_with_multiprocessing.batch.output.overflow", "type": "Counter", "description": "Incremented when multiprocessing cannot pull results in batches\nequal to the input batch size, because not enough memory was allocated.\nThis can be devastating for throughput. Increase `output_block_size` to\nfix."}, "arroyo.strategies.run_task_with_multiprocessing.batch.input.resize": {"name": "arroyo.strategies.run_task_with_multiprocessing.batch.input.resize", "type": "Counter", "description": "Arroyo has decided to re-allocate a block in order to combat input\nbuffer overflow. This behavior can be disabled by explicitly setting\n`input_block_size` to a not-None value in `RunTaskWithMultiprocessing`."}, "arroyo.strategies.run_task_with_multiprocessing.batch.output.resize": {"name": "arroyo.strategies.run_task_with_multiprocessing.batch.output.resize", "type": "Counter", "description": "Arroyo has decided to re-allocate a block in order to combat output\nbuffer overflow. This behavior can be disabled by explicitly setting\n`output_block_size` to a not-None value in `RunTaskWithMultiprocessing`."}, "arroyo.strategies.run_task_with_multiprocessing.batches_in_progress": {"name": "arroyo.strategies.run_task_with_multiprocessing.batches_in_progress", "type": "Gauge", "description": "How many batches are being processed in parallel by multiprocessing."}, "arroyo.strategies.run_task_with_multiprocessing.processes": {"name": "arroyo.strategies.run_task_with_multiprocessing.processes", "type": "Counter", "description": "A subprocess by multiprocessing unexpectedly died.\n\"sigchld.detected\",\nGauge: Shows how many processes the multiprocessing strategy is\nconfigured with."}, "arroyo.strategies.run_task_with_multiprocessing.pool.create": {"name": "arroyo.strategies.run_task_with_multiprocessing.pool.create", "type": "Counter", "description": "Incremented when the multiprocessing pool is created (or re-created)."}, "arroyo.consumer.poll.time": {"name": "arroyo.consumer.poll.time", "type": "Time", "description": "(unitless) spent polling librdkafka for new messages."}, "arroyo.consumer.processing.time": {"name": "arroyo.consumer.processing.time", "type": "Time", "description": "(unitless) spent in strategies (blocking in strategy.submit or\nstrategy.poll)"}, "arroyo.consumer.backpressure.time": {"name": "arroyo.consumer.backpressure.time", "type": "Time", "description": "(unitless) spent pausing the consumer due to backpressure (MessageRejected)"}, "arroyo.consumer.dlq.time": {"name": "arroyo.consumer.dlq.time", "type": "Time", "description": "(unitless) spent in handling `InvalidMessage` exceptions and sending\nmessages to the the DLQ."}, "arroyo.consumer.join.time": {"name": "arroyo.consumer.join.time", "type": "Time", "description": "(unitless) spent in waiting for the strategy to exit, such as during\nshutdown or rebalancing."}, "arroyo.consumer.callback.time": {"name": "arroyo.consumer.callback.time", "type": "Time", "description": "(unitless) spent in librdkafka callbacks. This metric's timings\noverlap other timings, and might spike at the same time."}, "arroyo.consumer.shutdown.time": {"name": "arroyo.consumer.shutdown.time", "type": "Time", "description": "(unitless) spent in shutting down the consumer. This metric's\ntimings overlap other timings, and might spike at the same time."}, "arroyo.consumer.run.callback": {"name": "arroyo.consumer.run.callback", "type": "Time", "description": "A regular duration metric where each datapoint is measuring the time it\ntook to execute a single callback. This metric is distinct from the\narroyo.consumer.*.time metrics as it does not attempt to accumulate time\nspent per second in an attempt to keep monitoring overhead low.\nThe metric is tagged by the name of the internal callback function being\nexecuted, as 'callback_name'. Possible values are on_partitions_assigned\nand on_partitions_revoked."}, "arroyo.consumer.run.close_strategy": {"name": "arroyo.consumer.run.close_strategy", "type": "Time", "description": "Duration metric measuring the time it took to flush in-flight messages\nand shut down the strategies."}, "arroyo.consumer.run.create_strategy": {"name": "arroyo.consumer.run.create_strategy", "type": "Time", "description": "Duration metric measuring the time it took to create the processing strategy."}, "arroyo.consumer.partitions_revoked.count": {"name": "arroyo.consumer.partitions_revoked.count", "type": "Counter", "description": "How many partitions have been revoked just now."}, "arroyo.consumer.partitions_assigned.count": {"name": "arroyo.consumer.partitions_assigned.count", "type": "Counter", "description": "How many partitions have been assigned just now."}, "arroyo.consumer.latency": {"name": "arroyo.consumer.latency", "type": "Time", "description": "Consumer latency in seconds. Recorded by the commit offsets strategy."}, "arroyo.consumer.pause": {"name": "arroyo.consumer.pause", "type": "Counter", "description": "Metric for when the underlying rdkafka consumer is being paused.\nThis flushes internal prefetch buffers."}, "arroyo.consumer.resume": {"name": "arroyo.consumer.resume", "type": "Counter", "description": "Metric for when the underlying rdkafka consumer is being resumed.\nThis might cause increased network usage as messages are being re-fetched."}, "arroyo.consumer.librdkafka.total_queue_size": {"name": "arroyo.consumer.librdkafka.total_queue_size", "type": "Gauge", "description": "Queue size of background queue that librdkafka uses to prefetch messages."}, "arroyo.processing.strategies.healthcheck.touch": {"name": "arroyo.processing.strategies.healthcheck.touch", "type": "Counter", "description": "Counter metric to measure how often the healthcheck file has been touched."}, "arroyo.strategies.filter.dropped_messages": {"name": "arroyo.strategies.filter.dropped_messages", "type": "Counter", "description": "Number of messages dropped in the FilterStep strategy"}, "arroyo.consumer.dlq.dropped_messages": {"name": "arroyo.consumer.dlq.dropped_messages", "type": "Counter", "description": "how many messages are dropped due to errors producing to the dlq"}, "arroyo.consumer.dlq_buffer.len": {"name": "arroyo.consumer.dlq_buffer.len", "type": "Gauge", "description": "Current length of the DLQ buffer deque"}, "arroyo.consumer.dlq_buffer.exceeded": {"name": "arroyo.consumer.dlq_buffer.exceeded", "type": "Counter", "description": "Number of times the DLQ buffer size has been exceeded, causing messages to be dropped"}, "arroyo.consumer.dlq_buffer.assigned_partitions": {"name": "arroyo.consumer.dlq_buffer.assigned_partitions", "type": "Gauge", "description": "Number of partitions being tracked in the DLQ buffer"}, "arroyo.producer.librdkafka.p99_int_latency": {"name": "arroyo.producer.librdkafka.p99_int_latency", "type": "Time", "description": "Internal producer queue latency from librdkafka statistics.\nTagged by broker_id."}, "arroyo.producer.librdkafka.p99_outbuf_latency": {"name": "arroyo.producer.librdkafka.p99_outbuf_latency", "type": "Time", "description": "Output buffer latency from librdkafka statistics.\nTagged by broker_id."}, "arroyo.producer.librdkafka.p99_rtt": {"name": "arroyo.producer.librdkafka.p99_rtt", "type": "Time", "description": "Round-trip time to brokers from librdkafka statistics.\nTagged by broker_id."}, "arroyo.producer.librdkafka.avg_int_latency": {"name": "arroyo.producer.librdkafka.avg_int_latency", "type": "Time", "description": "Average internal producer queue latency from librdkafka statistics.\nTagged by broker_id."}, "arroyo.producer.librdkafka.avg_outbuf_latency": {"name": "arroyo.producer.librdkafka.avg_outbuf_latency", "type": "Time", "description": "Average output buffer latency from librdkafka statistics.\nTagged by broker_id."}, "arroyo.producer.librdkafka.avg_rtt": {"name": "arroyo.producer.librdkafka.avg_rtt", "type": "Time", "description": "Average round-trip time to brokers from librdkafka statistics.\nTagged by broker_id."}}
|
|
1
|
+
{"arroyo.strategies.run_task_with_multiprocessing.batch.size.msg": {"name": "arroyo.strategies.run_task_with_multiprocessing.batch.size.msg", "type": "Time", "description": "Number of messages in a multiprocessing batch"}, "arroyo.strategies.run_task_with_multiprocessing.batch.size.bytes": {"name": "arroyo.strategies.run_task_with_multiprocessing.batch.size.bytes", "type": "Time", "description": "Number of bytes in a multiprocessing batch"}, "arroyo.strategies.run_task_with_multiprocessing.output_batch.size.msg": {"name": "arroyo.strategies.run_task_with_multiprocessing.output_batch.size.msg", "type": "Time", "description": "Number of messages in a multiprocessing batch after the message transformation"}, "arroyo.strategies.run_task_with_multiprocessing.output_batch.size.bytes": {"name": "arroyo.strategies.run_task_with_multiprocessing.output_batch.size.bytes", "type": "Time", "description": "Number of bytes in a multiprocessing batch after the message transformation"}, "arroyo.consumer.run.count": {"name": "arroyo.consumer.run.count", "type": "Counter", "description": "Number of times the consumer is spinning"}, "arroyo.consumer.invalid_message.count": {"name": "arroyo.consumer.invalid_message.count", "type": "Counter", "description": "Number of times the consumer encountered an invalid message."}, "arroyo.strategies.reduce.batch_time": {"name": "arroyo.strategies.reduce.batch_time", "type": "Time", "description": "How long it took the Reduce step to fill up a batch"}, "arroyo.strategies.run_task_with_multiprocessing.batch.backpressure": {"name": "arroyo.strategies.run_task_with_multiprocessing.batch.backpressure", "type": "Counter", "description": "Incremented when a strategy after multiprocessing applies\nbackpressure to multiprocessing. May be a reason why CPU cannot be\nsaturated."}, "arroyo.strategies.run_task_with_multiprocessing.batch.input.overflow": {"name": "arroyo.strategies.run_task_with_multiprocessing.batch.input.overflow", "type": "Counter", "description": "Incremented when multiprocessing cannot fill the input batch\nbecause not enough memory was allocated. This results in batches smaller\nthan configured. Increase `input_block_size` to fix."}, "arroyo.strategies.run_task_with_multiprocessing.batch.output.overflow": {"name": "arroyo.strategies.run_task_with_multiprocessing.batch.output.overflow", "type": "Counter", "description": "Incremented when multiprocessing cannot pull results in batches\nequal to the input batch size, because not enough memory was allocated.\nThis can be devastating for throughput. Increase `output_block_size` to\nfix."}, "arroyo.strategies.run_task_with_multiprocessing.batch.input.resize": {"name": "arroyo.strategies.run_task_with_multiprocessing.batch.input.resize", "type": "Counter", "description": "Arroyo has decided to re-allocate a block in order to combat input\nbuffer overflow. This behavior can be disabled by explicitly setting\n`input_block_size` to a not-None value in `RunTaskWithMultiprocessing`."}, "arroyo.strategies.run_task_with_multiprocessing.batch.output.resize": {"name": "arroyo.strategies.run_task_with_multiprocessing.batch.output.resize", "type": "Counter", "description": "Arroyo has decided to re-allocate a block in order to combat output\nbuffer overflow. This behavior can be disabled by explicitly setting\n`output_block_size` to a not-None value in `RunTaskWithMultiprocessing`."}, "arroyo.strategies.run_task_with_multiprocessing.batches_in_progress": {"name": "arroyo.strategies.run_task_with_multiprocessing.batches_in_progress", "type": "Gauge", "description": "How many batches are being processed in parallel by multiprocessing."}, "arroyo.strategies.run_task_with_multiprocessing.processes": {"name": "arroyo.strategies.run_task_with_multiprocessing.processes", "type": "Counter", "description": "A subprocess by multiprocessing unexpectedly died.\n\"sigchld.detected\",\nGauge: Shows how many processes the multiprocessing strategy is\nconfigured with."}, "arroyo.strategies.run_task_with_multiprocessing.pool.create": {"name": "arroyo.strategies.run_task_with_multiprocessing.pool.create", "type": "Counter", "description": "Incremented when the multiprocessing pool is created (or re-created)."}, "arroyo.consumer.poll.time": {"name": "arroyo.consumer.poll.time", "type": "Time", "description": "(unitless) spent polling librdkafka for new messages."}, "arroyo.consumer.processing.time": {"name": "arroyo.consumer.processing.time", "type": "Time", "description": "(unitless) spent in strategies (blocking in strategy.submit or\nstrategy.poll)"}, "arroyo.consumer.backpressure.time": {"name": "arroyo.consumer.backpressure.time", "type": "Time", "description": "(unitless) spent pausing the consumer due to backpressure (MessageRejected)"}, "arroyo.consumer.dlq.time": {"name": "arroyo.consumer.dlq.time", "type": "Time", "description": "(unitless) spent in handling `InvalidMessage` exceptions and sending\nmessages to the the DLQ."}, "arroyo.consumer.join.time": {"name": "arroyo.consumer.join.time", "type": "Time", "description": "(unitless) spent in waiting for the strategy to exit, such as during\nshutdown or rebalancing."}, "arroyo.consumer.callback.time": {"name": "arroyo.consumer.callback.time", "type": "Time", "description": "(unitless) spent in librdkafka callbacks. This metric's timings\noverlap other timings, and might spike at the same time."}, "arroyo.consumer.shutdown.time": {"name": "arroyo.consumer.shutdown.time", "type": "Time", "description": "(unitless) spent in shutting down the consumer. This metric's\ntimings overlap other timings, and might spike at the same time."}, "arroyo.consumer.run.callback": {"name": "arroyo.consumer.run.callback", "type": "Time", "description": "A regular duration metric where each datapoint is measuring the time it\ntook to execute a single callback. This metric is distinct from the\narroyo.consumer.*.time metrics as it does not attempt to accumulate time\nspent per second in an attempt to keep monitoring overhead low.\nThe metric is tagged by the name of the internal callback function being\nexecuted, as 'callback_name'. Possible values are on_partitions_assigned\nand on_partitions_revoked."}, "arroyo.consumer.run.close_strategy": {"name": "arroyo.consumer.run.close_strategy", "type": "Time", "description": "Duration metric measuring the time it took to flush in-flight messages\nand shut down the strategies."}, "arroyo.consumer.run.create_strategy": {"name": "arroyo.consumer.run.create_strategy", "type": "Time", "description": "Duration metric measuring the time it took to create the processing strategy."}, "arroyo.consumer.partitions_revoked.count": {"name": "arroyo.consumer.partitions_revoked.count", "type": "Counter", "description": "How many partitions have been revoked just now."}, "arroyo.consumer.partitions_assigned.count": {"name": "arroyo.consumer.partitions_assigned.count", "type": "Counter", "description": "How many partitions have been assigned just now."}, "arroyo.consumer.latency": {"name": "arroyo.consumer.latency", "type": "Time", "description": "Consumer latency in seconds. Recorded by the commit offsets strategy."}, "arroyo.consumer.pause": {"name": "arroyo.consumer.pause", "type": "Counter", "description": "Metric for when the underlying rdkafka consumer is being paused.\nThis flushes internal prefetch buffers."}, "arroyo.consumer.resume": {"name": "arroyo.consumer.resume", "type": "Counter", "description": "Metric for when the underlying rdkafka consumer is being resumed.\nThis might cause increased network usage as messages are being re-fetched."}, "arroyo.consumer.librdkafka.total_queue_size": {"name": "arroyo.consumer.librdkafka.total_queue_size", "type": "Gauge", "description": "Queue size of background queue that librdkafka uses to prefetch messages."}, "arroyo.processing.strategies.healthcheck.touch": {"name": "arroyo.processing.strategies.healthcheck.touch", "type": "Counter", "description": "Counter metric to measure how often the healthcheck file has been touched."}, "arroyo.strategies.filter.dropped_messages": {"name": "arroyo.strategies.filter.dropped_messages", "type": "Counter", "description": "Number of messages dropped in the FilterStep strategy"}, "arroyo.consumer.dlq.dropped_messages": {"name": "arroyo.consumer.dlq.dropped_messages", "type": "Counter", "description": "how many messages are dropped due to errors producing to the dlq"}, "arroyo.consumer.dlq_buffer.len": {"name": "arroyo.consumer.dlq_buffer.len", "type": "Gauge", "description": "Current length of the DLQ buffer deque"}, "arroyo.consumer.dlq_buffer.exceeded": {"name": "arroyo.consumer.dlq_buffer.exceeded", "type": "Counter", "description": "Number of times the DLQ buffer size has been exceeded, causing messages to be dropped"}, "arroyo.consumer.dlq_buffer.assigned_partitions": {"name": "arroyo.consumer.dlq_buffer.assigned_partitions", "type": "Gauge", "description": "Number of partitions being tracked in the DLQ buffer"}, "arroyo.producer.librdkafka.p99_int_latency": {"name": "arroyo.producer.librdkafka.p99_int_latency", "type": "Time", "description": "Internal producer queue latency from librdkafka statistics.\nTagged by broker_id."}, "arroyo.producer.librdkafka.p99_outbuf_latency": {"name": "arroyo.producer.librdkafka.p99_outbuf_latency", "type": "Time", "description": "Output buffer latency from librdkafka statistics.\nTagged by broker_id."}, "arroyo.producer.librdkafka.p99_rtt": {"name": "arroyo.producer.librdkafka.p99_rtt", "type": "Time", "description": "Round-trip time to brokers from librdkafka statistics.\nTagged by broker_id."}, "arroyo.producer.librdkafka.avg_int_latency": {"name": "arroyo.producer.librdkafka.avg_int_latency", "type": "Time", "description": "Average internal producer queue latency from librdkafka statistics.\nTagged by broker_id."}, "arroyo.producer.librdkafka.avg_outbuf_latency": {"name": "arroyo.producer.librdkafka.avg_outbuf_latency", "type": "Time", "description": "Average output buffer latency from librdkafka statistics.\nTagged by broker_id."}, "arroyo.producer.librdkafka.avg_rtt": {"name": "arroyo.producer.librdkafka.avg_rtt", "type": "Time", "description": "Average round-trip time to brokers from librdkafka statistics.\nTagged by broker_id."}, "arroyo.producer.produce_status": {"name": "arroyo.producer.produce_status", "type": "Counter", "description": "Number of times the produce strategy failed to produce a message"}}
|
arroyo/utils/metric_defs.py
CHANGED
|
@@ -124,4 +124,6 @@ MetricName = Literal[
|
|
|
124
124
|
# Time: Average round-trip time to brokers from librdkafka statistics.
|
|
125
125
|
# Tagged by broker_id.
|
|
126
126
|
"arroyo.producer.librdkafka.avg_rtt",
|
|
127
|
+
# Counter: Number of times the produce strategy failed to produce a message
|
|
128
|
+
"arroyo.producer.produce_status",
|
|
127
129
|
]
|
arroyo/utils/metrics.py
CHANGED
|
@@ -45,45 +45,6 @@ class Metrics(Protocol):
|
|
|
45
45
|
raise NotImplementedError
|
|
46
46
|
|
|
47
47
|
|
|
48
|
-
class ConsumerMetricsWrapper(Metrics):
|
|
49
|
-
"""
|
|
50
|
-
A wrapper around a metrics backend that automatically adds consumer_member_id
|
|
51
|
-
to all metrics calls.
|
|
52
|
-
|
|
53
|
-
Right now we only use this to add tags to the metrics emitted by
|
|
54
|
-
StreamProcessor, but ideally all metrics, even those emitted by strategies
|
|
55
|
-
and application code, would get this tag. The metrics abstraction in arroyo
|
|
56
|
-
is not sufficient for this. We'd have to add a "add_global_tags" method
|
|
57
|
-
(similar to the concept of global tags in sentry) and users would have to
|
|
58
|
-
implement it.
|
|
59
|
-
"""
|
|
60
|
-
|
|
61
|
-
def __init__(self, metrics: Metrics) -> None:
|
|
62
|
-
self.__metrics = metrics
|
|
63
|
-
self.consumer_member_id = ""
|
|
64
|
-
|
|
65
|
-
def _add_consumer_tag(self, tags: Optional[Tags]) -> Tags:
|
|
66
|
-
return {**(tags or {}), "consumer_member_id": self.consumer_member_id}
|
|
67
|
-
|
|
68
|
-
def increment(
|
|
69
|
-
self,
|
|
70
|
-
name: MetricName,
|
|
71
|
-
value: Union[int, float] = 1,
|
|
72
|
-
tags: Optional[Tags] = None,
|
|
73
|
-
) -> None:
|
|
74
|
-
self.__metrics.increment(name, value, tags=self._add_consumer_tag(tags))
|
|
75
|
-
|
|
76
|
-
def gauge(
|
|
77
|
-
self, name: MetricName, value: Union[int, float], tags: Optional[Tags] = None
|
|
78
|
-
) -> None:
|
|
79
|
-
self.__metrics.gauge(name, value, tags=self._add_consumer_tag(tags))
|
|
80
|
-
|
|
81
|
-
def timing(
|
|
82
|
-
self, name: MetricName, value: Union[int, float], tags: Optional[Tags] = None
|
|
83
|
-
) -> None:
|
|
84
|
-
self.__metrics.timing(name, value, tags=self._add_consumer_tag(tags))
|
|
85
|
-
|
|
86
|
-
|
|
87
48
|
class DummyMetricsBackend(Metrics):
|
|
88
49
|
"""
|
|
89
50
|
Default metrics backend that does not record anything.
|
|
@@ -172,12 +133,4 @@ def get_metrics() -> Metrics:
|
|
|
172
133
|
return _metrics_backend
|
|
173
134
|
|
|
174
135
|
|
|
175
|
-
|
|
176
|
-
"""
|
|
177
|
-
Get a metrics backend that automatically adds consumer_member_id to all metrics.
|
|
178
|
-
"""
|
|
179
|
-
base_metrics = get_metrics()
|
|
180
|
-
return ConsumerMetricsWrapper(base_metrics)
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
__all__ = ["configure_metrics", "Metrics", "MetricName", "Tags", "get_consumer_metrics"]
|
|
136
|
+
__all__ = ["configure_metrics", "Metrics", "MetricName", "Tags"]
|
|
@@ -16,7 +16,7 @@ arroyo/backends/local/storages/__init__.py,sha256=AGYujdAAcn3osoj9jq84IzTywYbkID
|
|
|
16
16
|
arroyo/backends/local/storages/abstract.py,sha256=1qVQp6roxHkK6XT2aklZyZk1qq7RzcPN6Db_CA5--kg,2901
|
|
17
17
|
arroyo/backends/local/storages/memory.py,sha256=AoKDsVZzBXkOJyWArKWp3vfGfU9xLlKFXE9gsJiMIzQ,2613
|
|
18
18
|
arroyo/processing/__init__.py,sha256=vZVg0wJvJfoVzlzGvnL59bT6YNIRJNQ5t7oU045Qbk4,87
|
|
19
|
-
arroyo/processing/processor.py,sha256=
|
|
19
|
+
arroyo/processing/processor.py,sha256=CNhybC2nISlja2GoSOWmPnn5_UQin4i07feXWkZCtww,21128
|
|
20
20
|
arroyo/processing/strategies/__init__.py,sha256=EU_JMb54eOxMxaC5mIFpI-sAF-X2ZScbE8czBZ7bQkY,1106
|
|
21
21
|
arroyo/processing/strategies/abstract.py,sha256=nu7juEz_aQmQIH35Z8u--FBuLjkK8_LQ1hIG2xpw9AA,4808
|
|
22
22
|
arroyo/processing/strategies/batching.py,sha256=s89xC6lQpBseEaApu1iNTipXGKeO95OMwinj2VBKn9s,4778
|
|
@@ -26,7 +26,7 @@ arroyo/processing/strategies/filter.py,sha256=dzx9BaIVigxFGfsrNYAWJYTDCanIp3RiV9
|
|
|
26
26
|
arroyo/processing/strategies/guard.py,sha256=W2Nsy8LW6RWYPh-_ReljR8_lkPgipOG8LhtDR-DDlto,4878
|
|
27
27
|
arroyo/processing/strategies/healthcheck.py,sha256=fEVB516nZVZWvZLzi4_ImaE6F7QQQJIymW6HgiUYUSA,1775
|
|
28
28
|
arroyo/processing/strategies/noop.py,sha256=BtWkC93QpZCKAB4qTsXLaqrYsllE1Olp6mY2YeuK9ag,726
|
|
29
|
-
arroyo/processing/strategies/produce.py,sha256=
|
|
29
|
+
arroyo/processing/strategies/produce.py,sha256=7ZbKB0tT8AcUXhACSeuVXAS-rgCTJKfUuWBQfZIkawM,5126
|
|
30
30
|
arroyo/processing/strategies/reduce.py,sha256=xv9bYisgHHyS8fVD1PdGi4TJsaK-4RAhMEDh4WHhYfI,3933
|
|
31
31
|
arroyo/processing/strategies/run_task.py,sha256=MGe2UcIWN7FkPc9plKzRVUNbZ7Sk0jWjw1z2vVOFI_I,2160
|
|
32
32
|
arroyo/processing/strategies/run_task_in_threads.py,sha256=f1sb2AG-BLz11X78jfhtERIkdFogrV8vtdT3pyJdkx0,6144
|
|
@@ -37,16 +37,16 @@ arroyo/utils/clock.py,sha256=r2EMO4nL5qIb1xnAd1sTAk2yK1UltyUi04lk5BqWKIc,944
|
|
|
37
37
|
arroyo/utils/codecs.py,sha256=x-8SJK0GLTOH4c_k24K97JPjBckxyQJcSpgoEViGUy0,541
|
|
38
38
|
arroyo/utils/concurrent.py,sha256=dbdPinjqmxCQ7izUGFNbGjB3OxfSIO01bnCSTANaVOE,1187
|
|
39
39
|
arroyo/utils/logging.py,sha256=Y1PnhYcI9XNNEK0H13Ct2xKLr2Niuw0dxayc6sWnui8,606
|
|
40
|
-
arroyo/utils/metricDefs.json,sha256=
|
|
41
|
-
arroyo/utils/metric_defs.py,sha256=
|
|
42
|
-
arroyo/utils/metrics.py,sha256=
|
|
40
|
+
arroyo/utils/metricDefs.json,sha256=craG10l31YnSzEUIeBPZFiyAAvrC3Gf9YZAbonc-gco,10444
|
|
41
|
+
arroyo/utils/metric_defs.py,sha256=43EgeEIx9pfTRzd1CGMoDx_M9g4fuhZjF7FWiuFeNSU,7401
|
|
42
|
+
arroyo/utils/metrics.py,sha256=kcyUR5cacoPMoU80RHSUhTMNzEcMBDpTXzcyW7yWZBk,3308
|
|
43
43
|
arroyo/utils/profiler.py,sha256=aiYy2RRPX_IiDIO7AnFM3hARaHCctS3rqUS5nrHXbSg,2452
|
|
44
44
|
arroyo/utils/retries.py,sha256=4MRhHUR7da9x1ytlo7YETo8S9HEebXmPF2-mKP4xYz0,3445
|
|
45
45
|
examples/transform_and_produce/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
46
46
|
examples/transform_and_produce/batched.py,sha256=st2R6qTneAtV0JFbKP30Ti3sJDYj8Jkbmta9JckKdZU,2636
|
|
47
47
|
examples/transform_and_produce/script.py,sha256=8kSMIjQNqGYEVyE0PvrfJh-a_UYCrJSstTp_De7kyyg,2306
|
|
48
48
|
examples/transform_and_produce/simple.py,sha256=H7xqxItjl4tx34wVW5dy6mB9G39QucAtxkJSBzVmjgA,1637
|
|
49
|
-
sentry_arroyo-2.
|
|
49
|
+
sentry_arroyo-2.28.1.dist-info/licenses/LICENSE,sha256=0Ng3MFdEcnz0sVD1XvGBBzbavvNp_7OAM5yVObB46jU,10829
|
|
50
50
|
tests/backends/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
51
51
|
tests/backends/mixins.py,sha256=sfNyE0VTeiD3GHOnBYl-9urvPuURI2G1BWke0cz7Dvc,20445
|
|
52
52
|
tests/backends/test_commit.py,sha256=iTHfK1qsBxim0XwxgMvNNSMqDUMEHoYkYBDcgxGBFbs,831
|
|
@@ -71,9 +71,9 @@ tests/processing/strategies/test_run_task_with_multiprocessing.py,sha256=eyv3O5X
|
|
|
71
71
|
tests/processing/strategies/test_unfold.py,sha256=mbC4XhT6GkJRuC7vPR0h7jqwt4cu20q7Z114EJ6J9mQ,2009
|
|
72
72
|
tests/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
73
73
|
tests/utils/test_concurrent.py,sha256=Gwdzym2UZ1HO3rhOSGmzxImWcLFygY8P7MXHT3Q0xTE,455
|
|
74
|
-
tests/utils/test_metrics.py,sha256=
|
|
74
|
+
tests/utils/test_metrics.py,sha256=bI0EtGgPokMQyEqX58i0-8zvLfxRP2nWaWr2wLMaJ_o,917
|
|
75
75
|
tests/utils/test_retries.py,sha256=AxJLkXWeL9AjHv_p1n0pe8CXXJp24ZQIuYBHfNcmiz4,3075
|
|
76
|
-
sentry_arroyo-2.
|
|
77
|
-
sentry_arroyo-2.
|
|
78
|
-
sentry_arroyo-2.
|
|
79
|
-
sentry_arroyo-2.
|
|
76
|
+
sentry_arroyo-2.28.1.dist-info/METADATA,sha256=lPU0XakUT5M-iyiJeHw1wBAyt3iVOiYpJEHG0ETqlpc,2208
|
|
77
|
+
sentry_arroyo-2.28.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
78
|
+
sentry_arroyo-2.28.1.dist-info/top_level.txt,sha256=DVdMZKysL_iIxm5aY0sYgZtP5ZXMg9YBaBmGQHVmDXA,22
|
|
79
|
+
sentry_arroyo-2.28.1.dist-info/RECORD,,
|
tests/utils/test_metrics.py
CHANGED
|
@@ -1,19 +1,8 @@
|
|
|
1
1
|
import pytest
|
|
2
2
|
|
|
3
|
-
from arroyo.utils.metrics import
|
|
4
|
-
Gauge,
|
|
5
|
-
MetricName,
|
|
6
|
-
configure_metrics,
|
|
7
|
-
get_consumer_metrics,
|
|
8
|
-
get_metrics,
|
|
9
|
-
)
|
|
3
|
+
from arroyo.utils.metrics import Gauge, MetricName, configure_metrics, get_metrics
|
|
10
4
|
from tests.metrics import Gauge as GaugeCall
|
|
11
|
-
from tests.metrics import
|
|
12
|
-
Increment,
|
|
13
|
-
TestingMetricsBackend,
|
|
14
|
-
Timing,
|
|
15
|
-
_TestingMetricsBackend,
|
|
16
|
-
)
|
|
5
|
+
from tests.metrics import TestingMetricsBackend, _TestingMetricsBackend
|
|
17
6
|
|
|
18
7
|
|
|
19
8
|
def test_gauge_simple() -> None:
|
|
@@ -42,43 +31,3 @@ def test_configure_metrics() -> None:
|
|
|
42
31
|
# Can be reset to something else with force
|
|
43
32
|
configure_metrics(_TestingMetricsBackend(), force=True)
|
|
44
33
|
assert get_metrics() != TestingMetricsBackend
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
def test_consumer_metrics_wrapper() -> None:
|
|
48
|
-
"""Test that ConsumerMetricsWrapper automatically adds consumer_member_id to all metrics."""
|
|
49
|
-
# Reset to a fresh backend
|
|
50
|
-
backend = _TestingMetricsBackend()
|
|
51
|
-
configure_metrics(backend, force=True)
|
|
52
|
-
|
|
53
|
-
consumer_member_id = "test-consumer-123"
|
|
54
|
-
consumer_metrics = get_consumer_metrics()
|
|
55
|
-
consumer_metrics.consumer_member_id = consumer_member_id
|
|
56
|
-
|
|
57
|
-
# Test increment
|
|
58
|
-
consumer_metrics.increment("arroyo.consumer.run.count", 5, tags={"extra": "tag"})
|
|
59
|
-
|
|
60
|
-
# Test gauge
|
|
61
|
-
consumer_metrics.gauge("arroyo.consumer.librdkafka.total_queue_size", 10.5)
|
|
62
|
-
|
|
63
|
-
# Test timing
|
|
64
|
-
consumer_metrics.timing("arroyo.consumer.poll.time", 100, tags={"another": "tag"})
|
|
65
|
-
|
|
66
|
-
expected_calls = [
|
|
67
|
-
Increment(
|
|
68
|
-
"arroyo.consumer.run.count",
|
|
69
|
-
5,
|
|
70
|
-
{"consumer_member_id": consumer_member_id, "extra": "tag"},
|
|
71
|
-
),
|
|
72
|
-
GaugeCall(
|
|
73
|
-
"arroyo.consumer.librdkafka.total_queue_size",
|
|
74
|
-
10.5,
|
|
75
|
-
{"consumer_member_id": consumer_member_id},
|
|
76
|
-
),
|
|
77
|
-
Timing(
|
|
78
|
-
"arroyo.consumer.poll.time",
|
|
79
|
-
100,
|
|
80
|
-
{"consumer_member_id": consumer_member_id, "another": "tag"},
|
|
81
|
-
),
|
|
82
|
-
]
|
|
83
|
-
|
|
84
|
-
assert backend.calls == expected_calls
|
|
File without changes
|
|
File without changes
|
|
File without changes
|