Skip to content

Commit

Permalink
metrics: unify metrics naming (#5863)
Browse files Browse the repository at this point in the history
  • Loading branch information
coocood committed Feb 11, 2018
1 parent 7059ca0 commit 0157fe5
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 72 deletions.
18 changes: 9 additions & 9 deletions metrics/ddl.go
Expand Up @@ -23,7 +23,7 @@ var (
Subsystem: "ddl",
Name: "waiting_jobs",
Help: "Gauge of jobs.",
}, []string{"action"})
}, []string{LblType})

HandleJobHistogram = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Expand All @@ -32,13 +32,13 @@ var (
Name: "handle_job_duration_seconds",
Help: "Bucketed histogram of processing time (s) of handle jobs",
Buckets: prometheus.ExponentialBuckets(0.01, 2, 20),
}, []string{"action", "result_state"})
}, []string{LblType, LblResult})

BatchAddIdxHistogram = prometheus.NewHistogram(
prometheus.HistogramOpts{
Namespace: "tidb",
Subsystem: "ddl",
Name: "batch_add_idx_succ",
Name: "batch_add_idx_duration_seconds",
Help: "Bucketed histogram of processing time (s) of batch handle data",
Buckets: prometheus.ExponentialBuckets(0.001, 2, 20),
})
Expand All @@ -54,7 +54,7 @@ var (
Name: "deploy_syncer_duration_seconds",
Help: "Bucketed histogram of processing time (s) of deploy syncer",
Buckets: prometheus.ExponentialBuckets(0.01, 2, 20),
}, []string{"state", "result_state"})
}, []string{LblType, LblResult})

UpdateSelfVersionHistogram = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Expand All @@ -63,7 +63,7 @@ var (
Name: "update_self_ver_duration_seconds",
Help: "Bucketed histogram of processing time (s) of update self version",
Buckets: prometheus.ExponentialBuckets(0.01, 2, 20),
}, []string{"result_state"})
}, []string{LblResult})

OwnerUpdateGlobalVersion = "update_global_version"
OwnerGetGlobalVersion = "get_global_version"
Expand All @@ -75,7 +75,7 @@ var (
Name: "owner_handle_syncer_duration_seconds",
Help: "Bucketed histogram of processing time (s) of handle syncer",
Buckets: prometheus.ExponentialBuckets(0.01, 2, 20),
}, []string{"op", "result_state"})
}, []string{LblType, LblResult})

// Metrics for ddl_worker.go.
WorkerAddDDLJob = "add_job"
Expand All @@ -88,7 +88,7 @@ var (
Name: "worker_operation_duration_seconds",
Help: "Bucketed histogram of processing time (s) of ddl worker operations",
Buckets: prometheus.ExponentialBuckets(0.001, 2, 20),
}, []string{"op", "result_state"})
}, []string{LblType, LblResult})

CreateDDL = "create_ddl"
CreateDDLWorker = "create_ddl_worker"
Expand All @@ -97,9 +97,9 @@ var (
prometheus.CounterOpts{
Namespace: "tidb",
Subsystem: "ddl",
Name: "worker_total",
Name: "worker_operation_total",
Help: "Counter of creating ddl/worker and isowner.",
}, []string{"type"})
}, []string{LblType})
)

func init() {
Expand Down
4 changes: 2 additions & 2 deletions metrics/distsql.go
Expand Up @@ -32,15 +32,15 @@ var (
prometheus.HistogramOpts{
Namespace: "tidb",
Subsystem: "distsql",
Name: "scan_keys_partial",
Name: "scan_keys_partial_count",
Help: "number of scanned keys for each partial result.",
},
)
DistSQLScanKeysHistogram = prometheus.NewHistogram(
prometheus.HistogramOpts{
Namespace: "tidb",
Subsystem: "distsql",
Name: "scan_keys",
Name: "scan_keys_count",
Help: "number of scanned keys for each query.",
},
)
Expand Down
6 changes: 3 additions & 3 deletions metrics/domain.go
Expand Up @@ -25,14 +25,14 @@ var (
Subsystem: "domain",
Name: "load_schema_total",
Help: "Counter of load schema",
}, []string{"type"})
}, []string{LblType})

// LoadSchemaDuration records the duration of load schema.
LoadSchemaDuration = prometheus.NewHistogram(
prometheus.HistogramOpts{
Namespace: "tidb",
Subsystem: "domain",
Name: "load_schema_duration",
Name: "load_schema_duration_seconds",
Help: "Bucketed histogram of processing time (s) in load schema.",
Buckets: prometheus.ExponentialBuckets(0.001, 2, 15),
})
Expand All @@ -44,7 +44,7 @@ var (
Subsystem: "domain",
Name: "load_privilege_total",
Help: "Counter of load privilege",
}, []string{"type"})
}, []string{LblType})
)

func init() {
Expand Down
4 changes: 2 additions & 2 deletions metrics/executor.go
Expand Up @@ -23,7 +23,7 @@ var (
prometheus.CounterOpts{
Namespace: "tidb",
Subsystem: "executor",
Name: "expensive_executor_counter",
Name: "expensive_total",
Help: "Counter of Expensive Executors.",
}, []string{LblType},
)
Expand All @@ -33,7 +33,7 @@ var (
prometheus.CounterOpts{
Namespace: "tidb",
Subsystem: "executor",
Name: "statement_node_total",
Name: "statement_total",
Help: "Counter of StmtNode.",
}, []string{LblType})
)
Expand Down
4 changes: 2 additions & 2 deletions metrics/meta.go
Expand Up @@ -29,7 +29,7 @@ var (
Name: "operation_duration_seconds",
Help: "Bucketed histogram of processing time (s) of handled autoid.",
Buckets: prometheus.ExponentialBuckets(0.0005, 2, 22),
}, []string{"op", "result_state"})
}, []string{LblType, LblResult})

GetSchemaDiff = "get_schema_diff"
SetSchemaDiff = "set_schema_diff"
Expand All @@ -44,7 +44,7 @@ var (
Name: "operation_duration_seconds",
Help: "Bucketed histogram of processing time (s) of tidb meta data operations.",
Buckets: prometheus.ExponentialBuckets(0.0005, 2, 22),
}, []string{"op", "result_state"})
}, []string{LblType, LblResult})
)

func init() {
Expand Down
3 changes: 2 additions & 1 deletion metrics/metrics.go
Expand Up @@ -20,7 +20,8 @@ var (
PanicCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: "tidb",
Name: "panic",
Subsystem: "server",
Name: "panic_total",
Help: "Counter of panic.",
}, []string{LblType})
)
Expand Down
12 changes: 6 additions & 6 deletions metrics/owner.go
Expand Up @@ -23,10 +23,10 @@ var (
prometheus.HistogramOpts{
Namespace: "tidb",
Subsystem: "owner",
Name: "new_session",
Name: "new_session_duration_seconds",
Help: "Bucketed histogram of processing time (s) of new session.",
Buckets: prometheus.ExponentialBuckets(0.0005, 2, 22),
}, []string{"type", "result_state"})
}, []string{LblType, LblResult})

Cancelled = "cancelled"
Deleted = "deleted"
Expand All @@ -36,18 +36,18 @@ var (
prometheus.CounterOpts{
Namespace: "tidb",
Subsystem: "owner",
Name: "watch_owner",
Name: "watch_owner_total",
Help: "Counter of watch owner.",
}, []string{"type", "return_reason"})
}, []string{LblType, LblResult})

NoLongerOwner = "no_longer_owner"
CampaignOwnerCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: "tidb",
Subsystem: "owner",
Name: "campaign_owner",
Name: "campaign_owner_total",
Help: "Counter of campaign owner.",
}, []string{"type", "retry_reason"})
}, []string{LblType, LblResult})
)

func init() {
Expand Down
10 changes: 5 additions & 5 deletions metrics/server.go
Expand Up @@ -38,7 +38,7 @@ var (
Subsystem: "server",
Name: "query_total",
Help: "Counter of queries.",
}, []string{"type", "status"})
}, []string{LblType, LblResult})

ConnGauge = prometheus.NewGauge(
prometheus.GaugeOpts{
Expand All @@ -52,15 +52,15 @@ var (
prometheus.CounterOpts{
Namespace: "tidb",
Subsystem: "server",
Name: "execute_error",
Name: "execute_error_total",
Help: "Counter of execute errors.",
}, []string{"type"})
}, []string{LblType})

CriticalErrorCounter = prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: "tidb",
Subsystem: "server",
Name: "critical_error",
Name: "critical_error_total",
Help: "Counter of critical errors.",
})

Expand All @@ -77,7 +77,7 @@ var (
Subsystem: "server",
Name: "event_total",
Help: "Counter of tidb-server event.",
}, []string{"type"})
}, []string{LblType})
)

func init() {
Expand Down
31 changes: 16 additions & 15 deletions metrics/session.go
Expand Up @@ -20,62 +20,62 @@ var (
SessionExecuteParseDuration = prometheus.NewHistogram(
prometheus.HistogramOpts{
Namespace: "tidb",
Subsystem: "server",
Name: "session_execute_parse_duration",
Subsystem: "session",
Name: "parse_duration_seconds",
Help: "Bucketed histogram of processing time (s) in parse SQL.",
Buckets: prometheus.LinearBuckets(0.00004, 0.00001, 13),
})
SessionExecuteCompileDuration = prometheus.NewHistogram(
prometheus.HistogramOpts{
Namespace: "tidb",
Subsystem: "server",
Name: "session_execute_compile_duration",
Subsystem: "session",
Name: "compile_duration_seconds",
Help: "Bucketed histogram of processing time (s) in query optimize.",
Buckets: prometheus.LinearBuckets(0.00004, 0.00001, 13),
})
SessionExecuteRunDuration = prometheus.NewHistogram(
prometheus.HistogramOpts{
Namespace: "tidb",
Subsystem: "server",
Name: "session_execute_run_duration",
Subsystem: "session",
Name: "execute_duration_seconds",
Help: "Bucketed histogram of processing time (s) in running executor.",
Buckets: prometheus.ExponentialBuckets(0.0001, 2, 13),
})
SchemaLeaseErrorCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: "tidb",
Subsystem: "server",
Name: "schema_lease_error_counter",
Subsystem: "session",
Name: "schema_lease_error_total",
Help: "Counter of schema lease error",
}, []string{LblType})
SessionRetry = prometheus.NewHistogram(
prometheus.HistogramOpts{
Namespace: "tidb",
Subsystem: "server",
Name: "session_retry",
Subsystem: "session",
Name: "retry_count",
Help: "Bucketed histogram of session retry count.",
Buckets: prometheus.LinearBuckets(0, 1, 10),
})
SessionRetryErrorCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: "tidb",
Subsystem: "server",
Name: "session_retry_error",
Subsystem: "session",
Name: "retry_error_total",
Help: "Counter of session retry error.",
}, []string{LblType})
TransactionCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: "tidb",
Subsystem: "server",
Subsystem: "session",
Name: "transaction_total",
Help: "Counter of transactions.",
}, []string{LblType})

SessionRestrictedSQLCounter = prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: "tidb",
Subsystem: "server",
Name: "session_restricted_sql_counter",
Subsystem: "session",
Name: "restricted_sql_total",
Help: "Counter of internal restricted sql.",
})
)
Expand All @@ -88,6 +88,7 @@ const (
LblError = "error"
LblRollback = "rollback"
LblType = "type"
LblResult = "result"
)

func init() {
Expand Down
4 changes: 2 additions & 2 deletions metrics/stats.go
Expand Up @@ -23,7 +23,7 @@ var (
prometheus.HistogramOpts{
Namespace: "tidb",
Subsystem: "statistics",
Name: "auto_analyze_duration",
Name: "auto_analyze_duration_seconds",
Help: "Bucketed histogram of processing time (s) of auto analyze.",
Buckets: prometheus.ExponentialBuckets(0.01, 2, 20),
})
Expand All @@ -34,7 +34,7 @@ var (
Subsystem: "statistics",
Name: "auto_analyze_total",
Help: "Counter of auto analyze.",
}, []string{"type"})
}, []string{LblType})

StatsInaccuracyRate = prometheus.NewHistogram(
prometheus.HistogramOpts{
Expand Down

0 comments on commit 0157fe5

Please sign in to comment.