Skip to content

Commit

Permalink
add metric
Browse files Browse the repository at this point in the history
  • Loading branch information
aptend committed Sep 11, 2024
1 parent a455ff1 commit 08782f2
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pkg/util/metric/v2/dashboard/grafana_dashboard_logtail.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,20 @@ func (c *DashboardCreator) initLogtailCollectRow() dashboard.Option {
4,
axis.Unit("s"),
axis.Min(0)),

c.getHistogram(
"pull scan row count",
c.getMetricWithFilter("mo_logtail_pull_scan_txn_count_bucket", `type="scan-row"`),
[]float64{0.50, 0.8, 0.90, 0.99},
6,
axis.Min(0)),

c.getHistogram(
"pull scan row count",
c.getMetricWithFilter("mo_logtail_pull_scan_txn_count_bucket", `type="skip-blk"`),
[]float64{0.50, 0.8, 0.90, 0.99},
6,
axis.Min(0)),
)
}

Expand Down
12 changes: 12 additions & 0 deletions pkg/util/metric/v2/logtail.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,18 @@ var (
LogtailSendLatencyHistogram = logTailSendDurationHistogram.WithLabelValues("latency")
LogtailSendNetworkHistogram = logTailSendDurationHistogram.WithLabelValues("network")

LogtailPullScanTxnCountHistogram = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Namespace: "mo",
Subsystem: "logtail",
Name: "pull_scan_txn_count",
Help: "Bucketed histogram of pull scan txn count.",
Buckets: prometheus.ExponentialBuckets(1, 2.0, 20),
}, []string{"type"})

LogTailPullScanSkipBlkCountHistogram = LogtailPullScanTxnCountHistogram.WithLabelValues("skip-blk")
LogTailPullScanScanRowCountHistogram = LogtailPullScanTxnCountHistogram.WithLabelValues("scan-row")

LogTailLoadCheckpointDurationHistogram = prometheus.NewHistogram(
prometheus.HistogramOpts{
Namespace: "mo",
Expand Down
1 change: 1 addition & 0 deletions pkg/util/metric/v2/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ func initLogtailMetrics() {
registry.MustRegister(logTailSendDurationHistogram)
registry.MustRegister(LogTailLoadCheckpointDurationHistogram)

registry.MustRegister(LogtailPullScanTxnCountHistogram)
registry.MustRegister(LogTailPushCollectionDurationHistogram)
registry.MustRegister(LogTailPullCollectionPhase1DurationHistogram)
registry.MustRegister(LogTailPullCollectionPhase2DurationHistogram)
Expand Down
8 changes: 8 additions & 0 deletions pkg/vm/engine/tae/logtail/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package logtail

import (
"github.com/matrixorigin/matrixone/pkg/container/types"
v2 "github.com/matrixorigin/matrixone/pkg/util/metric/v2"
"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/iface/txnif"
"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/model"
)
Expand Down Expand Up @@ -77,7 +78,9 @@ func (r *Reader) GetDirtyByTable(
dbID, id uint64,
) (tree *model.TableTree) {
tree = model.NewTableTree(dbID, id)
var rowScan, blkSkip int
op := func(row RowT) (moveOn bool) {
rowScan++
if memo := row.GetMemo(); memo.HasTableDataChanges(id) {
tree.Merge(memo.GetDirtyTableByID(id))
}
Expand All @@ -89,8 +92,13 @@ func (r *Reader) GetDirtyByTable(
return false
}
_, exist := summary.tids[id]
if !exist {
blkSkip++
}
return !exist
}
v2.LogTailPullScanSkipBlkCountHistogram.Observe(float64(blkSkip))
v2.LogTailPullScanScanRowCountHistogram.Observe(float64(rowScan))
r.table.ForeachRowInBetween(r.from, r.to, skipFn, op)
return
}
Expand Down

0 comments on commit 08782f2

Please sign in to comment.