@@ -86,12 +86,14 @@ func zeroTsItem() tsItem {
8686// toProto converts the tsItem to the corresponding protobuf representation.
8787func (i * tsItem ) toProto () * tipb.TopSQLRecordItem {
8888 return & tipb.TopSQLRecordItem {
89- TimestampSec : i .timestamp ,
90- CpuTimeMs : i .cpuTimeMs ,
91- StmtExecCount : i .stmtStats .ExecCount ,
92- StmtKvExecCount : i .stmtStats .KvStatsItem .KvExecCount ,
93- StmtDurationSumNs : i .stmtStats .SumDurationNs ,
94- StmtDurationCount : i .stmtStats .DurationCount ,
89+ TimestampSec : i .timestamp ,
90+ CpuTimeMs : i .cpuTimeMs ,
91+ StmtExecCount : i .stmtStats .ExecCount ,
92+ StmtKvExecCount : i .stmtStats .KvStatsItem .KvExecCount ,
93+ StmtDurationSumNs : i .stmtStats .SumDurationNs ,
94+ StmtDurationCount : i .stmtStats .DurationCount ,
95+ StmtNetworkInBytes : i .stmtStats .NetworkInBytes ,
96+ StmtNetworkOutBytes : i .stmtStats .NetworkOutBytes ,
9597 // Convert more indicators here.
9698 }
9799}
@@ -200,20 +202,25 @@ func (r *record) appendCPUTime(timestamp uint64, cpuTimeMs uint32) {
200202 // Before:
201203 // tsIndex: [10000 => 0]
202204 // tsItems:
203- // timestamp: [10000]
204- // cpuTimeMs: [0]
205- // stmtStats.ExecCount: [?]
206- // stmtStats.KvExecCount: [map{"?": ?}]
207- // stmtStats.DurationSum: [?]
205+ // timestamp: [10000]
206+ // cpuTimeMs: [0]
207+ // stmtStats.ExecCount: [?]
208+ // stmtStats.KvExecCount: [map{"?": ?}]
209+ // stmtStats.DurationSum: [?]
210+ // stmtStats.NetworkInBytes: [?]
211+ // stmtStats.NetworkOutBytes: [?]
208212 //
209213 // After:
210214 // tsIndex: [10000 => 0]
211215 // tsItems:
212- // timestamp: [10000]
213- // cpuTimeMs: [123]
214- // stmtStats.ExecCount: [?]
215- // stmtStats.KvExecCount: [map{"?": ?}]
216- // stmtStats.DurationSum: [?]
216+ // timestamp: [10000]
217+ // cpuTimeMs: [123]
218+ // stmtStats.ExecCount: [?]
219+ // stmtStats.KvExecCount: [map{"?": ?}]
220+ // stmtStats.DurationSum: [?]
221+ // stmtStats.DurationSum: [?]
222+ // stmtStats.NetworkInBytes: [?]
223+ // stmtStats.NetworkOutBytes: [?]
217224 //
218225 r .tsItems [index ].cpuTimeMs += cpuTimeMs
219226 } else {
@@ -225,20 +232,24 @@ func (r *record) appendCPUTime(timestamp uint64, cpuTimeMs uint32) {
225232 // Before:
226233 // tsIndex: []
227234 // tsItems:
228- // timestamp: []
229- // cpuTimeMs: []
230- // stmtStats.ExecCount: []
231- // stmtStats.KvExecCount: []
232- // stmtStats.DurationSum: []
235+ // timestamp: []
236+ // cpuTimeMs: []
237+ // stmtStats.ExecCount: []
238+ // stmtStats.KvExecCount: []
239+ // stmtStats.DurationSum: []
240+ // stmtStats.NetworkInBytes: []
241+ // stmtStats.NetworkOutBytes: []
233242 //
234243 // After:
235244 // tsIndex: [10000 => 0]
236245 // tsItems:
237- // timestamp: [10000]
238- // cpuTimeMs: [123]
239- // stmtStats.ExecCount: [0]
240- // stmtStats.KvExecCount: [map{}]
241- // stmtStats.DurationSum: [0]
246+ // timestamp: [10000]
247+ // cpuTimeMs: [123]
248+ // stmtStats.ExecCount: [0]
249+ // stmtStats.KvExecCount: [map{}]
250+ // stmtStats.DurationSum: [0]
251+ // stmtStats.NetworkInBytes: [0]
252+ // stmtStats.NetworkOutBytes: [0]
242253 //
243254 newItem := zeroTsItem ()
244255 newItem .timestamp = timestamp
@@ -258,50 +269,59 @@ func (r *record) appendStmtStatsItem(timestamp uint64, item stmtstats.StatementS
258269 // corresponding stmtStats has been set to 0 (or other values,
259270 // although impossible), so we merge it.
260271 //
261- // let timestamp = 10000, execCount = 123, kvExecCount = map{"1.1.1.1:1": 123}, durationSum = 456
262- //
272+ // let timestamp = 10000, execCount = 123, kvExecCount = map{"1.1.1.1:1": 123}, durationSum = 456,
273+ // networkInBytes = 10, networkOutBytes = 20
263274 // Before:
264275 // tsIndex: [10000 => 0]
265276 // tsItems:
266- // timestamp: [10000]
267- // cpuTimeMs: [?]
268- // stmtStats.ExecCount: [0]
269- // stmtStats.KvExecCount: [map{}]
270- // stmtStats.DurationSum: [0]
277+ // timestamp: [10000]
278+ // cpuTimeMs: [?]
279+ // stmtStats.ExecCount: [0]
280+ // stmtStats.KvExecCount: [map{}]
281+ // stmtStats.DurationSum: [0]
282+ // stmtStats.NetworkInBytes: [0]
283+ // stmtStats.NetworkOutBytes: [0]
271284 //
272285 // After:
273286 // tsIndex: [10000 => 0]
274287 // tsItems:
275- // timestamp: [10000]
276- // cpuTimeMs: [?]
277- // stmtStats.ExecCount: [123]
278- // stmtStats.KvExecCount: [map{"1.1.1.1:1": 123}]
279- // stmtStats.DurationSum: [456]
288+ // timestamp: [10000]
289+ // cpuTimeMs: [?]
290+ // stmtStats.ExecCount: [123]
291+ // stmtStats.KvExecCount: [map{"1.1.1.1:1": 123}]
292+ // stmtStats.DurationSum: [456]
293+ // stmtStats.NetworkInBytes: [10]
294+ // stmtStats.NetworkOutBytes: [20]
280295 //
281296 r .tsItems [index ].stmtStats .Merge (& item )
282297 } else {
283298 // For this timestamp, we have not appended any tsItem, so append it directly.
284299 // Other fields in tsItem except stmtStats will be initialized to 0.
285300 //
286301 // let timestamp = 10000, execCount = 123, kvExecCount = map{"1.1.1.1:1": 123}, durationSum = 456
302+ // networkInBytes = 10, networkOutBytes = 20
287303 //
288304 // Before:
289305 // tsIndex: []
290306 // tsItems:
291- // timestamp: []
292- // cpuTimeMs: []
293- // stmtStats.ExecCount: []
294- // stmtStats.KvExecCount: []
295- // stmtStats.DurationSum: []
307+ // timestamp: []
308+ // cpuTimeMs: []
309+ // stmtStats.ExecCount: []
310+ // stmtStats.KvExecCount: []
311+ // stmtStats.DurationSum: []
312+ // stmtStats.NetworkInBytes: []
313+ // stmtStats.NetworkOutBytes: []
296314 //
297315 // After:
298316 // tsIndex: [10000 => 0]
299317 // tsItems:
300- // timestamp: [10000]
301- // cpuTimeMs: [0]
302- // stmtStats.ExecCount: [123]
303- // stmtStats.KvExecCount: [map{"1.1.1.1:1": 123}]
304- // stmtStats.DurationSum: [456]
318+ // timestamp: [10000]
319+ // cpuTimeMs: [0]
320+ // stmtStats.ExecCount: [123]
321+ // stmtStats.KvExecCount: [map{"1.1.1.1:1": 123}]
322+ // stmtStats.DurationSum: [456]
323+ // stmtStats.NetworkInBytes: [10]
324+ // stmtStats.NetworkOutBytes: [20]
305325 //
306326 newItem := zeroTsItem ()
307327 newItem .timestamp = timestamp
@@ -543,7 +563,7 @@ func (c *collecting) getReportRecords() records {
543563 for _ , v := range c .records {
544564 rs = append (rs , * v )
545565 }
546- if others != nil && others . totalCPUTimeMs > 0 {
566+ if others != nil {
547567 rs = append (rs , * others )
548568 }
549569 return rs
0 commit comments