@@ -46,8 +46,7 @@ type callinfo struct {
46
46
Callinfos map [string ]map [string ]* pathinfo //first key peername,second key path
47
47
}
48
48
type pathinfo struct {
49
- SuccessCount uint32
50
- ErrCount uint32
49
+ TotalCount uint32
51
50
ErrCodeCount map [int32 ]uint32
52
51
T50 uint64 //nano second
53
52
T90 uint64 //nano second
@@ -222,15 +221,15 @@ func WebClientMonitor(peername, method, path string, e error, timewaste uint64)
222
221
}
223
222
}
224
223
atomic .AddUint32 (& (pinfo .timewaste [timewasteIndex (timewaste )]), 1 )
224
+ atomic .AddUint32 (& pinfo .TotalCount , 1 )
225
225
//error
226
226
ee := cerror .ConvertStdError (e )
227
+ pinfo .lker .Lock ()
227
228
if ee == nil {
228
- atomic .AddUint32 (& pinfo .SuccessCount , 1 )
229
- return
229
+ pinfo .ErrCodeCount [0 ]++
230
+ } else {
231
+ pinfo .ErrCodeCount [ee .Code ]++
230
232
}
231
- atomic .AddUint32 (& pinfo .ErrCount , 1 )
232
- pinfo .lker .Lock ()
233
- pinfo .ErrCodeCount [ee .Code ]++
234
233
pinfo .lker .Unlock ()
235
234
}
236
235
func WebServerMonitor (peername , method , path string , e error , timewaste uint64 ) {
@@ -264,15 +263,15 @@ func WebServerMonitor(peername, method, path string, e error, timewaste uint64)
264
263
}
265
264
}
266
265
atomic .AddUint32 (& (pinfo .timewaste [timewasteIndex (timewaste )]), 1 )
266
+ atomic .AddUint32 (& pinfo .TotalCount , 1 )
267
267
//error
268
268
ee := cerror .ConvertStdError (e )
269
+ pinfo .lker .Lock ()
269
270
if ee == nil {
270
- atomic .AddUint32 (& pinfo .SuccessCount , 1 )
271
- return
271
+ pinfo .ErrCodeCount [0 ]++
272
+ } else {
273
+ pinfo .ErrCodeCount [ee .Code ]++
272
274
}
273
- atomic .AddUint32 (& pinfo .ErrCount , 1 )
274
- pinfo .lker .Lock ()
275
- pinfo .ErrCodeCount [ee .Code ]++
276
275
pinfo .lker .Unlock ()
277
276
}
278
277
func GrpcClientMonitor (peername , method , path string , e error , timewaste uint64 ) {
@@ -306,15 +305,15 @@ func GrpcClientMonitor(peername, method, path string, e error, timewaste uint64)
306
305
}
307
306
}
308
307
atomic .AddUint32 (& (pinfo .timewaste [timewasteIndex (timewaste )]), 1 )
308
+ atomic .AddUint32 (& pinfo .TotalCount , 1 )
309
309
//error
310
310
ee := cerror .ConvertStdError (e )
311
+ pinfo .lker .Lock ()
311
312
if ee == nil {
312
- atomic .AddUint32 (& pinfo .SuccessCount , 1 )
313
- return
313
+ pinfo .ErrCodeCount [0 ]++
314
+ } else {
315
+ pinfo .ErrCodeCount [ee .Code ]++
314
316
}
315
- atomic .AddUint32 (& pinfo .ErrCount , 1 )
316
- pinfo .lker .Lock ()
317
- pinfo .ErrCodeCount [ee .Code ]++
318
317
pinfo .lker .Unlock ()
319
318
320
319
}
@@ -349,15 +348,15 @@ func GrpcServerMonitor(peername, method, path string, e error, timewaste uint64)
349
348
}
350
349
}
351
350
atomic .AddUint32 (& (pinfo .timewaste [timewasteIndex (timewaste )]), 1 )
351
+ atomic .AddUint32 (& pinfo .TotalCount , 1 )
352
352
//error
353
353
ee := cerror .ConvertStdError (e )
354
+ pinfo .lker .Lock ()
354
355
if ee == nil {
355
- atomic .AddUint32 (& pinfo .SuccessCount , 1 )
356
- return
356
+ pinfo .ErrCodeCount [0 ]++
357
+ } else {
358
+ pinfo .ErrCodeCount [ee .Code ]++
357
359
}
358
- atomic .AddUint32 (& pinfo .ErrCount , 1 )
359
- pinfo .lker .Lock ()
360
- pinfo .ErrCodeCount [ee .Code ]++
361
360
pinfo .lker .Unlock ()
362
361
}
363
362
func CrpcClientMonitor (peername , method , path string , e error , timewaste uint64 ) {
@@ -391,15 +390,15 @@ func CrpcClientMonitor(peername, method, path string, e error, timewaste uint64)
391
390
}
392
391
}
393
392
atomic .AddUint32 (& (pinfo .timewaste [timewasteIndex (timewaste )]), 1 )
393
+ atomic .AddUint32 (& pinfo .TotalCount , 1 )
394
394
//error
395
395
ee := cerror .ConvertStdError (e )
396
+ pinfo .lker .Lock ()
396
397
if ee == nil {
397
- atomic .AddUint32 (& pinfo .SuccessCount , 1 )
398
- return
398
+ pinfo .ErrCodeCount [0 ]++
399
+ } else {
400
+ pinfo .ErrCodeCount [ee .Code ]++
399
401
}
400
- atomic .AddUint32 (& pinfo .ErrCount , 1 )
401
- pinfo .lker .Lock ()
402
- pinfo .ErrCodeCount [ee .Code ]++
403
402
pinfo .lker .Unlock ()
404
403
}
405
404
func CrpcServerMonitor (peername , method , path string , e error , timewaste uint64 ) {
@@ -433,15 +432,15 @@ func CrpcServerMonitor(peername, method, path string, e error, timewaste uint64)
433
432
}
434
433
}
435
434
atomic .AddUint32 (& (pinfo .timewaste [timewasteIndex (timewaste )]), 1 )
435
+ atomic .AddUint32 (& pinfo .TotalCount , 1 )
436
436
//error
437
437
ee := cerror .ConvertStdError (e )
438
+ pinfo .lker .Lock ()
438
439
if ee == nil {
439
- atomic .AddUint32 (& pinfo .SuccessCount , 1 )
440
- return
440
+ pinfo .ErrCodeCount [0 ]++
441
+ } else {
442
+ pinfo .ErrCodeCount [ee .Code ]++
441
443
}
442
- atomic .AddUint32 (& pinfo .ErrCount , 1 )
443
- pinfo .lker .Lock ()
444
- pinfo .ErrCodeCount [ee .Code ]++
445
444
pinfo .lker .Unlock ()
446
445
}
447
446
@@ -469,42 +468,42 @@ func GetMonitorInfo() *Monitor {
469
468
for _ , cinfo := range r .WebClientinfos {
470
469
for _ , peer := range cinfo .Callinfos {
471
470
for _ , path := range peer {
472
- path .T50 , path .T90 , path .T99 = getT (& path .timewaste , path .maxTimewaste , path .SuccessCount + path . ErrCount )
471
+ path .T50 , path .T90 , path .T99 = getT (& path .timewaste , path .maxTimewaste , path .TotalCount )
473
472
}
474
473
}
475
474
}
476
475
for _ , cinfo := range r .WebServerinfos {
477
476
for _ , peer := range cinfo .Callinfos {
478
477
for _ , path := range peer {
479
- path .T50 , path .T90 , path .T99 = getT (& path .timewaste , path .maxTimewaste , path .SuccessCount + path . ErrCount )
478
+ path .T50 , path .T90 , path .T99 = getT (& path .timewaste , path .maxTimewaste , path .TotalCount )
480
479
}
481
480
}
482
481
}
483
482
for _ , cinfo := range r .GrpcClientinfos {
484
483
for _ , peer := range cinfo .Callinfos {
485
484
for _ , path := range peer {
486
- path .T50 , path .T90 , path .T99 = getT (& path .timewaste , path .maxTimewaste , path .SuccessCount + path . ErrCount )
485
+ path .T50 , path .T90 , path .T99 = getT (& path .timewaste , path .maxTimewaste , path .TotalCount )
487
486
}
488
487
}
489
488
}
490
489
for _ , cinfo := range r .GrpcServerinfos {
491
490
for _ , peer := range cinfo .Callinfos {
492
491
for _ , path := range peer {
493
- path .T50 , path .T90 , path .T99 = getT (& path .timewaste , path .maxTimewaste , path .SuccessCount + path . ErrCount )
492
+ path .T50 , path .T90 , path .T99 = getT (& path .timewaste , path .maxTimewaste , path .TotalCount )
494
493
}
495
494
}
496
495
}
497
496
for _ , cinfo := range r .CrpcClientinfos {
498
497
for _ , peer := range cinfo .Callinfos {
499
498
for _ , path := range peer {
500
- path .T50 , path .T90 , path .T99 = getT (& path .timewaste , path .maxTimewaste , path .SuccessCount + path . ErrCount )
499
+ path .T50 , path .T90 , path .T99 = getT (& path .timewaste , path .maxTimewaste , path .TotalCount )
501
500
}
502
501
}
503
502
}
504
503
for _ , cinfo := range r .CrpcServerinfos {
505
504
for _ , peer := range cinfo .Callinfos {
506
505
for _ , path := range peer {
507
- path .T50 , path .T90 , path .T99 = getT (& path .timewaste , path .maxTimewaste , path .SuccessCount + path . ErrCount )
506
+ path .T50 , path .T90 , path .T99 = getT (& path .timewaste , path .maxTimewaste , path .TotalCount )
508
507
}
509
508
}
510
509
}
0 commit comments