Beispiel #1
0
    def test_on_tp_commit(self, monitor: PrometheusMonitor,
                          metrics: FaustMetrics) -> None:
        offsets = {TP("foo", 0): 1001, TP("foo", 1): 2002, TP("bar", 3): 3003}

        monitor.on_tp_commit(offsets)

        self.assert_has_sample_value(
            metrics.topic_partition_offset_commited,
            "topic_partition_offset_commited",
            {
                "topic": "foo",
                "partition": "0"
            },
            1001,
        )
        self.assert_has_sample_value(
            metrics.topic_partition_offset_commited,
            "topic_partition_offset_commited",
            {
                "topic": "foo",
                "partition": "1"
            },
            2002,
        )
        self.assert_has_sample_value(
            metrics.topic_partition_offset_commited,
            "topic_partition_offset_commited",
            {
                "topic": "bar",
                "partition": "3"
            },
            3003,
        )
Beispiel #2
0
 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})