Skip to content

Commit 2926c43

Browse files
authored
Merge pull request #1328 from AlekseyGlushenok/metrics-over-table
Metrics over table
2 parents de97000 + 1ffb2eb commit 2926c43

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
* Added metrics over `db.Table().Do()` and `db.Table().DoTx()`
12
* Added method `ydb.ParamsBuilder().Param(name).Any(value)` to add custom `types.Value`
23
* Upgraded dependencies:
34
* `google.golang.org/grpc` - from `v1.57.1` to `v1.62.1`

metrics/table.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
func table(config Config) (t trace.Table) {
1313
config = config.WithSystem("table")
1414
alive := config.GaugeVec("sessions", "node_id")
15+
session := config.WithSystem("session")
1516
config = config.WithSystem("pool")
1617
limit := config.GaugeVec("limit")
1718
size := config.GaugeVec("size")
@@ -82,6 +83,42 @@ func table(config Config) (t trace.Table) {
8283

8384
return nil
8485
}
86+
{
87+
latency := session.WithSystem("query").TimerVec("latency")
88+
errs := session.WithSystem("query").CounterVec("errs", "status")
89+
attempts := session.WithSystem("query").HistogramVec("attempts", []float64{0, 1, 2, 3, 4, 5, 7, 10})
90+
t.OnDo = func(info trace.TableDoStartInfo) func(trace.TableDoDoneInfo) {
91+
start := time.Now()
92+
93+
return func(doneInfo trace.TableDoDoneInfo) {
94+
if config.Details()&trace.TableSessionQueryEvents != 0 {
95+
latency.With(nil).Record(time.Since(start))
96+
errs.With(map[string]string{
97+
"status": errorBrief(doneInfo.Error),
98+
})
99+
attempts.With(nil).Record(float64(doneInfo.Attempts))
100+
}
101+
}
102+
}
103+
}
104+
{
105+
latency := session.WithSystem("tx").TimerVec("latency")
106+
errs := session.WithSystem("tx").CounterVec("errs", "status")
107+
attempts := session.WithSystem("tx").HistogramVec("attempts", []float64{0, 1, 2, 3, 4, 5, 7, 10})
108+
t.OnDoTx = func(info trace.TableDoTxStartInfo) func(trace.TableDoTxDoneInfo) {
109+
start := time.Now()
110+
111+
return func(doneInfo trace.TableDoTxDoneInfo) {
112+
if config.Details()&trace.TableSessionQueryEvents != 0 {
113+
latency.With(nil).Record(time.Since(start))
114+
errs.With(map[string]string{
115+
"status": errorBrief(doneInfo.Error),
116+
})
117+
attempts.With(nil).Record(float64(doneInfo.Attempts))
118+
}
119+
}
120+
}
121+
}
85122

86123
return t
87124
}

0 commit comments

Comments
 (0)