+ global_metrics.remove_if_exists("input_received_frames", labels);
+ global_metrics.remove_if_exists("input_dropped_frames_jitter", labels);
+ global_metrics.remove_if_exists("input_dropped_frames_error", labels);
+ global_metrics.remove_if_exists("input_dropped_frames_resets", labels);
+ global_metrics.remove_if_exists("input_queue_length_frames", labels);
+ global_metrics.remove_if_exists("input_queue_duped_frames", labels);
+
+ global_metrics.remove_if_exists("input_has_signal_bool", labels);
+ global_metrics.remove_if_exists("input_is_connected_bool", labels);
+ global_metrics.remove_if_exists("input_interlaced_bool", labels);
+ global_metrics.remove_if_exists("input_width_pixels", labels);
+ global_metrics.remove_if_exists("input_height_pixels", labels);
+ global_metrics.remove_if_exists("input_frame_rate_nom", labels);
+ global_metrics.remove_if_exists("input_frame_rate_den", labels);
+ global_metrics.remove_if_exists("input_sample_rate_hz", labels);
+
+ // SRT metrics.
+
+ // Global measurements (counters).
+ global_metrics.remove_if_exists("srt_uptime_seconds", labels);
+ global_metrics.remove_if_exists("srt_send_duration_seconds", labels);
+ global_metrics.remove_if_exists("srt_sent_bytes", labels);
+ global_metrics.remove_if_exists("srt_received_bytes", labels);
+
+ vector<pair<string, string>> packet_labels = card->labels;
+ packet_labels.emplace_back("type", "normal");
+ global_metrics.remove_if_exists("srt_sent_packets", packet_labels);
+ global_metrics.remove_if_exists("srt_received_packets", packet_labels);
+
+ packet_labels.back().second = "lost";
+ global_metrics.remove_if_exists("srt_sent_packets", packet_labels);
+ global_metrics.remove_if_exists("srt_received_packets", packet_labels);
+
+ packet_labels.back().second = "retransmitted";
+ global_metrics.remove_if_exists("srt_sent_packets", packet_labels);
+ global_metrics.remove_if_exists("srt_sent_bytes", packet_labels);
+
+ packet_labels.back().second = "ack";
+ global_metrics.remove_if_exists("srt_sent_packets", packet_labels);
+ global_metrics.remove_if_exists("srt_received_packets", packet_labels);
+
+ packet_labels.back().second = "nak";
+ global_metrics.remove_if_exists("srt_sent_packets", packet_labels);
+ global_metrics.remove_if_exists("srt_received_packets", packet_labels);
+
+ packet_labels.back().second = "dropped";
+ global_metrics.remove_if_exists("srt_sent_packets", packet_labels);
+ global_metrics.remove_if_exists("srt_received_packets", packet_labels);
+ global_metrics.remove_if_exists("srt_sent_bytes", packet_labels);
+ global_metrics.remove_if_exists("srt_received_bytes", packet_labels);
+
+ packet_labels.back().second = "undecryptable";
+ global_metrics.remove_if_exists("srt_received_packets", packet_labels);
+ global_metrics.remove_if_exists("srt_received_bytes", packet_labels);
+
+ global_metrics.remove_if_exists("srt_filter_sent_extra_packets", labels);
+ global_metrics.remove_if_exists("srt_filter_received_extra_packets", labels);
+ global_metrics.remove_if_exists("srt_filter_received_rebuilt_packets", labels);
+ global_metrics.remove_if_exists("srt_filter_received_lost_packets", labels);
+
+ // Instant measurements (gauges).
+ global_metrics.remove_if_exists("srt_packet_sending_period_seconds", labels);
+ global_metrics.remove_if_exists("srt_flow_window_packets", labels);
+ global_metrics.remove_if_exists("srt_congestion_window_packets", labels);
+ global_metrics.remove_if_exists("srt_flight_size_packets", labels);
+ global_metrics.remove_if_exists("srt_rtt_seconds", labels);
+ global_metrics.remove_if_exists("srt_estimated_bandwidth_bits_per_second", labels);
+ global_metrics.remove_if_exists("srt_bandwidth_ceiling_bits_per_second", labels);
+ global_metrics.remove_if_exists("srt_send_buffer_available_bytes", labels);
+ global_metrics.remove_if_exists("srt_receive_buffer_available_bytes", labels);
+ global_metrics.remove_if_exists("srt_mss_bytes", labels);
+
+ global_metrics.remove_if_exists("srt_sender_unacked_packets", labels);
+ global_metrics.remove_if_exists("srt_sender_unacked_bytes", labels);
+ global_metrics.remove_if_exists("srt_sender_unacked_timespan_seconds", labels);
+ global_metrics.remove_if_exists("srt_sender_delivery_delay_seconds", labels);
+
+ global_metrics.remove_if_exists("srt_receiver_unacked_packets", labels);
+ global_metrics.remove_if_exists("srt_receiver_unacked_bytes", labels);
+ global_metrics.remove_if_exists("srt_receiver_unacked_timespan_seconds", labels);
+ global_metrics.remove_if_exists("srt_receiver_delivery_delay_seconds", labels);
+ }
+
+ if (is_active) {
+ // Register metrics.
+ vector<pair<string, string>> labels;
+ char card_name[64];
+ snprintf(card_name, sizeof(card_name), "%d", card_index);
+ labels.emplace_back("card", card_name);
+
+ switch (card_type) {
+ case CardType::LIVE_CARD:
+ labels.emplace_back("cardtype", "live");
+ break;
+ case CardType::FAKE_CAPTURE:
+ labels.emplace_back("cardtype", "fake");
+ break;
+ case CardType::FFMPEG_INPUT:
+ if (is_srt_card) {
+ labels.emplace_back("cardtype", "srt");
+ } else {
+ labels.emplace_back("cardtype", "ffmpeg");
+ }
+ break;
+ case CardType::CEF_INPUT:
+ labels.emplace_back("cardtype", "cef");
+ break;
+ default:
+ assert(false);
+ }
+ card->jitter_history.register_metrics(labels);
+ card->queue_length_policy.register_metrics(labels);
+ global_metrics.add("input_received_frames", labels, &card->metric_input_received_frames);
+ global_metrics.add("input_dropped_frames_jitter", labels, &card->metric_input_dropped_frames_jitter);
+ global_metrics.add("input_dropped_frames_error", labels, &card->metric_input_dropped_frames_error);
+ global_metrics.add("input_dropped_frames_resets", labels, &card->metric_input_resets);
+ global_metrics.add("input_queue_length_frames", labels, &card->metric_input_queue_length_frames, Metrics::TYPE_GAUGE);
+ global_metrics.add("input_queue_duped_frames", labels, &card->metric_input_duped_frames);
+
+ global_metrics.add("input_has_signal_bool", labels, &card->metric_input_has_signal_bool, Metrics::TYPE_GAUGE);
+ global_metrics.add("input_is_connected_bool", labels, &card->metric_input_is_connected_bool, Metrics::TYPE_GAUGE);
+ global_metrics.add("input_interlaced_bool", labels, &card->metric_input_interlaced_bool, Metrics::TYPE_GAUGE);
+ global_metrics.add("input_width_pixels", labels, &card->metric_input_width_pixels, Metrics::TYPE_GAUGE);
+ global_metrics.add("input_height_pixels", labels, &card->metric_input_height_pixels, Metrics::TYPE_GAUGE);
+ global_metrics.add("input_frame_rate_nom", labels, &card->metric_input_frame_rate_nom, Metrics::TYPE_GAUGE);
+ global_metrics.add("input_frame_rate_den", labels, &card->metric_input_frame_rate_den, Metrics::TYPE_GAUGE);
+ global_metrics.add("input_sample_rate_hz", labels, &card->metric_input_sample_rate_hz, Metrics::TYPE_GAUGE);
+
+ if (is_srt_card) {
+ // Global measurements (counters).
+ global_metrics.add("srt_uptime_seconds", labels, &card->metric_srt_uptime_seconds);
+ global_metrics.add("srt_send_duration_seconds", labels, &card->metric_srt_send_duration_seconds);
+ global_metrics.add("srt_sent_bytes", labels, &card->metric_srt_sent_bytes);
+ global_metrics.add("srt_received_bytes", labels, &card->metric_srt_received_bytes);
+
+ vector<pair<string, string>> packet_labels = labels;
+ packet_labels.emplace_back("type", "normal");
+ global_metrics.add("srt_sent_packets", packet_labels, &card->metric_srt_sent_packets_normal);
+ global_metrics.add("srt_received_packets", packet_labels, &card->metric_srt_received_packets_normal);
+
+ packet_labels.back().second = "lost";
+ global_metrics.add("srt_sent_packets", packet_labels, &card->metric_srt_sent_packets_lost);
+ global_metrics.add("srt_received_packets", packet_labels, &card->metric_srt_received_packets_lost);
+
+ packet_labels.back().second = "retransmitted";
+ global_metrics.add("srt_sent_packets", packet_labels, &card->metric_srt_sent_packets_retransmitted);
+ global_metrics.add("srt_sent_bytes", packet_labels, &card->metric_srt_sent_bytes_retransmitted);
+
+ packet_labels.back().second = "ack";
+ global_metrics.add("srt_sent_packets", packet_labels, &card->metric_srt_sent_packets_ack);
+ global_metrics.add("srt_received_packets", packet_labels, &card->metric_srt_received_packets_ack);
+
+ packet_labels.back().second = "nak";
+ global_metrics.add("srt_sent_packets", packet_labels, &card->metric_srt_sent_packets_nak);
+ global_metrics.add("srt_received_packets", packet_labels, &card->metric_srt_received_packets_nak);
+
+ packet_labels.back().second = "dropped";
+ global_metrics.add("srt_sent_packets", packet_labels, &card->metric_srt_sent_packets_dropped);
+ global_metrics.add("srt_received_packets", packet_labels, &card->metric_srt_received_packets_dropped);
+ global_metrics.add("srt_sent_bytes", packet_labels, &card->metric_srt_sent_bytes_dropped);
+ global_metrics.add("srt_received_bytes", packet_labels, &card->metric_srt_received_bytes_dropped);
+
+ packet_labels.back().second = "undecryptable";
+ global_metrics.add("srt_received_packets", packet_labels, &card->metric_srt_received_packets_undecryptable);
+ global_metrics.add("srt_received_bytes", packet_labels, &card->metric_srt_received_bytes_undecryptable);
+
+ global_metrics.add("srt_filter_sent_extra_packets", labels, &card->metric_srt_filter_sent_packets);
+ global_metrics.add("srt_filter_received_extra_packets", labels, &card->metric_srt_filter_received_extra_packets);
+ global_metrics.add("srt_filter_received_rebuilt_packets", labels, &card->metric_srt_filter_received_rebuilt_packets);
+ global_metrics.add("srt_filter_received_lost_packets", labels, &card->metric_srt_filter_received_lost_packets);
+
+ // Instant measurements (gauges).
+ global_metrics.add("srt_packet_sending_period_seconds", labels, &card->metric_srt_packet_sending_period_seconds, Metrics::TYPE_GAUGE);
+ global_metrics.add("srt_flow_window_packets", labels, &card->metric_srt_flow_window_packets, Metrics::TYPE_GAUGE);
+ global_metrics.add("srt_congestion_window_packets", labels, &card->metric_srt_congestion_window_packets, Metrics::TYPE_GAUGE);
+ global_metrics.add("srt_flight_size_packets", labels, &card->metric_srt_flight_size_packets, Metrics::TYPE_GAUGE);
+ global_metrics.add("srt_rtt_seconds", labels, &card->metric_srt_rtt_seconds, Metrics::TYPE_GAUGE);
+ global_metrics.add("srt_estimated_bandwidth_bits_per_second", labels, &card->metric_srt_estimated_bandwidth_bits_per_second, Metrics::TYPE_GAUGE);
+ global_metrics.add("srt_bandwidth_ceiling_bits_per_second", labels, &card->metric_srt_bandwidth_ceiling_bits_per_second, Metrics::TYPE_GAUGE);
+ global_metrics.add("srt_send_buffer_available_bytes", labels, &card->metric_srt_send_buffer_available_bytes, Metrics::TYPE_GAUGE);
+ global_metrics.add("srt_receive_buffer_available_bytes", labels, &card->metric_srt_receive_buffer_available_bytes, Metrics::TYPE_GAUGE);
+ global_metrics.add("srt_mss_bytes", labels, &card->metric_srt_mss_bytes, Metrics::TYPE_GAUGE);
+
+ global_metrics.add("srt_sender_unacked_packets", labels, &card->metric_srt_sender_unacked_packets, Metrics::TYPE_GAUGE);
+ global_metrics.add("srt_sender_unacked_bytes", labels, &card->metric_srt_sender_unacked_bytes, Metrics::TYPE_GAUGE);
+ global_metrics.add("srt_sender_unacked_timespan_seconds", labels, &card->metric_srt_sender_unacked_timespan_seconds, Metrics::TYPE_GAUGE);
+ global_metrics.add("srt_sender_delivery_delay_seconds", labels, &card->metric_srt_sender_delivery_delay_seconds, Metrics::TYPE_GAUGE);
+
+ global_metrics.add("srt_receiver_unacked_packets", labels, &card->metric_srt_receiver_unacked_packets, Metrics::TYPE_GAUGE);
+ global_metrics.add("srt_receiver_unacked_bytes", labels, &card->metric_srt_receiver_unacked_bytes, Metrics::TYPE_GAUGE);
+ global_metrics.add("srt_receiver_unacked_timespan_seconds", labels, &card->metric_srt_receiver_unacked_timespan_seconds, Metrics::TYPE_GAUGE);
+ global_metrics.add("srt_receiver_delivery_delay_seconds", labels, &card->metric_srt_receiver_delivery_delay_seconds, Metrics::TYPE_GAUGE);
+ }
+
+ card->labels = labels;
+ } else {
+ card->labels.clear();