Commit 6c5860d3 by bergquist

feat(metrics): measure proxy requests

parent eb673fd1
......@@ -13,9 +13,15 @@ var (
M_Page_Status_200 Counter
M_Page_Status_500 Counter
M_Page_Status_404 Counter
M_Api_Status_500 Counter
M_Api_Status_404 Counter
M_Page_Status_Unknown Counter
M_Api_Status_200 Counter
M_Api_Status_404 Counter
M_Api_Status_500 Counter
M_Api_Status_Unknown Counter
M_Proxy_Status_200 Counter
M_Proxy_Status_404 Counter
M_Proxy_Status_500 Counter
M_Proxy_Status_Unknown Counter
M_Api_User_SignUpStarted Counter
M_Api_User_SignUpCompleted Counter
M_Api_User_SignUpInvite Counter
......@@ -55,10 +61,17 @@ func initMetricVars(settings *MetricSettings) {
M_Page_Status_200 = RegCounter("page.resp_status", "code", "200")
M_Page_Status_500 = RegCounter("page.resp_status", "code", "500")
M_Page_Status_404 = RegCounter("page.resp_status", "code", "404")
M_Page_Status_Unknown = RegCounter("page.resp_status", "code", "unknown")
M_Api_Status_500 = RegCounter("api.resp_status", "code", "500")
M_Api_Status_404 = RegCounter("api.resp_status", "code", "404")
M_Api_Status_200 = RegCounter("api.resp_status", "code", "200")
M_Api_Status_404 = RegCounter("api.resp_status", "code", "404")
M_Api_Status_500 = RegCounter("api.resp_status", "code", "500")
M_Api_Status_Unknown = RegCounter("api.resp_status", "code", "unknown")
M_Proxy_Status_200 = RegCounter("proxy.resp_status", "code", "200")
M_Proxy_Status_404 = RegCounter("proxy.resp_status", "code", "404")
M_Proxy_Status_500 = RegCounter("proxy.resp_status", "code", "500")
M_Proxy_Status_Unknown = RegCounter("proxy.resp_status", "code", "unknown")
M_Api_User_SignUpStarted = RegCounter("api.user.signup_started")
M_Api_User_SignUpCompleted = RegCounter("api.user.signup_completed")
......
......@@ -16,27 +16,50 @@ func RequestMetrics() macaron.Handler {
status := rw.Status()
if strings.HasPrefix(req.RequestURI, "/api/datasources/proxy") {
return
}
if strings.HasPrefix(req.RequestURI, "/api/") {
switch status {
case 200:
metrics.M_Api_Status_200.Inc(1)
case 404:
metrics.M_Api_Status_404.Inc(1)
case 500:
metrics.M_Api_Status_500.Inc(1)
}
countProxyRequests(status)
} else if strings.HasPrefix(req.RequestURI, "/api/") {
countApiRequests(status)
} else {
switch status {
case 200:
metrics.M_Page_Status_200.Inc(1)
case 404:
metrics.M_Page_Status_404.Inc(1)
case 500:
metrics.M_Page_Status_500.Inc(1)
}
countPageRequests(status)
}
}
}
func countApiRequests(status int) {
switch status {
case 200:
metrics.M_Api_Status_200.Inc(1)
case 404:
metrics.M_Api_Status_404.Inc(1)
case 500:
metrics.M_Api_Status_500.Inc(1)
default:
metrics.M_Api_Status_Unknown.Inc(1)
}
}
func countPageRequests(status int) {
switch status {
case 200:
metrics.M_Page_Status_200.Inc(1)
case 404:
metrics.M_Page_Status_404.Inc(1)
case 500:
metrics.M_Page_Status_500.Inc(1)
default:
metrics.M_Page_Status_Unknown.Inc(1)
}
}
func countProxyRequests(status int) {
switch status {
case 200:
metrics.M_Proxy_Status_200.Inc(1)
case 404:
metrics.M_Proxy_Status_404.Inc(1)
case 500:
metrics.M_Proxy_Status_500.Inc(1)
default:
metrics.M_Proxy_Status_Unknown.Inc(1)
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment