private void PublishTopicsStats(Dictionary <string, TopicStatistic> statisticsTopics)
        {
            long now = DateTime.Now.GetMilliseconds();

            PublishTopicsStatistics(statisticsTopics);

            foreach (var topic in statisticsTopics)
            {
                foreach (var partition in topic.Value.Partitions)
                {
                    LibrdKafkaSensor.ScopedLibrdKafkaSensor.Record(PartitionTotalNumberOfMessagesProducedSensor
                                                                   .Scoped(
                                                                       (LibrdKafkaBaseMetrics.TOPIC_TAG, topic.Value.TopicName),
                                                                       (LibrdKafkaBaseMetrics.BROKER_ID_TAG, partition.Value.BrokerId.ToString()),
                                                                       (LibrdKafkaBaseMetrics.PARTITION_ID_TAG, partition.Value.PartitionId.ToString()))
                                                                   , partition.Value.TotalNumberOfMessagesProduced, now);

                    LibrdKafkaSensor.ScopedLibrdKafkaSensor.Record(PartitionTotalNumberOfBytesProducedSensor
                                                                   .Scoped(
                                                                       (LibrdKafkaBaseMetrics.TOPIC_TAG, topic.Value.TopicName),
                                                                       (LibrdKafkaBaseMetrics.BROKER_ID_TAG, partition.Value.BrokerId.ToString()),
                                                                       (LibrdKafkaBaseMetrics.PARTITION_ID_TAG, partition.Value.PartitionId.ToString()))
                                                                   , partition.Value.TotalNumberOfBytesProduced, now);

                    LibrdKafkaSensor.ScopedLibrdKafkaSensor.Record(PartitionNumberOfMessagesInFlightSensor
                                                                   .Scoped(
                                                                       (LibrdKafkaBaseMetrics.TOPIC_TAG, topic.Value.TopicName),
                                                                       (LibrdKafkaBaseMetrics.BROKER_ID_TAG, partition.Value.BrokerId.ToString()),
                                                                       (LibrdKafkaBaseMetrics.PARTITION_ID_TAG, partition.Value.PartitionId.ToString()))
                                                                   , partition.Value.NumberOfMessagesInFlight, now);

                    LibrdKafkaSensor.ScopedLibrdKafkaSensor.Record(PartitionNextExpectedAckSequenceSensor
                                                                   .Scoped(
                                                                       (LibrdKafkaBaseMetrics.TOPIC_TAG, topic.Value.TopicName),
                                                                       (LibrdKafkaBaseMetrics.BROKER_ID_TAG, partition.Value.BrokerId.ToString()),
                                                                       (LibrdKafkaBaseMetrics.PARTITION_ID_TAG, partition.Value.PartitionId.ToString()))
                                                                   , partition.Value.NextExpectedAckSequence, now);

                    LibrdKafkaSensor.ScopedLibrdKafkaSensor.Record(PartitionLastInternalMessageIdAckedSensor
                                                                   .Scoped(
                                                                       (LibrdKafkaBaseMetrics.TOPIC_TAG, topic.Value.TopicName),
                                                                       (LibrdKafkaBaseMetrics.BROKER_ID_TAG, partition.Value.BrokerId.ToString()),
                                                                       (LibrdKafkaBaseMetrics.PARTITION_ID_TAG, partition.Value.PartitionId.ToString()))
                                                                   , partition.Value.LastInternalMessageIdAcked, now);
                }

                BatchSizeAverageBytesSensor.RemoveOldScopeSensor(now);
                BatchMessageCountsAverageSensor.RemoveOldScopeSensor(now);
                PartitionTotalNumberOfMessagesProducedSensor.RemoveOldScopeSensor(now);
                PartitionTotalNumberOfBytesProducedSensor.RemoveOldScopeSensor(now);
                PartitionNumberOfMessagesInFlightSensor.RemoveOldScopeSensor(now);
                PartitionNextExpectedAckSequenceSensor.RemoveOldScopeSensor(now);
                PartitionLastInternalMessageIdAckedSensor.RemoveOldScopeSensor(now);
            }
        }
Exemple #2
0
        private void PublishTopicsStats(Dictionary <string, TopicStatistic> statisticsTopics)
        {
            long now = DateTime.Now.GetMilliseconds();

            PublishTopicsStatistics(statisticsTopics);

            foreach (var topic in statisticsTopics)
            {
                foreach (var partition in topic.Value.Partitions)
                {
                    LibrdKafkaSensor.ScopedLibrdKafkaSensor.Record(ConsumerLagSensor
                                                                   .Scoped(
                                                                       (LibrdKafkaBaseMetrics.TOPIC_TAG, topic.Value.TopicName),
                                                                       (LibrdKafkaBaseMetrics.BROKER_ID_TAG, partition.Value.BrokerId.ToString()),
                                                                       (LibrdKafkaBaseMetrics.PARTITION_ID_TAG, partition.Value.PartitionId.ToString()))
                                                                   , partition.Value.ConsumerLag, now);

                    LibrdKafkaSensor.ScopedLibrdKafkaSensor.Record(TotalNumberOfMessagesConsumedByPartitionSensor
                                                                   .Scoped(
                                                                       (LibrdKafkaBaseMetrics.TOPIC_TAG, topic.Value.TopicName),
                                                                       (LibrdKafkaBaseMetrics.BROKER_ID_TAG, partition.Value.BrokerId.ToString()),
                                                                       (LibrdKafkaBaseMetrics.PARTITION_ID_TAG, partition.Value.PartitionId.ToString()))
                                                                   , partition.Value.TotalNumberOfMessagesconsumed, now);

                    LibrdKafkaSensor.ScopedLibrdKafkaSensor.Record(TotalNumberOfBytesConsumedByPartitionSensor
                                                                   .Scoped(
                                                                       (LibrdKafkaBaseMetrics.TOPIC_TAG, topic.Value.TopicName),
                                                                       (LibrdKafkaBaseMetrics.BROKER_ID_TAG, partition.Value.BrokerId.ToString()),
                                                                       (LibrdKafkaBaseMetrics.PARTITION_ID_TAG, partition.Value.PartitionId.ToString()))
                                                                   , partition.Value.TotalNumberOfBytesConsumed, now);
                }
            }

            BatchSizeAverageBytesSensor.RemoveOldScopeSensor(now);
            BatchMessageCountsAverageSensor.RemoveOldScopeSensor(now);
            ConsumerLagSensor.RemoveOldScopeSensor(now);
            TotalNumberOfMessagesConsumedByPartitionSensor.RemoveOldScopeSensor(now);
            TotalNumberOfBytesConsumedByPartitionSensor.RemoveOldScopeSensor(now);
        }