Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

metric: replace QueryDurationHistogram's "general" type to detail type (#8819) #8875

Merged
merged 3 commits into from
Dec 29, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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