metrics.go 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package metrics
  2. var MetricStats = NewRegistry()
  3. var UseNilMetrics bool = true
  4. var (
  5. M_Instance_Start Counter
  6. M_Page_Status_200 Counter
  7. M_Page_Status_500 Counter
  8. M_Page_Status_404 Counter
  9. M_Api_Status_500 Counter
  10. M_Api_Status_404 Counter
  11. M_Api_User_SignUpStarted Counter
  12. M_Api_User_SignUpCompleted Counter
  13. M_Api_User_SignUpInvite Counter
  14. M_Api_Dashboard_Save Timer
  15. M_Api_Dashboard_Get Timer
  16. M_Api_Dashboard_Search Timer
  17. M_Api_Admin_User_Create Counter
  18. M_Api_Login_Post Counter
  19. M_Api_Login_OAuth Counter
  20. M_Api_Org_Create Counter
  21. M_Api_Dashboard_Snapshot_Create Counter
  22. M_Api_Dashboard_Snapshot_External Counter
  23. M_Api_Dashboard_Snapshot_Get Counter
  24. M_Models_Dashboard_Insert Counter
  25. // Timers
  26. M_DataSource_ProxyReq_Timer Timer
  27. )
  28. func initMetricVars(settings *MetricSettings) {
  29. UseNilMetrics = settings.Enabled == false
  30. M_Instance_Start = RegCounter("instance_start")
  31. M_Page_Status_200 = RegCounter("page.resp_status", "code", "200")
  32. M_Page_Status_500 = RegCounter("page.resp_status", "code", "500")
  33. M_Page_Status_404 = RegCounter("page.resp_status", "code", "404")
  34. M_Api_Status_500 = RegCounter("api.resp_status", "code", "500")
  35. M_Api_Status_404 = RegCounter("api.resp_status", "code", "404")
  36. M_Api_User_SignUpStarted = RegCounter("api.user.signup_started")
  37. M_Api_User_SignUpCompleted = RegCounter("api.user.signup_completed")
  38. M_Api_User_SignUpInvite = RegCounter("api.user.signup_invite")
  39. M_Api_Dashboard_Save = RegTimer("api.dashboard.save")
  40. M_Api_Dashboard_Get = RegTimer("api.dashboard.get")
  41. M_Api_Dashboard_Search = RegTimer("api.dashboard.search")
  42. M_Api_Admin_User_Create = RegCounter("api.admin.user_create")
  43. M_Api_Login_Post = RegCounter("api.login.post")
  44. M_Api_Login_OAuth = RegCounter("api.login.oauth")
  45. M_Api_Org_Create = RegCounter("api.org.create")
  46. M_Api_Dashboard_Snapshot_Create = RegCounter("api.dashboard_snapshot.create")
  47. M_Api_Dashboard_Snapshot_External = RegCounter("api.dashboard_snapshot.external")
  48. M_Api_Dashboard_Snapshot_Get = RegCounter("api.dashboard_snapshot.get")
  49. M_Models_Dashboard_Insert = RegCounter("models.dashboard.insert")
  50. // Timers
  51. M_DataSource_ProxyReq_Timer = RegTimer("api.dataproxy.request.all")
  52. }