mirror of
https://github.com/openfaas/faas.git
synced 2025-06-20 21:46:33 +00:00
Extract separate files/packages for better visibility.
This commit is contained in:
@ -18,3 +18,41 @@ type MetricOptions struct {
|
||||
func PrometheusHandler() http.Handler {
|
||||
return prometheus.Handler()
|
||||
}
|
||||
|
||||
func BuildMetricsOptions() MetricOptions {
|
||||
GatewayRequestsTotal := prometheus.NewCounter(prometheus.CounterOpts{
|
||||
Name: "gateway_requests_total",
|
||||
Help: "Total amount of HTTP requests to the gateway",
|
||||
})
|
||||
GatewayServerlessServedTotal := prometheus.NewCounter(prometheus.CounterOpts{
|
||||
Name: "gateway_serverless_invocation_total",
|
||||
Help: "Total amount of serverless function invocations",
|
||||
})
|
||||
GatewayFunctions := prometheus.NewHistogram(prometheus.HistogramOpts{
|
||||
Name: "gateway_functions",
|
||||
Help: "Gateway functions",
|
||||
})
|
||||
GatewayFunctionInvocation := prometheus.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Name: "gateway_function_invocation_total",
|
||||
Help: "Individual function metrics",
|
||||
},
|
||||
[]string{"function_name"},
|
||||
)
|
||||
|
||||
metricsOptions := MetricOptions{
|
||||
GatewayRequestsTotal: GatewayRequestsTotal,
|
||||
GatewayServerlessServedTotal: GatewayServerlessServedTotal,
|
||||
GatewayFunctions: GatewayFunctions,
|
||||
GatewayFunctionInvocation: GatewayFunctionInvocation,
|
||||
}
|
||||
|
||||
return metricsOptions
|
||||
}
|
||||
|
||||
func RegisterMetrics(metricsOptions MetricOptions) {
|
||||
prometheus.Register(metricsOptions.GatewayRequestsTotal)
|
||||
prometheus.Register(metricsOptions.GatewayServerlessServedTotal)
|
||||
prometheus.Register(metricsOptions.GatewayFunctions)
|
||||
prometheus.Register(metricsOptions.GatewayFunctionInvocation)
|
||||
}
|
||||
|
Reference in New Issue
Block a user