Skip to content

Commit

Permalink
metrics: distinguish events of server level and connection level (#48290
Browse files Browse the repository at this point in the history
)

close #48289
  • Loading branch information
jackysp authored Nov 6, 2023
1 parent 18979c6 commit b93b2f5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkg/metrics/grafana/tidb.json
Original file line number Diff line number Diff line change
Expand Up @@ -2915,7 +2915,7 @@
"expr": "increase(tidb_server_event_total{k8s_cluster=\"$k8s_cluster\", tidb_cluster=\"$tidb_cluster\", instance=~\"$instance\"}[10m])",
"format": "time_series",
"intervalFactor": 2,
"legendFormat": "{{instance}}-server {{type}}",
"legendFormat": "{{instance}}-{{type}}",
"refId": "A"
}
],
Expand Down
8 changes: 4 additions & 4 deletions pkg/metrics/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ var (
ExecuteErrorCounter *prometheus.CounterVec
CriticalErrorCounter prometheus.Counter

EventStart = "start"
EventGracefulDown = "graceful_shutdown"
ServerStart = "server-start"
ServerStop = "server-stop"

// Eventkill occurs when the server.Kill() function is called.
EventKill = "kill"
EventClose = "close"
EventKill = "kill"

ServerEventCounter *prometheus.CounterVec
TimeJumpBackCounter prometheus.Counter
Expand Down
4 changes: 2 additions & 2 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ func (s *Server) reportConfig() {

// Run runs the server.
func (s *Server) Run() error {
metrics.ServerEventCounter.WithLabelValues(metrics.EventStart).Inc()
metrics.ServerEventCounter.WithLabelValues(metrics.ServerStart).Inc()
s.reportConfig()

// Start HTTP API to report tidb info such as TPS.
Expand Down Expand Up @@ -579,7 +579,7 @@ func (s *Server) closeListener() {
s.authTokenCancelFunc()
}
s.wg.Wait()
metrics.ServerEventCounter.WithLabelValues(metrics.EventClose).Inc()
metrics.ServerEventCounter.WithLabelValues(metrics.ServerStop).Inc()
}

// Close closes the server.
Expand Down

0 comments on commit b93b2f5

Please sign in to comment.