Skip to content

Commit

Permalink
metric: replace QueryDurationHistogram's "general" type to detail type (
Browse files Browse the repository at this point in the history
  • Loading branch information
lysu authored and zz-jason committed Dec 29, 2018
1 parent 8ee7459 commit 199fac4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions executor/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import (
"golang.org/x/net/context"
)

// processinfoSetter is the interface use to set current running process info.
type processinfoSetter interface {
SetProcessInfo(string)
}
Expand Down Expand Up @@ -230,6 +231,7 @@ func (a *ExecStmt) Exec(ctx context.Context) (sqlexec.RecordSet, error) {
}
// Update processinfo, ShowProcess() will use it.
pi.SetProcessInfo(sql)
a.Ctx.GetSessionVars().StmtCtx.StmtType = GetStmtLabel(a.StmtNode)
}
// If the executor doesn't return any result to the client, we execute it without delay.
if e.Schema().Len() == 0 {
Expand Down
7 changes: 6 additions & 1 deletion server/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,12 @@ func (cc *clientConn) addMetrics(cmd byte, startTime time.Time, err error) {
} else {
metrics.QueryTotalCounter.WithLabelValues(label, "OK").Inc()
}
metrics.QueryDurationHistogram.WithLabelValues(metrics.LblGeneral).Observe(time.Since(startTime).Seconds())
stmtType := cc.ctx.GetSessionVars().StmtCtx.StmtType
sqlType := metrics.LblGeneral
if stmtType != "" {
sqlType = stmtType
}
metrics.QueryDurationHistogram.WithLabelValues(sqlType).Observe(time.Since(startTime).Seconds())
}

// dispatch handles client request based on command which is the first byte of the data.
Expand Down
1 change: 1 addition & 0 deletions sessionctx/stmtctx/stmtctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ type StatementContext struct {
RuntimeStatsColl *execdetails.RuntimeStatsColl
TableIDs []int64
IndexIDs []int64
StmtType string
}

// AddAffectedRows adds affected rows.
Expand Down

0 comments on commit 199fac4

Please sign in to comment.