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) {
|
func (e *Exporter) Describe(ch chan<- *prometheus.Desc) {
|
||||||
e.metricOptions.GatewayFunctionInvocation.Describe(ch)
|
e.metricOptions.GatewayFunctionInvocation.Describe(ch)
|
||||||
e.metricOptions.GatewayFunctionsHistogram.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
|
// 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.GatewayFunctionInvocation.Collect(ch)
|
||||||
e.metricOptions.GatewayFunctionsHistogram.Collect(ch)
|
e.metricOptions.GatewayFunctionsHistogram.Collect(ch)
|
||||||
|
|
||||||
e.metricOptions.ServiceReplicasCounter.Reset()
|
e.metricOptions.ServiceReplicasGauge.Reset()
|
||||||
for _, service := range e.services {
|
for _, service := range e.services {
|
||||||
e.metricOptions.ServiceReplicasCounter.
|
e.metricOptions.ServiceReplicasGauge.
|
||||||
WithLabelValues(service.Name).
|
WithLabelValues(service.Name).
|
||||||
Set(float64(service.Replicas))
|
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
|
// 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)
|
t.Errorf("Want %s, got: %s", expectedGatewayFunctionsHistogramDesc, actualGatewayFunctionsHistogramDesc)
|
||||||
}
|
}
|
||||||
d = (<-ch)
|
d = (<-ch)
|
||||||
expectedServiceReplicasCounterDesc := `Desc{fqName: "gateway_service_count", help: "Docker service replicas", constLabels: {}, variableLabels: [function_name]}`
|
expectedServiceReplicasGaugeDesc := `Desc{fqName: "gateway_service_count", help: "Docker service replicas", constLabels: {}, variableLabels: [function_name]}`
|
||||||
actualServiceReplicasCounterDesc := d.String()
|
actualServiceReplicasGaugeDesc := d.String()
|
||||||
if expectedServiceReplicasCounterDesc != actualServiceReplicasCounterDesc {
|
if expectedServiceReplicasGaugeDesc != actualServiceReplicasGaugeDesc {
|
||||||
t.Errorf("Want %s, got: %s", expectedServiceReplicasCounterDesc, actualServiceReplicasCounterDesc)
|
t.Errorf("Want %s, got: %s", expectedServiceReplicasGaugeDesc, actualServiceReplicasGaugeDesc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
type MetricOptions struct {
|
type MetricOptions struct {
|
||||||
GatewayFunctionInvocation *prometheus.CounterVec
|
GatewayFunctionInvocation *prometheus.CounterVec
|
||||||
GatewayFunctionsHistogram *prometheus.HistogramVec
|
GatewayFunctionsHistogram *prometheus.HistogramVec
|
||||||
ServiceReplicasCounter *prometheus.GaugeVec
|
ServiceReplicasGauge *prometheus.GaugeVec
|
||||||
}
|
}
|
||||||
|
|
||||||
// PrometheusHandler Bootstraps prometheus for metrics collection
|
// PrometheusHandler Bootstraps prometheus for metrics collection
|
||||||
@ -47,7 +47,7 @@ func BuildMetricsOptions() MetricOptions {
|
|||||||
metricsOptions := MetricOptions{
|
metricsOptions := MetricOptions{
|
||||||
GatewayFunctionsHistogram: gatewayFunctionsHistogram,
|
GatewayFunctionsHistogram: gatewayFunctionsHistogram,
|
||||||
GatewayFunctionInvocation: gatewayFunctionInvocation,
|
GatewayFunctionInvocation: gatewayFunctionInvocation,
|
||||||
ServiceReplicasCounter: serviceReplicas,
|
ServiceReplicasGauge: serviceReplicas,
|
||||||
}
|
}
|
||||||
|
|
||||||
return metricsOptions
|
return metricsOptions
|
||||||
|
Reference in New Issue
Block a user