@@ -12,6 +12,7 @@ import (
1212func 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