def test_on_message_in(self, monitor: PrometheusMonitor, metrics: FaustMetrics) -> None: message = Mock(name="message") monitor.on_message_in(TP1, 400, message) self.assert_has_sample_value(metrics.messages_received, "messages_received_total", {}, 1) self.assert_has_sample_value(metrics.active_messages, "active_messages", {}, 1) self.assert_has_sample_value( metrics.messages_received_per_topics, "messages_received_per_topic_total", {"topic": "foo"}, 1, ) self.assert_has_sample_value( metrics.messages_received_per_topics_partition, "messages_received_per_topics_partition", { "topic": "foo", "partition": "3" }, 400, )
def _handle_event( self, monitor: PrometheusMonitor, topic_partition: TP, stream: StreamT, event: EventT, offset: int, ) -> None: monitor.track_tp_end_offset(topic_partition, offset + 5) monitor.on_message_in(topic_partition, offset, event.message) monitor.on_stream_event_in(topic_partition, offset, stream, event) monitor.on_tp_commit({topic_partition: offset})