@@ -192,14 +192,15 @@ boolean logSlowOperations(long approxCurrentTimeNanos)
192
192
if (!slowOperations .isEmpty ())
193
193
{
194
194
long approxElapsedNanos = approxCurrentTimeNanos - approxLastLogTimeNanos ;
195
- noSpamLogger .info ("Some operations were slow, details available at debug level (debug.log)" );
195
+ noSpamLogger .info ("Some operations were slow, details available at debug level (debug.log) or " +
196
+ "system_views.slow_queries virtual table (when enabled)." );
196
197
197
198
if (slowOperationsLogger .isDebugEnabled ())
198
199
{
199
200
if (slowOperationsLoggedToVirtualTable )
200
201
{
201
202
// This is the crux of the patch for appending to vtable.
202
- // Because we can send only String's to debug method (or objects, on which toString()
203
+ // Because we can send only Strings to debug method (or objects, on which toString()
203
204
// would be eventually called), we need to log a string in such a way that we can
204
205
// get Operation object(s) back "on the other side" when dealing with vtables and custom appenders
205
206
// as appenders work with LoggingEvent where message is just a string.
@@ -370,10 +371,10 @@ public abstract static class Operation
370
371
long totalTimeNanos ;
371
372
372
373
/** The maximum time spent by this operation */
373
- long maxTime ;
374
+ long maxTimeNanos ;
374
375
375
376
/** The minimum time spent by this operation */
376
- long minTime ;
377
+ long minTimeNanos ;
377
378
378
379
/** The name of the operation, i.e. the SELECT query CQL,
379
380
* this is set lazily as it takes time to build the query CQL */
@@ -385,10 +386,10 @@ public abstract static class Operation
385
386
* which does not follow wall clock and is useless for
386
387
* reporting purposes e.g. in virtual tables
387
388
*/
388
- private final long timestamp ;
389
+ private final long timestampMs ;
389
390
390
391
// optional keyspace and table this operation acts on
391
- // used upon deserialisation
392
+ // used upon deserialization
392
393
private String keyspace ;
393
394
private String table ;
394
395
private boolean crossNode ;
@@ -398,17 +399,17 @@ public abstract static class Operation
398
399
this .operation = operation ;
399
400
numTimesReported = 1 ;
400
401
totalTimeNanos = failedAtNanos - operation .creationTimeNanos ();
401
- minTime = totalTimeNanos ;
402
- maxTime = totalTimeNanos ;
403
- timestamp = Clock .Global .currentTimeMillis ();
402
+ minTimeNanos = totalTimeNanos ;
403
+ maxTimeNanos = totalTimeNanos ;
404
+ timestampMs = Clock .Global .currentTimeMillis () - ( Clock . Global . nanoTime () - operation . creationTimeNanos ()) / 1_000_000 ;
404
405
}
405
406
406
407
void add (Operation operation )
407
408
{
408
409
numTimesReported ++;
409
410
totalTimeNanos += operation .totalTimeNanos ;
410
- maxTime = Math .max (maxTime , operation .maxTime );
411
- minTime = Math .min (minTime , operation .minTime );
411
+ maxTimeNanos = Math .max (maxTimeNanos , operation .maxTimeNanos );
412
+ minTimeNanos = Math .min (minTimeNanos , operation .minTimeNanos );
412
413
}
413
414
414
415
public abstract String getLogMessage ();
@@ -467,15 +468,15 @@ public long totalTimeNanos()
467
468
}
468
469
469
470
@ JsonProperty
470
- public long maxTime ()
471
+ public long maxTimeNanos ()
471
472
{
472
- return maxTime ;
473
+ return maxTimeNanos ;
473
474
}
474
475
475
476
@ JsonProperty
476
- public long minTime ()
477
+ public long minTimeNanos ()
477
478
{
478
- return minTime ;
479
+ return minTimeNanos ;
479
480
}
480
481
481
482
@ JsonIgnore
@@ -485,19 +486,21 @@ public long averageTime()
485
486
}
486
487
487
488
@ JsonProperty
488
- public long timestamp ()
489
+ public long timestampMs ()
489
490
{
490
- return timestamp ;
491
+ return timestampMs ;
491
492
}
492
493
493
494
public static String serialize (Collection <Operation > operations )
494
495
{
495
496
return JsonUtils .writeAsJsonString (operations );
496
497
}
497
498
499
+ private static final TypeReference <List <Operation >> TYPE_REFERENCE = new TypeReference <>() {};
500
+
498
501
public static List <Operation > deserialize (String message ) throws Throwable
499
502
{
500
- return JsonUtils .JSON_OBJECT_MAPPER .readValue (message , new TypeReference <>() {} );
503
+ return JsonUtils .JSON_OBJECT_MAPPER .readValue (message , TYPE_REFERENCE );
501
504
}
502
505
}
503
506
@@ -524,8 +527,8 @@ public String getLogMessage()
524
527
name (),
525
528
numTimesReported ,
526
529
NANOSECONDS .toMillis (totalTimeNanos / numTimesReported ),
527
- NANOSECONDS .toMillis (minTime ),
528
- NANOSECONDS .toMillis (maxTime ),
530
+ NANOSECONDS .toMillis (minTimeNanos ),
531
+ NANOSECONDS .toMillis (maxTimeNanos ),
529
532
NANOSECONDS .toMillis (operation .timeoutNanos ()),
530
533
operation .isCrossNode () ? "msec/cross-node" : "msec" );
531
534
}
@@ -537,7 +540,7 @@ public String getLogMessage()
537
540
@ VisibleForTesting
538
541
public final static class SlowOperation extends Operation
539
542
{
540
- // purely for deserialisation purposes
543
+ // purely for deserialization purposes
541
544
public SlowOperation ()
542
545
{
543
546
this (Monitorable .NO_OP , 0 );
@@ -562,8 +565,8 @@ public String getLogMessage()
562
565
name (),
563
566
numTimesReported ,
564
567
NANOSECONDS .toMillis (totalTimeNanos / numTimesReported ),
565
- NANOSECONDS .toMillis (minTime ),
566
- NANOSECONDS .toMillis (maxTime ),
568
+ NANOSECONDS .toMillis (minTimeNanos ),
569
+ NANOSECONDS .toMillis (maxTimeNanos ),
567
570
NANOSECONDS .toMillis (operation .slowTimeoutNanos ()),
568
571
operation .isCrossNode () ? "msec/cross-node" : "msec" );
569
572
}
0 commit comments