mirror of
https://github.com/openfaas/faas.git
synced 2025-06-21 14:23:25 +00:00
Renamed ServiceReplicasCounter to ServiceReplicasGauge
To avoid future confusion, this fix renames ServiceReplicasCounter to ServiceReplicasGauge. Signed-off-by: Ken Fukuyama <kenfdev@gmail.com>
This commit is contained in:
@ -35,7 +35,7 @@ func NewExporter(options MetricOptions) *Exporter {
|
||||
func (e *Exporter) Describe(ch chan<- *prometheus.Desc) {
|
||||
e.metricOptions.GatewayFunctionInvocation.Describe(ch)
|
||||
e.metricOptions.GatewayFunctionsHistogram.Describe(ch)
|
||||
e.metricOptions.ServiceReplicasCounter.Describe(ch)
|
||||
e.metricOptions.ServiceReplicasGauge.Describe(ch)
|
||||
}
|
||||
|
||||
// Collect collects data to be consumed by prometheus
|
||||
@ -43,13 +43,13 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
|
||||
e.metricOptions.GatewayFunctionInvocation.Collect(ch)
|
||||
e.metricOptions.GatewayFunctionsHistogram.Collect(ch)
|
||||
|
||||
e.metricOptions.ServiceReplicasCounter.Reset()
|
||||
e.metricOptions.ServiceReplicasGauge.Reset()
|
||||
for _, service := range e.services {
|
||||
e.metricOptions.ServiceReplicasCounter.
|
||||
e.metricOptions.ServiceReplicasGauge.
|
||||
WithLabelValues(service.Name).
|
||||
Set(float64(service.Replicas))
|
||||
}
|
||||
e.metricOptions.ServiceReplicasCounter.Collect(ch)
|
||||
e.metricOptions.ServiceReplicasGauge.Collect(ch)
|
||||
}
|
||||
|
||||
// StartServiceWatcher starts a ticker and collects service replica counts to expose to prometheus
|
||||
|
@ -53,10 +53,10 @@ func Test_Describe_DescribesThePrometheusMetrics(t *testing.T) {
|
||||
t.Errorf("Want %s, got: %s", expectedGatewayFunctionsHistogramDesc, actualGatewayFunctionsHistogramDesc)
|
||||
}
|
||||
d = (<-ch)
|
||||
expectedServiceReplicasCounterDesc := `Desc{fqName: "gateway_service_count", help: "Docker service replicas", constLabels: {}, variableLabels: [function_name]}`
|
||||
actualServiceReplicasCounterDesc := d.String()
|
||||
if expectedServiceReplicasCounterDesc != actualServiceReplicasCounterDesc {
|
||||
t.Errorf("Want %s, got: %s", expectedServiceReplicasCounterDesc, actualServiceReplicasCounterDesc)
|
||||
expectedServiceReplicasGaugeDesc := `Desc{fqName: "gateway_service_count", help: "Docker service replicas", constLabels: {}, variableLabels: [function_name]}`
|
||||
actualServiceReplicasGaugeDesc := d.String()
|
||||
if expectedServiceReplicasGaugeDesc != actualServiceReplicasGaugeDesc {
|
||||
t.Errorf("Want %s, got: %s", expectedServiceReplicasGaugeDesc, actualServiceReplicasGaugeDesc)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ import (
|
||||
type MetricOptions struct {
|
||||
GatewayFunctionInvocation *prometheus.CounterVec
|
||||
GatewayFunctionsHistogram *prometheus.HistogramVec
|
||||
ServiceReplicasCounter *prometheus.GaugeVec
|
||||
ServiceReplicasGauge *prometheus.GaugeVec
|
||||
}
|
||||
|
||||
// PrometheusHandler Bootstraps prometheus for metrics collection
|
||||
@ -47,7 +47,7 @@ func BuildMetricsOptions() MetricOptions {
|
||||
metricsOptions := MetricOptions{
|
||||
GatewayFunctionsHistogram: gatewayFunctionsHistogram,
|
||||
GatewayFunctionInvocation: gatewayFunctionInvocation,
|
||||
ServiceReplicasCounter: serviceReplicas,
|
||||
ServiceReplicasGauge: serviceReplicas,
|
||||
}
|
||||
|
||||
return metricsOptions
|
||||
|
Reference in New Issue
Block a user