-
Notifications
You must be signed in to change notification settings - Fork 994
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add JFR Event for Command Latency #1820
Original pull request: #1821.
- Loading branch information
Showing
2 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
src/main/java/io/lettuce/core/event/metrics/JfrCommandLatency.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package io.lettuce.core.event.metrics; | ||
|
||
import io.lettuce.core.metrics.CommandLatencyId; | ||
import io.lettuce.core.metrics.CommandMetrics; | ||
import jdk.jfr.Category; | ||
import jdk.jfr.Event; | ||
import jdk.jfr.Label; | ||
import jdk.jfr.StackTrace; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
/** | ||
* A JFR event for Each Command Latency | ||
* triggered by JfrCommandLatencyEvent | ||
* | ||
* @see JfrCommandLatency | ||
* @author Hash.Jang | ||
*/ | ||
@Category({ "Lettuce", "Command Events" }) | ||
@Label("Command Latency") | ||
@StackTrace(false) | ||
public class JfrCommandLatency extends Event { | ||
private final String remoteAddress; | ||
private final String commandType; | ||
private final long count; | ||
private final TimeUnit timeUnit; | ||
private final long firstResponseMin; | ||
private final long firstResponseMax; | ||
private final String firstResponsePercentiles; | ||
private final long completionResponseMin; | ||
private final long completionResponseMax; | ||
private final String completionResponsePercentiles; | ||
|
||
public JfrCommandLatency(CommandLatencyId commandLatencyId, CommandMetrics commandMetrics) { | ||
this.remoteAddress = commandLatencyId.remoteAddress().toString(); | ||
this.commandType = commandLatencyId.commandType().toString(); | ||
this.count = commandMetrics.getCount(); | ||
this.timeUnit = commandMetrics.getTimeUnit(); | ||
this.firstResponseMin = commandMetrics.getFirstResponse().getMin(); | ||
this.firstResponseMax = commandMetrics.getFirstResponse().getMax(); | ||
this.firstResponsePercentiles = commandMetrics.getFirstResponse().getPercentiles().toString(); | ||
this.completionResponseMin = commandMetrics.getCompletion().getMin(); | ||
this.completionResponseMax = commandMetrics.getCompletion().getMax(); | ||
this.completionResponsePercentiles = commandMetrics.getCompletion().getPercentiles().toString(); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/io/lettuce/core/event/metrics/JfrCommandLatencyEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package io.lettuce.core.event.metrics; | ||
|
||
import jdk.jfr.Category; | ||
import jdk.jfr.Event; | ||
import jdk.jfr.Label; | ||
import jdk.jfr.StackTrace; | ||
|
||
/** | ||
* JFR Event for CommandLatencyEvent | ||
* A JfrCommandLatencyEvent is only a trigger of multiple JfrCommandLatency | ||
* | ||
* @see JfrCommandLatency | ||
* @author Hash.Jang | ||
*/ | ||
@Category({ "Lettuce", "Command Events" }) | ||
@Label("Command Latency Trigger") | ||
@StackTrace(false) | ||
public class JfrCommandLatencyEvent extends Event { | ||
private final int size; | ||
|
||
public JfrCommandLatencyEvent(CommandLatencyEvent commandLatencyEvent) { | ||
this.size = commandLatencyEvent.getLatencies().size(); | ||
commandLatencyEvent.getLatencies().forEach((commandLatencyId, commandMetrics) -> { | ||
JfrCommandLatency jfrCommandLatency = new JfrCommandLatency(commandLatencyId, commandMetrics); | ||
jfrCommandLatency.commit(); | ||
}); | ||
} | ||
} |