Skip to content

Commit

Permalink
metrics: adjust metrics and its comments (pingcap#16429)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackysp authored Apr 15, 2020
1 parent 62c1c8d commit 2c8afe6
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 50 deletions.
2 changes: 1 addition & 1 deletion distsql/select_result.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (r *selectResult) fetchResp(ctx context.Context) error {
// final round of fetch
// TODO: Add a label to distinguish between success or failure.
// https://github.com/pingcap/tidb/issues/11397
metrics.DistSQLQueryHistgram.WithLabelValues(r.label, r.sqlType).Observe(r.fetchDuration.Seconds())
metrics.DistSQLQueryHistogram.WithLabelValues(r.label, r.sqlType).Observe(r.fetchDuration.Seconds())
r.durationReported = true
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion distsql/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (r *streamResult) readDataFromResponse(ctx context.Context, resp kv.Respons
resultSubset, err := resp.Next(ctx)
// TODO: Add a label to distinguish between success or failure.
// https://github.com/pingcap/tidb/issues/11397
metrics.DistSQLQueryHistgram.WithLabelValues(r.label, r.sqlType).Observe(time.Since(startTime).Seconds())
metrics.DistSQLQueryHistogram.WithLabelValues(r.label, r.sqlType).Observe(time.Since(startTime).Seconds())
if err != nil {
return false, err
}
Expand Down
12 changes: 6 additions & 6 deletions metrics/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var (
Subsystem: "ddl",
Name: "handle_job_duration_seconds",
Help: "Bucketed histogram of processing time (s) of handle jobs",
Buckets: prometheus.ExponentialBuckets(0.01, 2, 22), // 10ms ~ 12hours
Buckets: prometheus.ExponentialBuckets(0.01, 2, 22), // 10ms ~ 6hours
}, []string{LblType, LblResult})

BatchAddIdxHistogram = prometheus.NewHistogramVec(
Expand All @@ -40,7 +40,7 @@ var (
Subsystem: "ddl",
Name: "batch_add_idx_duration_seconds",
Help: "Bucketed histogram of processing time (s) of batch handle data",
Buckets: prometheus.ExponentialBuckets(0.001, 2, 22), // 1ms ~ 1hours
Buckets: prometheus.ExponentialBuckets(0.001, 2, 22), // 1ms ~ 0.5hours
}, []string{LblType})

SyncerInit = "init"
Expand All @@ -53,7 +53,7 @@ var (
Subsystem: "ddl",
Name: "deploy_syncer_duration_seconds",
Help: "Bucketed histogram of processing time (s) of deploy syncer",
Buckets: prometheus.ExponentialBuckets(0.001, 2, 20), // 1ms ~ 1024s
Buckets: prometheus.ExponentialBuckets(0.001, 2, 20), // 1ms ~ 524s
}, []string{LblType, LblResult})

UpdateSelfVersionHistogram = prometheus.NewHistogramVec(
Expand All @@ -62,7 +62,7 @@ var (
Subsystem: "ddl",
Name: "update_self_ver_duration_seconds",
Help: "Bucketed histogram of processing time (s) of update self version",
Buckets: prometheus.ExponentialBuckets(0.001, 2, 20), // 1ms ~ 1024s
Buckets: prometheus.ExponentialBuckets(0.001, 2, 20), // 1ms ~ 524s
}, []string{LblResult})

OwnerUpdateGlobalVersion = "update_global_version"
Expand All @@ -77,7 +77,7 @@ var (
Subsystem: "ddl",
Name: "owner_handle_syncer_duration_seconds",
Help: "Bucketed histogram of processing time (s) of handle syncer",
Buckets: prometheus.ExponentialBuckets(0.001, 2, 20), // 1ms ~ 1024s
Buckets: prometheus.ExponentialBuckets(0.001, 2, 20), // 1ms ~ 524s
}, []string{LblType, LblResult})

// Metrics for ddl_worker.go.
Expand All @@ -91,7 +91,7 @@ var (
Subsystem: "ddl",
Name: "worker_operation_duration_seconds",
Help: "Bucketed histogram of processing time (s) of ddl worker operations",
Buckets: prometheus.ExponentialBuckets(0.001, 2, 22), // 1ms ~ 4096s
Buckets: prometheus.ExponentialBuckets(0.001, 2, 22), // 1ms ~ 2048s
}, []string{LblType, LblAction, LblResult})

CreateDDLInstance = "create_ddl_instance"
Expand Down
4 changes: 2 additions & 2 deletions metrics/distsql.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ import (

// distsql metrics.
var (
DistSQLQueryHistgram = prometheus.NewHistogramVec(
DistSQLQueryHistogram = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Namespace: "tidb",
Subsystem: "distsql",
Name: "handle_query_duration_seconds",
Help: "Bucketed histogram of processing time (s) of handled queries.",
Buckets: prometheus.ExponentialBuckets(0.0005, 2, 18), // 0.5ms ~ 128s
Buckets: prometheus.ExponentialBuckets(0.0005, 2, 18), // 0.5ms ~ 64s
}, []string{LblType, LblSQLType})

DistSQLScanKeysPartialHistogram = prometheus.NewHistogram(
Expand Down
2 changes: 1 addition & 1 deletion metrics/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var (
Subsystem: "domain",
Name: "load_schema_duration_seconds",
Help: "Bucketed histogram of processing time (s) in load schema.",
Buckets: prometheus.ExponentialBuckets(0.001, 2, 20), // 1ms ~ 4000s
Buckets: prometheus.ExponentialBuckets(0.001, 2, 20), // 1ms ~ 524s
})

// LoadPrivilegeCounter records the counter of load privilege.
Expand Down
2 changes: 1 addition & 1 deletion metrics/gc_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var (
Subsystem: "tikvclient",
Name: "gc_seconds",
Help: "Bucketed histogram of gc duration.",
Buckets: prometheus.ExponentialBuckets(1, 2, 20), // 1s ~ 12days
Buckets: prometheus.ExponentialBuckets(1, 2, 20), // 1s ~ 6days
}, []string{"stage"})

GCConfigGauge = prometheus.NewGaugeVec(
Expand Down
4 changes: 2 additions & 2 deletions metrics/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var (
Subsystem: "autoid",
Name: "operation_duration_seconds",
Help: "Bucketed histogram of processing time (s) of handled autoid.",
Buckets: prometheus.ExponentialBuckets(0.0005, 2, 22), // 500us ~ 2097s
Buckets: prometheus.ExponentialBuckets(0.0005, 2, 22), // 0.5ms ~ 1048s
}, []string{LblType, LblResult})

GetSchemaDiff = "get_schema_diff"
Expand All @@ -43,6 +43,6 @@ var (
Subsystem: "meta",
Name: "operation_duration_seconds",
Help: "Bucketed histogram of processing time (s) of tidb meta data operations.",
Buckets: prometheus.ExponentialBuckets(0.0005, 2, 22), // 500us ~ 2097s
Buckets: prometheus.ExponentialBuckets(0.0005, 2, 22), // 0.5ms ~ 1048s
}, []string{LblType, LblResult})
)
2 changes: 1 addition & 1 deletion metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func RegisterMetrics() {
prometheus.MustRegister(DDLWorkerHistogram)
prometheus.MustRegister(DeploySyncerHistogram)
prometheus.MustRegister(DistSQLPartialCountHistogram)
prometheus.MustRegister(DistSQLQueryHistgram)
prometheus.MustRegister(DistSQLQueryHistogram)
prometheus.MustRegister(DistSQLScanKeysHistogram)
prometheus.MustRegister(DistSQLScanKeysPartialHistogram)
prometheus.MustRegister(DumpFeedbackCounter)
Expand Down
2 changes: 1 addition & 1 deletion metrics/oracles.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ var (
Subsystem: "pdclient",
Name: "ts_future_wait_seconds",
Help: "Bucketed histogram of seconds cost for waiting timestamp future.",
Buckets: prometheus.ExponentialBuckets(0.000005, 2, 20), // 5us ~ 5s
Buckets: prometheus.ExponentialBuckets(0.000005, 2, 24), // 5us ~ 40s
})
)
2 changes: 1 addition & 1 deletion metrics/owner.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var (
Subsystem: "owner",
Name: "new_session_duration_seconds",
Help: "Bucketed histogram of processing time (s) of new session.",
Buckets: prometheus.ExponentialBuckets(0.0005, 2, 22), // 500us ~ 2097s
Buckets: prometheus.ExponentialBuckets(0.0005, 2, 22), // 0.5ms ~ 1048s
}, []string{LblType, LblResult})

WatcherClosed = "watcher_closed"
Expand Down
10 changes: 5 additions & 5 deletions metrics/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var (
Subsystem: "server",
Name: "handle_query_duration_seconds",
Help: "Bucketed histogram of processing time (s) of handled queries.",
Buckets: prometheus.ExponentialBuckets(0.0005, 2, 22), // 500us ~ 2097s
Buckets: prometheus.ExponentialBuckets(0.0005, 2, 22), // 0.5ms ~ 1048s
}, []string{LblSQLType})

QueryTotalCounter = prometheus.NewCounterVec(
Expand Down Expand Up @@ -128,7 +128,7 @@ var (
Subsystem: "server",
Name: "get_token_duration_seconds",
Help: "Duration (us) for getting token, it should be small until concurrency limit is reached.",
Buckets: prometheus.ExponentialBuckets(1, 2, 26), // 1us ~ 67s
Buckets: prometheus.ExponentialBuckets(1, 2, 26), // 1us ~ 33s
})

TotalQueryProcHistogram = prometheus.NewHistogram(
Expand All @@ -137,23 +137,23 @@ var (
Subsystem: "server",
Name: "slow_query_process_duration_seconds",
Help: "Bucketed histogram of processing time (s) of of slow queries.",
Buckets: prometheus.ExponentialBuckets(0.001, 2, 22), // 1ms ~ 4096s
Buckets: prometheus.ExponentialBuckets(0.001, 2, 22), // 1ms ~ 2048s
})
TotalCopProcHistogram = prometheus.NewHistogram(
prometheus.HistogramOpts{
Namespace: "tidb",
Subsystem: "server",
Name: "slow_query_cop_duration_seconds",
Help: "Bucketed histogram of all cop processing time (s) of of slow queries.",
Buckets: prometheus.ExponentialBuckets(0.001, 2, 22), // 1ms ~ 4096s
Buckets: prometheus.ExponentialBuckets(0.001, 2, 22), // 1ms ~ 2048s
})
TotalCopWaitHistogram = prometheus.NewHistogram(
prometheus.HistogramOpts{
Namespace: "tidb",
Subsystem: "server",
Name: "slow_query_wait_duration_seconds",
Help: "Bucketed histogram of all cop waiting time (s) of of slow queries.",
Buckets: prometheus.ExponentialBuckets(0.001, 2, 22), // 1ms ~ 4096s
Buckets: prometheus.ExponentialBuckets(0.001, 2, 22), // 1ms ~ 2048s
})
)

Expand Down
18 changes: 9 additions & 9 deletions metrics/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var (
Subsystem: "session",
Name: "parse_duration_seconds",
Help: "Bucketed histogram of processing time (s) in parse SQL.",
Buckets: prometheus.ExponentialBuckets(0.00004, 2, 22), // 40us ~ 168s
Buckets: prometheus.ExponentialBuckets(0.00004, 2, 22), // 40us ~ 84s
}, []string{LblSQLType})
SessionExecuteCompileDuration = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Expand All @@ -32,15 +32,15 @@ var (
Name: "compile_duration_seconds",
Help: "Bucketed histogram of processing time (s) in query optimize.",
// Build plan may execute the statement, or allocate table ID, so it might take a long time.
Buckets: prometheus.ExponentialBuckets(0.00004, 2, 22), // 40us ~ 168s
Buckets: prometheus.ExponentialBuckets(0.00004, 2, 22), // 40us ~ 84s
}, []string{LblSQLType})
SessionExecuteRunDuration = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Namespace: "tidb",
Subsystem: "session",
Name: "execute_duration_seconds",
Help: "Bucketed histogram of processing time (s) in running executor.",
Buckets: prometheus.ExponentialBuckets(0.0001, 2, 22), // 100us ~ 419s
Buckets: prometheus.ExponentialBuckets(0.0001, 2, 22), // 100us ~ 209s
}, []string{LblSQLType})
SchemaLeaseErrorCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Expand All @@ -55,7 +55,7 @@ var (
Subsystem: "session",
Name: "retry_num",
Help: "Bucketed histogram of session retry count.",
Buckets: prometheus.LinearBuckets(0, 1, 20), // 0 ~ 20
Buckets: prometheus.LinearBuckets(0, 1, 21), // 0 ~ 20
})
SessionRetryErrorCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Expand All @@ -79,7 +79,7 @@ var (
Subsystem: "session",
Name: "transaction_statement_num",
Help: "Bucketed histogram of statements count in each transaction.",
Buckets: prometheus.ExponentialBuckets(1, 2, 16), // 1 ~ 65536
Buckets: prometheus.ExponentialBuckets(1, 2, 16), // 1 ~ 32768
}, []string{LblSQLType, LblType})

TransactionDuration = prometheus.NewHistogramVec(
Expand All @@ -88,7 +88,7 @@ var (
Subsystem: "session",
Name: "transaction_duration_seconds",
Help: "Bucketed histogram of a transaction execution duration, including retry.",
Buckets: prometheus.ExponentialBuckets(0.001, 2, 20), // 1ms ~ 1049s
Buckets: prometheus.ExponentialBuckets(0.001, 2, 20), // 1ms ~ 524s
}, []string{LblSQLType, LblType})

StatementDeadlockDetectDuration = prometheus.NewHistogram(
Expand All @@ -97,7 +97,7 @@ var (
Subsystem: "session",
Name: "statement_deadlock_detect_duration_seconds",
Help: "Bucketed histogram of a statement deadlock detect duration.",
Buckets: prometheus.ExponentialBuckets(0.001, 2, 20), // 1ms ~ 1049s
Buckets: prometheus.ExponentialBuckets(0.001, 2, 20), // 1ms ~ 524s
},
)

Expand All @@ -107,7 +107,7 @@ var (
Subsystem: "session",
Name: "statement_pessimistic_retry_count",
Help: "Bucketed histogram of statement pessimistic retry count",
Buckets: prometheus.ExponentialBuckets(1, 2, 16), // 1 ~ 65536
Buckets: prometheus.ExponentialBuckets(1, 2, 16), // 1 ~ 32768
})

StatementLockKeysCount = prometheus.NewHistogram(
Expand All @@ -116,7 +116,7 @@ var (
Subsystem: "session",
Name: "statement_lock_keys_count",
Help: "Keys locking for a single statement",
Buckets: prometheus.ExponentialBuckets(1, 2, 21), // 1 ~ 2097152
Buckets: prometheus.ExponentialBuckets(1, 2, 21), // 1 ~ 1048576
})
)

Expand Down
2 changes: 1 addition & 1 deletion metrics/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var (
Subsystem: "statistics",
Name: "auto_analyze_duration_seconds",
Help: "Bucketed histogram of processing time (s) of auto analyze.",
Buckets: prometheus.ExponentialBuckets(0.01, 2, 20), // 10ms ~ 3hours
Buckets: prometheus.ExponentialBuckets(0.01, 2, 20), // 10ms ~ 1.5hours
})

AutoAnalyzeCounter = prometheus.NewCounterVec(
Expand Down
Loading

0 comments on commit 2c8afe6

Please sign in to comment.