Ejemplo n.º 1
0
 public override void Register(StreamMetricsRegistry metricsRegistry)
 {
     TotalNumberOfMessagesConsumedSensor =
         LibrdKafkaConsumerMetrics.TotalNumberOfMessagesConsumedSensor(threadId, clientId, streamAppId,
                                                                       metricsRegistry);
     TotalNumberOfMessageBytesConsumedSensor =
         LibrdKafkaConsumerMetrics.TotalNumberOfMessageBytesConsumedSensor(threadId, clientId, streamAppId,
                                                                           metricsRegistry);
     NumberOfOpsWaitinInQueueSensor =
         LibrdKafkaConsumerMetrics.NumberOfOpsWaitinInQueueSensor(threadId, clientId, streamAppId,
                                                                  metricsRegistry);
     TotalNumberOfResponsesReceivedFromKafkaSensor =
         LibrdKafkaConsumerMetrics.TotalNumberOfResponsesReceivedFromKafkaSensor(threadId, clientId, streamAppId,
                                                                                 metricsRegistry);
     TotalNumberOfBytesReceivedFromKafkaSensor =
         LibrdKafkaConsumerMetrics.TotalNumberOfBytesReceivedFromKafkaSensor(threadId, clientId, streamAppId,
                                                                             metricsRegistry);
     RebalanceAgeSensor =
         LibrdKafkaConsumerMetrics.RebalanceAgeSensor(threadId, clientId, streamAppId, metricsRegistry);
     TotalNumberOfRelabalanceSensor =
         LibrdKafkaConsumerMetrics.TotalNumberOfRelabalanceSensor(threadId, clientId, streamAppId,
                                                                  metricsRegistry);
     TotalNumberOfResponsesReceivedSensor =
         LibrdKafkaConsumerMetrics.TotalNumberOfResponsesReceivedSensor(threadId, clientId, streamAppId,
                                                                        metricsRegistry);
     TotalNumberOfBytesReceivedSensor =
         LibrdKafkaConsumerMetrics.TotalNumberOfBytesReceivedSensor(threadId, clientId, streamAppId,
                                                                    metricsRegistry);
     TotalNumberOfReceivedErrorsSensor =
         LibrdKafkaConsumerMetrics.TotalNumberOfReceivedErrorsSensor(threadId, clientId, streamAppId,
                                                                     metricsRegistry);
     NumberOfConnectionAttempsSensor =
         LibrdKafkaConsumerMetrics.NumberOfConnectionAttempsSensor(threadId, clientId, streamAppId,
                                                                   metricsRegistry);
     NumberOfDisconnectsSensor =
         LibrdKafkaConsumerMetrics.NumberOfDisconnectsSensor(threadId, clientId, streamAppId, metricsRegistry);
     BrokerLatencyAverageMsSensor =
         LibrdKafkaConsumerMetrics.BrokerLatencyAverageMsSensor(threadId, clientId, streamAppId,
                                                                metricsRegistry);
     BatchSizeAverageBytesSensor =
         LibrdKafkaConsumerMetrics.BatchSizeAverageBytesSensor(threadId, clientId, streamAppId, metricsRegistry);
     BatchMessageCountsAverageSensor =
         LibrdKafkaConsumerMetrics.BatchMessageCountsAverageSensor(threadId, clientId, streamAppId,
                                                                   metricsRegistry);
     ConsumerLagSensor =
         LibrdKafkaConsumerMetrics.ConsumerLagSensor(threadId, clientId, streamAppId, metricsRegistry);
     TotalNumberOfMessagesConsumedByPartitionSensor =
         LibrdKafkaConsumerMetrics.TotalNumberOfMessagesConsumedByPartitionSensor(threadId, clientId,
                                                                                  streamAppId, metricsRegistry);
     TotalNumberOfBytesConsumedByPartitionSensor =
         LibrdKafkaConsumerMetrics.TotalNumberOfBytesConsumedByPartitionSensor(threadId, clientId, streamAppId,
                                                                               metricsRegistry);
 }
            internal ScopedLibrdKafkaSensor(LibrdKafkaSensor sensor, ScopedLibrdKafka scoped)
                : base(sensor.Name, sensor.Description, sensor.MetricsRecording)
            {
                this.scoped = scoped;

                foreach (var m in sensor.originMeasurableStats)
                {
                    var cloneMeasurableStat = (IMeasurableStat)Activator.CreateInstance(m.Value.GetType());
                    var tags = new Dictionary <string, string>(m.Key.Tags);
                    scoped.Scope.Split(ScopedLibrdKafka.separator)
                    .ForEach((i) =>
                    {
                        var items = i.Split(ScopedLibrdKafka.internalSeparator);
                        if (items.Length == 2)
                        {
                            tags.AddOrUpdate(items[0], items[1]);
                        }
                    });

                    var newKeyMetricName = new MetricName(
                        $"{m.Key.Name}-{scoped.Scope}",
                        m.Key.Group,
                        m.Key.Description,
                        tags
                        );

                    var newMetricName = new MetricName(
                        m.Key.Name,
                        m.Key.Group,
                        m.Key.Description,
                        tags
                        );

                    AddStatMetric(newKeyMetricName, newMetricName, cloneMeasurableStat);
                }
            }
        public override void Register(StreamMetricsRegistry metricsRegistry)
        {
            TotalNumberOfMessagesProducedSensor =
                LibrdKafkaProducerMetrics.TotalNumberOfMessagesProducedSensor(threadId, clientId, streamAppId,
                                                                              metricsRegistry);
            TotalNumberOfMessageBytesProducedSensor =
                LibrdKafkaProducerMetrics.TotalNumberOfMessageBytesProducedSensor(threadId, clientId, streamAppId,
                                                                                  metricsRegistry);
            NumberOfOpsWaitinInQueueSensor =
                LibrdKafkaProducerMetrics.NumberOfOpsWaitinInQueueSensor(threadId, clientId, streamAppId,
                                                                         metricsRegistry);
            CurrentNumberOfMessagesInProducerQueuesSensor =
                LibrdKafkaProducerMetrics.CurrentNumberOfMessagesInProducerQueuesSensor(threadId, clientId,
                                                                                        streamAppId, metricsRegistry);
            CurrentSizeOfMessagesInProducerQueuesSensor =
                LibrdKafkaProducerMetrics.CurrentSizeOfMessagesInProducerQueuesSensor(threadId, clientId, streamAppId,
                                                                                      metricsRegistry);
            MaxMessagesAllowedOnProducerQueuesSensor =
                LibrdKafkaProducerMetrics.MaxMessagesAllowedOnProducerQueuesSensor(threadId, clientId, streamAppId,
                                                                                   metricsRegistry);
            MaxSizeOfMessagesAllowedOnProducerQueuesSensor =
                LibrdKafkaProducerMetrics.MaxSizeOfMessagesAllowedOnProducerQueuesSensor(threadId, clientId,
                                                                                         streamAppId, metricsRegistry);
            TotalNumberOfRequestSentToKafkaSensor =
                LibrdKafkaProducerMetrics.TotalNumberOfRequestSentToKafkaSensor(threadId, clientId, streamAppId,
                                                                                metricsRegistry);
            TotalNumberOfBytesTransmittedToKafkaSensor =
                LibrdKafkaProducerMetrics.TotalNumberOfBytesTransmittedToKafkaSensor(threadId, clientId, streamAppId,
                                                                                     metricsRegistry);

            //PER BROKER (add Broker NodeId as label)
            NumberOfRequestAwaitingTransmissionSensor =
                LibrdKafkaProducerMetrics.NumberOfRequestAwaitingTransmissionSensor(threadId, clientId, streamAppId,
                                                                                    metricsRegistry);
            NumberOfMessagesAwaitingTransmissionSensor =
                LibrdKafkaProducerMetrics.NumberOfMessagesAwaitingTransmissionSensor(threadId, clientId, streamAppId,
                                                                                     metricsRegistry);
            NumberOfRequestInFlightSensor =
                LibrdKafkaProducerMetrics.NumberOfRequestInFlightSensor(threadId, clientId, streamAppId,
                                                                        metricsRegistry);
            NumberOfMessagesInFlightSensor =
                LibrdKafkaProducerMetrics.NumberOfMessagesInFlightSensor(threadId, clientId, streamAppId,
                                                                         metricsRegistry);
            TotalNumberOfRequestSentSensor =
                LibrdKafkaProducerMetrics.TotalNumberOfRequestSentSensor(threadId, clientId, streamAppId,
                                                                         metricsRegistry);
            TotalNumberOfBytesSentSensor =
                LibrdKafkaProducerMetrics.TotalNumberOfBytesSentSensor(threadId, clientId, streamAppId,
                                                                       metricsRegistry);
            TotalNumberOfTransmissionErrorsSensor =
                LibrdKafkaProducerMetrics.TotalNumberOfTransmissionErrorsSensor(threadId, clientId, streamAppId,
                                                                                metricsRegistry);
            TotalNumberOfRequestRetriesSensor =
                LibrdKafkaProducerMetrics.TotalNumberOfRequestRetriesSensor(threadId, clientId, streamAppId,
                                                                            metricsRegistry);
            TotalNumberOfRequestTimeoutSensor =
                LibrdKafkaProducerMetrics.TotalNumberOfRequestTimeoutSensor(threadId, clientId, streamAppId,
                                                                            metricsRegistry);
            NumberOfConnectionAttempsSensor =
                LibrdKafkaProducerMetrics.NumberOfConnectionAttempsSensor(threadId, clientId, streamAppId,
                                                                          metricsRegistry); // Including successful, failed and name resolution failures
            NumberOfDisconnectsSensor =
                LibrdKafkaProducerMetrics.NumberOfDisconnectsSensor(threadId, clientId, streamAppId, metricsRegistry);
            InternalQueueProducerLatencyAverageMsSensor =
                LibrdKafkaProducerMetrics.InternalQueueProducerLatencyAverageMsSensor(threadId, clientId, streamAppId,
                                                                                      metricsRegistry);
            InternalRequestQueueLatencyAverageMsSensor =
                LibrdKafkaProducerMetrics.InternalRequestQueueLatencyAverageMsSensor(threadId, clientId, streamAppId,
                                                                                     metricsRegistry);
            BrokerLatencyAverageMsSensor =
                LibrdKafkaProducerMetrics.BrokerLatencyAverageMsSensor(threadId, clientId, streamAppId,
                                                                       metricsRegistry);

            // Per Topic(add topic name as label)
            BatchSizeAverageBytesSensor =
                LibrdKafkaProducerMetrics.BatchSizeAverageBytesSensor(threadId, clientId, streamAppId,
                                                                      metricsRegistry);
            BatchMessageCountsAverageSensor =
                LibrdKafkaProducerMetrics.BatchMessageCountsAverageSensor(threadId, clientId, streamAppId,
                                                                          metricsRegistry);

            //  Per Partition(topic brokder id PartitionId as label)
            PartitionTotalNumberOfMessagesProducedSensor =
                LibrdKafkaProducerMetrics.PartitionTotalNumberOfMessagesProducedSensor(threadId, clientId,
                                                                                       streamAppId, metricsRegistry);
            PartitionTotalNumberOfBytesProducedSensor =
                LibrdKafkaProducerMetrics.PartitionTotalNumberOfBytesProducedSensor(threadId, clientId, streamAppId,
                                                                                    metricsRegistry);
            PartitionNumberOfMessagesInFlightSensor =
                LibrdKafkaProducerMetrics.PartitionNumberOfMessagesInFlightSensor(threadId, clientId, streamAppId,
                                                                                  metricsRegistry);
            PartitionNextExpectedAckSequenceSensor =
                LibrdKafkaProducerMetrics.PartitionNextExpectedAckSequenceSensor(threadId, clientId, streamAppId,
                                                                                 metricsRegistry);
            PartitionLastInternalMessageIdAckedSensor =
                LibrdKafkaProducerMetrics.PartitionLastInternalMessageIdAckedSensor(threadId, clientId, streamAppId,
                                                                                    metricsRegistry);

            ApplyTaskIdTagIfNeed();
        }