Skip to content

Commit

Permalink
store/tikv: add conn pool metrics. (pingcap#3312)
Browse files Browse the repository at this point in the history
  • Loading branch information
disksing authored and zimulala committed May 23, 2017
1 parent 31579bb commit 9c6cd3e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions store/tikv/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func (c *rpcClient) SendCopReq(ctx goctx.Context, addr string, req *coprocessor.
if err != nil {
return nil, errors.Trace(err)
}
connPoolHistogram.WithLabelValues("cop").Observe(time.Since(start).Seconds())
defer c.p.PutConn(conn)
msg := msgpb.Message{
MsgType: msgpb.MessageType_CopReq,
Expand Down Expand Up @@ -108,6 +109,7 @@ func (c *rpcClient) SendKVReq(ctx goctx.Context, addr string, req *kvrpcpb.Reque
if err != nil {
return nil, errors.Trace(err)
}
connPoolHistogram.WithLabelValues("kv").Observe(time.Since(start).Seconds())
defer c.p.PutConn(conn)
msg := msgpb.Message{
MsgType: msgpb.MessageType_KvReq,
Expand Down
10 changes: 10 additions & 0 deletions store/tikv/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ var (
Buckets: prometheus.ExponentialBuckets(0.0005, 2, 18),
})

connPoolHistogram = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Namespace: "tidb",
Subsystem: "tikvclient",
Name: "get_conn_seconds",
Help: "Bucketed histogram of taking conn from conn pool.",
Buckets: prometheus.ExponentialBuckets(0.0005, 2, 18),
}, []string{"type"})

sendReqHistogram = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Namespace: "tidb",
Expand Down Expand Up @@ -211,6 +220,7 @@ func init() {
prometheus.MustRegister(backoffCounter)
prometheus.MustRegister(backoffHistogram)
prometheus.MustRegister(sendReqHistogram)
prometheus.MustRegister(connPoolHistogram)
prometheus.MustRegister(coprocessorCounter)
prometheus.MustRegister(coprocessorHistogram)
prometheus.MustRegister(gcWorkerCounter)
Expand Down

0 comments on commit 9c6cd3e

Please sign in to comment.