-
Notifications
You must be signed in to change notification settings - Fork 233
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
metrics: seperate metrics with source scope for txn command #723
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,14 +74,27 @@ var ( | |
BackoffHistogramIsWitness prometheus.Observer | ||
BackoffHistogramEmpty prometheus.Observer | ||
|
||
TxnRegionsNumHistogramWithSnapshot prometheus.Observer | ||
TxnRegionsNumHistogramPrewrite prometheus.Observer | ||
TxnRegionsNumHistogramCommit prometheus.Observer | ||
TxnRegionsNumHistogramCleanup prometheus.Observer | ||
TxnRegionsNumHistogramPessimisticLock prometheus.Observer | ||
TxnRegionsNumHistogramPessimisticRollback prometheus.Observer | ||
TxnRegionsNumHistogramWithCoprocessor prometheus.Observer | ||
TxnRegionsNumHistogramWithBatchCoprocessor prometheus.Observer | ||
TxnRegionsNumHistogramWithSnapshotInternal prometheus.Observer | ||
TxnRegionsNumHistogramWithSnapshot prometheus.Observer | ||
TxnRegionsNumHistogramPrewriteInternal prometheus.Observer | ||
TxnRegionsNumHistogramPrewrite prometheus.Observer | ||
TxnRegionsNumHistogramCommitInternal prometheus.Observer | ||
TxnRegionsNumHistogramCommit prometheus.Observer | ||
TxnRegionsNumHistogramCleanupInternal prometheus.Observer | ||
TxnRegionsNumHistogramCleanup prometheus.Observer | ||
TxnRegionsNumHistogramPessimisticLockInternal prometheus.Observer | ||
TxnRegionsNumHistogramPessimisticLock prometheus.Observer | ||
TxnRegionsNumHistogramPessimisticRollbackInternal prometheus.Observer | ||
TxnRegionsNumHistogramPessimisticRollback prometheus.Observer | ||
TxnRegionsNumHistogramWithCoprocessorInternal prometheus.Observer | ||
TxnRegionsNumHistogramWithCoprocessor prometheus.Observer | ||
TxnRegionsNumHistogramWithBatchCoprocessorInternal prometheus.Observer | ||
TxnRegionsNumHistogramWithBatchCoprocessor prometheus.Observer | ||
|
||
TxnWriteKVCountHistogramInternal prometheus.Observer | ||
TxnWriteKVCountHistogramGeneral prometheus.Observer | ||
TxnWriteSizeHistogramInternal prometheus.Observer | ||
TxnWriteSizeHistogramGeneral prometheus.Observer | ||
|
||
LockResolverCountWithBatchResolve prometheus.Counter | ||
LockResolverCountWithExpired prometheus.Counter | ||
|
@@ -185,14 +198,26 @@ func initShortcuts() { | |
BackoffHistogramIsWitness = TiKVBackoffHistogram.WithLabelValues("isWitness") | ||
BackoffHistogramEmpty = TiKVBackoffHistogram.WithLabelValues("") | ||
|
||
TxnRegionsNumHistogramWithSnapshot = TiKVTxnRegionsNumHistogram.WithLabelValues("snapshot") | ||
TxnRegionsNumHistogramPrewrite = TiKVTxnRegionsNumHistogram.WithLabelValues("2pc_prewrite") | ||
TxnRegionsNumHistogramCommit = TiKVTxnRegionsNumHistogram.WithLabelValues("2pc_commit") | ||
TxnRegionsNumHistogramCleanup = TiKVTxnRegionsNumHistogram.WithLabelValues("2pc_cleanup") | ||
TxnRegionsNumHistogramPessimisticLock = TiKVTxnRegionsNumHistogram.WithLabelValues("2pc_pessimistic_lock") | ||
TxnRegionsNumHistogramPessimisticRollback = TiKVTxnRegionsNumHistogram.WithLabelValues("2pc_pessimistic_rollback") | ||
TxnRegionsNumHistogramWithCoprocessor = TiKVTxnRegionsNumHistogram.WithLabelValues("coprocessor") | ||
TxnRegionsNumHistogramWithBatchCoprocessor = TiKVTxnRegionsNumHistogram.WithLabelValues("batch_coprocessor") | ||
TxnRegionsNumHistogramWithSnapshotInternal = TiKVTxnRegionsNumHistogram.WithLabelValues("snapshot", LblInternal) | ||
TxnRegionsNumHistogramWithSnapshot = TiKVTxnRegionsNumHistogram.WithLabelValues("snapshot", LblGeneral) | ||
TxnRegionsNumHistogramPrewriteInternal = TiKVTxnRegionsNumHistogram.WithLabelValues("2pc_prewrite", LblInternal) | ||
TxnRegionsNumHistogramPrewrite = TiKVTxnRegionsNumHistogram.WithLabelValues("2pc_prewrite", LblGeneral) | ||
TxnRegionsNumHistogramCommitInternal = TiKVTxnRegionsNumHistogram.WithLabelValues("2pc_commit", LblInternal) | ||
TxnRegionsNumHistogramCommit = TiKVTxnRegionsNumHistogram.WithLabelValues("2pc_commit", LblGeneral) | ||
TxnRegionsNumHistogramCleanupInternal = TiKVTxnRegionsNumHistogram.WithLabelValues("2pc_cleanup", LblInternal) | ||
TxnRegionsNumHistogramCleanup = TiKVTxnRegionsNumHistogram.WithLabelValues("2pc_cleanup", LblGeneral) | ||
TxnRegionsNumHistogramPessimisticLockInternal = TiKVTxnRegionsNumHistogram.WithLabelValues("2pc_pessimistic_lock", LblInternal) | ||
TxnRegionsNumHistogramPessimisticLock = TiKVTxnRegionsNumHistogram.WithLabelValues("2pc_pessimistic_lock", LblGeneral) | ||
TxnRegionsNumHistogramPessimisticRollbackInternal = TiKVTxnRegionsNumHistogram.WithLabelValues("2pc_pessimistic_rollback", LblInternal) | ||
TxnRegionsNumHistogramPessimisticRollback = TiKVTxnRegionsNumHistogram.WithLabelValues("2pc_pessimistic_rollback", LblGeneral) | ||
TxnRegionsNumHistogramWithCoprocessorInternal = TiKVTxnRegionsNumHistogram.WithLabelValues("coprocessor", LblInternal) | ||
TxnRegionsNumHistogramWithCoprocessor = TiKVTxnRegionsNumHistogram.WithLabelValues("batch_coprocessor", LblGeneral) | ||
TxnRegionsNumHistogramWithBatchCoprocessorInternal = TiKVTxnRegionsNumHistogram.WithLabelValues("coprocessor", LblInternal) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The type "coprocessor" is wrong, and the init of |
||
TxnRegionsNumHistogramWithBatchCoprocessor = TiKVTxnRegionsNumHistogram.WithLabelValues("batch_coprocessor", LblGeneral) | ||
TxnWriteKVCountHistogramInternal = TiKVTxnWriteKVCountHistogram.WithLabelValues(LblInternal) | ||
TxnWriteKVCountHistogramGeneral = TiKVTxnWriteKVCountHistogram.WithLabelValues(LblGeneral) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Unluckily there is no codegen by macro for such works :( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing |
||
TxnWriteSizeHistogramInternal = TiKVTxnWriteKVCountHistogram.WithLabelValues(LblInternal) | ||
TxnWriteSizeHistogramGeneral = TiKVTxnWriteKVCountHistogram.WithLabelValues(LblGeneral) | ||
|
||
LockResolverCountWithBatchResolve = TiKVLockResolverCounter.WithLabelValues("batch_resolve") | ||
LockResolverCountWithExpired = TiKVLockResolverCounter.WithLabelValues("expired") | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -187,6 +187,10 @@ type twoPhaseCommitter struct { | |||||
|
||||||
// assertion error happened when initializing mutations, could be false positive if pessimistic lock is lost | ||||||
stashedAssertionError error | ||||||
|
||||||
// isInternal means it's related to an internal transaction. It's only used by `asyncPessimisticRollback` as the | ||||||
// committer may contain a nil `txn` pointer. | ||||||
isInternal bool | ||||||
} | ||||||
|
||||||
type memBufferMutations struct { | ||||||
|
@@ -696,8 +700,15 @@ func (c *twoPhaseCommitter) initKeysAndMutations(ctx context.Context) error { | |||||
WriteKeys: c.mutations.Len(), | ||||||
ResolveLock: util.ResolveLockDetail{}, | ||||||
} | ||||||
metrics.TiKVTxnWriteKVCountHistogram.Observe(float64(commitDetail.WriteKeys)) | ||||||
metrics.TiKVTxnWriteSizeHistogram.Observe(float64(commitDetail.WriteSize)) | ||||||
|
||||||
isInternalReq := util.IsInternalRequest(c.txn.GetRequestSource()) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
if isInternalReq { | ||||||
metrics.TxnWriteKVCountHistogramInternal.Observe(float64(commitDetail.WriteKeys)) | ||||||
metrics.TxnWriteSizeHistogramInternal.Observe(float64(commitDetail.WriteSize)) | ||||||
} else { | ||||||
metrics.TxnWriteKVCountHistogramGeneral.Observe(float64(commitDetail.WriteKeys)) | ||||||
metrics.TxnWriteSizeHistogramGeneral.Observe(float64(commitDetail.WriteSize)) | ||||||
} | ||||||
c.hasNoNeedCommitKeys = checkCnt > 0 | ||||||
c.lockTTL = txnLockTTL(txn.startTime, size) | ||||||
c.priority = txn.priority.ToPB() | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TxnRegionsNumHistogramWithCoprocessorInternal
is missing