mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Add calls metric (#637)
* Add new Prometheus metric fn_api_calls * Change fn_api_calls to a counter
This commit is contained in:
committed by
Reed Allman
parent
77d8f32ec4
commit
c0dec594ef
@@ -1,8 +1,9 @@
|
|||||||
package agent
|
package agent
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO this should expose:
|
// TODO this should expose:
|
||||||
@@ -48,24 +49,31 @@ type FunctionStats struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
fnCalls = prometheus.NewCounterVec(
|
||||||
|
prometheus.CounterOpts{
|
||||||
|
Name: "fn_api_calls",
|
||||||
|
Help: "Function calls by app and path",
|
||||||
|
},
|
||||||
|
[](string){"app", "path"},
|
||||||
|
)
|
||||||
fnQueued = prometheus.NewGaugeVec(
|
fnQueued = prometheus.NewGaugeVec(
|
||||||
prometheus.GaugeOpts{
|
prometheus.GaugeOpts{
|
||||||
Name: "fn_api_queued",
|
Name: "fn_api_queued",
|
||||||
Help: "Queued requests by path",
|
Help: "Queued requests by app and path",
|
||||||
},
|
},
|
||||||
[](string){"app", "path"},
|
[](string){"app", "path"},
|
||||||
)
|
)
|
||||||
fnRunning = prometheus.NewGaugeVec(
|
fnRunning = prometheus.NewGaugeVec(
|
||||||
prometheus.GaugeOpts{
|
prometheus.GaugeOpts{
|
||||||
Name: "fn_api_running",
|
Name: "fn_api_running",
|
||||||
Help: "Running requests by path",
|
Help: "Running requests by app and path",
|
||||||
},
|
},
|
||||||
[](string){"app", "path"},
|
[](string){"app", "path"},
|
||||||
)
|
)
|
||||||
fnCompleted = prometheus.NewCounterVec(
|
fnCompleted = prometheus.NewCounterVec(
|
||||||
prometheus.CounterOpts{
|
prometheus.CounterOpts{
|
||||||
Name: "fn_api_completed",
|
Name: "fn_api_completed",
|
||||||
Help: "Completed requests by path",
|
Help: "Completed requests by app and path",
|
||||||
},
|
},
|
||||||
[](string){"app", "path"},
|
[](string){"app", "path"},
|
||||||
)
|
)
|
||||||
@@ -79,6 +87,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
prometheus.MustRegister(fnCalls)
|
||||||
prometheus.MustRegister(fnQueued)
|
prometheus.MustRegister(fnQueued)
|
||||||
prometheus.MustRegister(fnRunning)
|
prometheus.MustRegister(fnRunning)
|
||||||
prometheus.MustRegister(fnFailed)
|
prometheus.MustRegister(fnFailed)
|
||||||
@@ -104,6 +113,7 @@ func (s *stats) Enqueue(app string, path string) {
|
|||||||
s.queue++
|
s.queue++
|
||||||
s.getStatsForFunction(path).queue++
|
s.getStatsForFunction(path).queue++
|
||||||
fnQueued.WithLabelValues(app, path).Inc()
|
fnQueued.WithLabelValues(app, path).Inc()
|
||||||
|
fnCalls.WithLabelValues(app, path).Inc()
|
||||||
|
|
||||||
s.mu.Unlock()
|
s.mu.Unlock()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user