Skip to content

Commit

Permalink
server: Add metrics for tidb-server panic (pingcap#5692)
Browse files Browse the repository at this point in the history
  • Loading branch information
shenli authored and zimulala committed Jan 22, 2018
1 parent a2a48b3 commit c30309a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions server/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ func (cc *clientConn) Run() {
stackSize := runtime.Stack(buf, false)
buf = buf[:stackSize]
log.Errorf("lastCmd %s, %v, %s", cc.lastCmd, r, buf)
panicCounter.Add(1)
}
if !closedOutside {
err := cc.Close()
Expand Down
10 changes: 10 additions & 0 deletions server/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,23 @@ var (
Name: "critical_error",
Help: "Counter of critical errors.",
})

// panicCounter measures the count of panics.
panicCounter = prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: "tidb",
Subsystem: "server",
Name: "panic",
Help: "Counter of panic.",
})
)

func init() {
prometheus.MustRegister(queryHistogram)
prometheus.MustRegister(queryCounter)
prometheus.MustRegister(connGauge)
prometheus.MustRegister(criticalErrorCounter)
prometheus.MustRegister(panicCounter)
}

func executeErrorToLabel(err error) string {
Expand Down

0 comments on commit c30309a

Please sign in to comment.