mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
metrics standardize
This commit is contained in:
@@ -44,8 +44,6 @@ func handleRunner(c *gin.Context) {
|
|||||||
c.Set("reqID", reqID) // todo: put this in the ctx instead of gin's
|
c.Set("reqID", reqID) // todo: put this in the ctx instead of gin's
|
||||||
|
|
||||||
log = log.WithFields(logrus.Fields{"request_id": reqID})
|
log = log.WithFields(logrus.Fields{"request_id": reqID})
|
||||||
// Request count metric
|
|
||||||
log.WithFields(logrus.Fields{"metric": "function-request", "type": "count", "value": 1}).Info()
|
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
@@ -107,6 +105,14 @@ func handleRunner(c *gin.Context) {
|
|||||||
|
|
||||||
log.WithField("routes", routes).Debug("Got routes from datastore")
|
log.WithField("routes", routes).Debug("Got routes from datastore")
|
||||||
for _, el := range routes {
|
for _, el := range routes {
|
||||||
|
metricBaseName := "server.handleRunner." + appName + "."
|
||||||
|
log = log.WithFields(logrus.Fields{
|
||||||
|
"app": appName, "route": el.Path, "image": el.Image, "request_id": reqID})
|
||||||
|
|
||||||
|
// Request count metric
|
||||||
|
log.WithFields(logrus.Fields{
|
||||||
|
"metric": (metricBaseName + "requests"), "type": "count", "value": 1}).Info()
|
||||||
|
|
||||||
if params, match := matchRoute(el.Path, route); match {
|
if params, match := matchRoute(el.Path, route); match {
|
||||||
|
|
||||||
var stdout bytes.Buffer // TODO: should limit the size of this, error if gets too big. akin to: https://golang.org/pkg/io/#LimitReader
|
var stdout bytes.Buffer // TODO: should limit the size of this, error if gets too big. akin to: https://golang.org/pkg/io/#LimitReader
|
||||||
@@ -160,12 +166,14 @@ func handleRunner(c *gin.Context) {
|
|||||||
|
|
||||||
if result.Status() == "success" {
|
if result.Status() == "success" {
|
||||||
c.Data(http.StatusOK, "", stdout.Bytes())
|
c.Data(http.StatusOK, "", stdout.Bytes())
|
||||||
|
log.WithFields(logrus.Fields{
|
||||||
|
"metric": (metricBaseName + "succeeded"), "type": "count", "value": 1}).Info()
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// log.WithFields(logrus.Fields{"app": appName, "route": el, "req_id": reqID}).Debug(stderr.String())
|
// log.WithFields(logrus.Fields{"app": appName, "route": el, "req_id": reqID}).Debug(stderr.String())
|
||||||
// Error count metric
|
// Error count metric
|
||||||
log.WithFields(logrus.Fields{
|
log.WithFields(logrus.Fields{
|
||||||
"app": appName, "route": el.Path, "image": el.Image, "req_id": reqID,
|
"metric": (metricBaseName + "error"), "type": "count", "value": 1}).Info()
|
||||||
"metric": "function-error", "type": "count", "value": 1}).Info()
|
|
||||||
|
|
||||||
c.AbortWithStatus(http.StatusInternalServerError)
|
c.AbortWithStatus(http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
@@ -173,8 +181,7 @@ func handleRunner(c *gin.Context) {
|
|||||||
// Execution time metric
|
// Execution time metric
|
||||||
metricElapsed := time.Since(metricStart)
|
metricElapsed := time.Since(metricStart)
|
||||||
log.WithFields(logrus.Fields{
|
log.WithFields(logrus.Fields{
|
||||||
"app": appName, "route": el.Path, "image": el.Image, "req_id": reqID,
|
"metric": (metricBaseName + "time"), "type": "time", "value": metricElapsed}).Info()
|
||||||
"metric": "function-runner", "type": "time", "value": metricElapsed}).Info()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user