diff --git a/agent/agent.go b/agent/agent.go index 6970c754..c68e6689 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -696,7 +696,10 @@ func (a *agentImpl) reportChannelSize() { } for _, mr := range a.metricsReporters { if err := mr.ReportGauge(metrics.ChannelCapacity, map[string]string{"channel": "agent_chsend"}, float64(chSendCapacity)); err != nil { - logger.Log.Warnf("failed to report chSend channel capaacity: %s", err.Error()) + logger.Log.Warnf("failed to report gauge chSend channel capacity: %s", err.Error()) + } + if err := mr.ReportHistogram(metrics.ChannelCapacityHistogram, map[string]string{"channel": "agent_chsend"}, float64(chSendCapacity)); err != nil { + logger.Log.Warnf("failed to report histogram chSend channel capacity: %s", err.Error()) } } } diff --git a/metrics/constants.go b/metrics/constants.go index 2bd3c71f..37cdbceb 100644 --- a/metrics/constants.go +++ b/metrics/constants.go @@ -8,7 +8,10 @@ var ( // CountServers counts the number of servers of different types CountServers = "count_servers" // ChannelCapacity represents the capacity of a channel (available slots) + // Deprecated: This variable will be removed in future versions. Use ChannelCapacityHistogram instead. ChannelCapacity = "channel_capacity" + // ChannelCapacityHistogram represents the capacity of a channel as a histogram (distribution of available slots) + ChannelCapacityHistogram = "channel_capacity_histogram" // DroppedMessages reports the number of dropped messages in rpc server (messages that will not be handled) DroppedMessages = "dropped_messages" // ProcessDelay reports the message processing delay to handle the messages at the handler service diff --git a/metrics/prometheus_reporter.go b/metrics/prometheus_reporter.go index 1fe26a7c..f68c15e9 100644 --- a/metrics/prometheus_reporter.go +++ b/metrics/prometheus_reporter.go @@ -199,6 +199,17 @@ func (p *PrometheusReporter) registerMetrics( append([]string{"channel"}, additionalLabelsKeys...), ) + p.histogramReportersMap[ChannelCapacityHistogram] = prometheus.NewHistogramVec( + prometheus.HistogramOpts{ + Namespace: "pitaya", + Subsystem: "channel", + Name: ChannelCapacityHistogram, + Help: "the available capacity of the channel", + Buckets: []float64{0, 1, 10, 50, 100, 250, 500, 750, 1000, 1500, 2000, 3000, 4000, 5000}, + ConstLabels: constLabels, + }, + append([]string{"channel"}, additionalLabelsKeys...), + p.gaugeReportersMap[DroppedMessages] = prometheus.NewGaugeVec( prometheus.GaugeOpts{ Namespace: "pitaya",