Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MetricsCollector ¶
type MetricsCollector struct {
// contains filtered or unexported fields
}
MetricsCollector implements the |channelmetrics.MetricsCollector| interface using Prometheus. It records various metrics related to channel operations.
func NewMetricsCollector ¶
func NewMetricsCollector(chanName, namespace, subsystem string) *MetricsCollector
NewMetricsCollector creates a new MetricsCollector with histograms for produce and consume durations, and gauges for channel length and capacity. It accepts namespace, subsystem, and chanName parameters to organize metrics. The function initializes and returns a pointer to a MetricsCollector struct that contains the following Prometheus metrics:
produceDuration: a Histogram metric that measures the duration of producing an item. It tracks the time taken to add an item to the ObservableChan. This metric helps to monitor the performance and latency of item production.
consumeDuration: a Histogram metric that measures the duration of consuming an item. It tracks the time taken to retrieve an item from the ObservableChan. This metric helps to monitor the performance and latency of item consumption.
channelLen: a Gauge metric that measures the current size of the channel buffer. It tracks the number of items in the channel buffer at any given time. This metric helps to monitor the utilization of the channel buffer.
channelCap: a Gauge metric that measures the capacity of the channel buffer. It tracks the maximum number of items that the channel buffer can hold. This metric helps to understand the configuration and potential limits of the channel buffer.
These metrics are useful for monitoring the performance and throughput of the ObservableChan. By tracking the durations of item production and consumption, as well as the buffer size and capacity, you can identify bottlenecks, optimize performance, and ensure that the ObservableChan is operating efficiently.
func (*MetricsCollector) RecordChannelCap ¶
func (c *MetricsCollector) RecordChannelCap(capacity int)
RecordChannelCap records the capacity of the channel buffer.
func (*MetricsCollector) RecordChannelLen ¶
func (c *MetricsCollector) RecordChannelLen(size int)
RecordChannelLen records the current size of the channel buffer.
func (*MetricsCollector) RecordConsumeDuration ¶
func (c *MetricsCollector) RecordConsumeDuration(duration time.Duration)
RecordConsumeDuration records the duration taken to consume an item from the channel.
func (*MetricsCollector) RecordProduceDuration ¶
func (c *MetricsCollector) RecordProduceDuration(duration time.Duration)
RecordProduceDuration records the duration taken to produce an item into the channel.