Extract separate files/packages for better visibility.

This commit is contained in:
Alex Ellis
2017-01-21 15:50:19 +00:00
parent 8da30eecaa
commit b9bd7c8101
7 changed files with 209 additions and 188 deletions

View File

@ -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)
}