Exemplo n.º 1
0
        private void PublishBrokerStats(Dictionary <string, BrokerStatistic> statisticsBrokers)
        {
            long now = DateTime.Now.GetMilliseconds();

            foreach (var broker in statisticsBrokers)
            {
                LibrdKafkaSensor.ScopedLibrdKafkaSensor.Record(TotalNumberOfResponsesReceivedSensor
                                                               .Scoped((LibrdKafkaBaseMetrics.BROKER_ID_TAG, broker.Value.NodeId.ToString()))
                                                               , broker.Value.TotalNumberOfResponsesReceived, now);
                LibrdKafkaSensor.ScopedLibrdKafkaSensor.Record(TotalNumberOfBytesReceivedSensor
                                                               .Scoped((LibrdKafkaBaseMetrics.BROKER_ID_TAG, broker.Value.NodeId.ToString()))
                                                               , broker.Value.TotalNumberOfBytesReceived, now);
                LibrdKafkaSensor.ScopedLibrdKafkaSensor.Record(TotalNumberOfReceivedErrorsSensor
                                                               .Scoped((LibrdKafkaBaseMetrics.BROKER_ID_TAG, broker.Value.NodeId.ToString()))
                                                               , broker.Value.TotalNumberOfReceivedErrors, now);
                LibrdKafkaSensor.ScopedLibrdKafkaSensor.Record(NumberOfConnectionAttempsSensor
                                                               .Scoped((LibrdKafkaBaseMetrics.BROKER_ID_TAG, broker.Value.NodeId.ToString()))
                                                               , broker.Value.NumberOfConnectionAttemps, now);
                LibrdKafkaSensor.ScopedLibrdKafkaSensor.Record(NumberOfDisconnectsSensor
                                                               .Scoped((LibrdKafkaBaseMetrics.BROKER_ID_TAG, broker.Value.NodeId.ToString()))
                                                               , broker.Value.NumberOfDisconnects, now);
                LibrdKafkaSensor.ScopedLibrdKafkaSensor.Record(BrokerLatencyAverageMsSensor
                                                               .Scoped((LibrdKafkaBaseMetrics.BROKER_ID_TAG, broker.Value.NodeId.ToString()))
                                                               , broker.Value.BrokerLatency.Average, now);
            }

            TotalNumberOfResponsesReceivedSensor.RemoveOldScopeSensor(now);
            TotalNumberOfBytesReceivedSensor.RemoveOldScopeSensor(now);
            TotalNumberOfReceivedErrorsSensor.RemoveOldScopeSensor(now);
            NumberOfConnectionAttempsSensor.RemoveOldScopeSensor(now);
            NumberOfDisconnectsSensor.RemoveOldScopeSensor(now);
            BrokerLatencyAverageMsSensor.RemoveOldScopeSensor(now);
        }
        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);
            }
        }
Exemplo n.º 3
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);
        }
        private void PublishBrokerStats(Dictionary <string, BrokerStatistic> statisticsBrokers)
        {
            long now = DateTime.Now.GetMilliseconds();

            foreach (var broker in statisticsBrokers)
            {
                LibrdKafkaSensor.ScopedLibrdKafkaSensor.Record(NumberOfRequestAwaitingTransmissionSensor
                                                               .Scoped((LibrdKafkaBaseMetrics.BROKER_ID_TAG, broker.Value.NodeId.ToString()))
                                                               , broker.Value.NumberOfRequestAwaitingTransmission, now);
                LibrdKafkaSensor.ScopedLibrdKafkaSensor.Record(NumberOfMessagesAwaitingTransmissionSensor
                                                               .Scoped((LibrdKafkaBaseMetrics.BROKER_ID_TAG, broker.Value.NodeId.ToString()))
                                                               , broker.Value.NumberOfMessagesAwaitingTransmission, now);
                LibrdKafkaSensor.ScopedLibrdKafkaSensor.Record(NumberOfRequestInFlightSensor
                                                               .Scoped((LibrdKafkaBaseMetrics.BROKER_ID_TAG, broker.Value.NodeId.ToString()))
                                                               , broker.Value.NumberOfRequestInFlight, now);
                LibrdKafkaSensor.ScopedLibrdKafkaSensor.Record(NumberOfMessagesInFlightSensor
                                                               .Scoped((LibrdKafkaBaseMetrics.BROKER_ID_TAG, broker.Value.NodeId.ToString()))
                                                               , broker.Value.NumberOfMessagesInFlight, now);
                LibrdKafkaSensor.ScopedLibrdKafkaSensor.Record(TotalNumberOfRequestSentSensor
                                                               .Scoped((LibrdKafkaBaseMetrics.BROKER_ID_TAG, broker.Value.NodeId.ToString()))
                                                               , broker.Value.TotalNumberOfRequestSent, now);
                LibrdKafkaSensor.ScopedLibrdKafkaSensor.Record(TotalNumberOfBytesSentSensor
                                                               .Scoped((LibrdKafkaBaseMetrics.BROKER_ID_TAG, broker.Value.NodeId.ToString()))
                                                               , broker.Value.TotalNumberOfBytesSent, now);
                LibrdKafkaSensor.ScopedLibrdKafkaSensor.Record(TotalNumberOfTransmissionErrorsSensor
                                                               .Scoped((LibrdKafkaBaseMetrics.BROKER_ID_TAG, broker.Value.NodeId.ToString()))
                                                               , broker.Value.TotalNumberOfTransmissionErrors, now);
                LibrdKafkaSensor.ScopedLibrdKafkaSensor.Record(TotalNumberOfRequestRetriesSensor
                                                               .Scoped((LibrdKafkaBaseMetrics.BROKER_ID_TAG, broker.Value.NodeId.ToString()))
                                                               , broker.Value.TotalNumberOfRequestRetries, now);
                LibrdKafkaSensor.ScopedLibrdKafkaSensor.Record(TotalNumberOfRequestTimeoutSensor
                                                               .Scoped((LibrdKafkaBaseMetrics.BROKER_ID_TAG, broker.Value.NodeId.ToString()))
                                                               , broker.Value.TotalNumberOfRequestTimeout, now);
                LibrdKafkaSensor.ScopedLibrdKafkaSensor.Record(NumberOfConnectionAttempsSensor
                                                               .Scoped((LibrdKafkaBaseMetrics.BROKER_ID_TAG, broker.Value.NodeId.ToString()))
                                                               , broker.Value.NumberOfConnectionAttemps, now);
                LibrdKafkaSensor.ScopedLibrdKafkaSensor.Record(NumberOfDisconnectsSensor
                                                               .Scoped((LibrdKafkaBaseMetrics.BROKER_ID_TAG, broker.Value.NodeId.ToString()))
                                                               , broker.Value.NumberOfDisconnects, now);
                LibrdKafkaSensor.ScopedLibrdKafkaSensor.Record(InternalQueueProducerLatencyAverageMsSensor
                                                               .Scoped((LibrdKafkaBaseMetrics.BROKER_ID_TAG, broker.Value.NodeId.ToString()))
                                                               , broker.Value.InternalQueueProducerLatency.Average, now);
                LibrdKafkaSensor.ScopedLibrdKafkaSensor.Record(InternalRequestQueueLatencyAverageMsSensor
                                                               .Scoped((LibrdKafkaBaseMetrics.BROKER_ID_TAG, broker.Value.NodeId.ToString()))
                                                               , broker.Value.InternalRequestQueueLatency.Average, now);
                LibrdKafkaSensor.ScopedLibrdKafkaSensor.Record(BrokerLatencyAverageMsSensor
                                                               .Scoped((LibrdKafkaBaseMetrics.BROKER_ID_TAG, broker.Value.NodeId.ToString()))
                                                               , broker.Value.BrokerLatency.Average, now);
            }

            NumberOfRequestAwaitingTransmissionSensor.RemoveOldScopeSensor(now);
            NumberOfMessagesAwaitingTransmissionSensor.RemoveOldScopeSensor(now);
            NumberOfRequestInFlightSensor.RemoveOldScopeSensor(now);
            NumberOfMessagesInFlightSensor.RemoveOldScopeSensor(now);
            TotalNumberOfRequestSentSensor.RemoveOldScopeSensor(now);
            TotalNumberOfBytesSentSensor.RemoveOldScopeSensor(now);
            TotalNumberOfTransmissionErrorsSensor.RemoveOldScopeSensor(now);
            TotalNumberOfRequestRetriesSensor.RemoveOldScopeSensor(now);
            TotalNumberOfRequestTimeoutSensor.RemoveOldScopeSensor(now);
            NumberOfConnectionAttempsSensor.RemoveOldScopeSensor(now);
            NumberOfDisconnectsSensor.RemoveOldScopeSensor(now);
            InternalQueueProducerLatencyAverageMsSensor.RemoveOldScopeSensor(now);
            InternalRequestQueueLatencyAverageMsSensor.RemoveOldScopeSensor(now);
            BrokerLatencyAverageMsSensor.RemoveOldScopeSensor(now);
        }