Skip to content

Commit

Permalink
Expose starting time to event listener
Browse files Browse the repository at this point in the history
  • Loading branch information
sopel39 committed Aug 23, 2024
1 parent 6679e23 commit 36d1a33
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ public void queryImmediateFailureEvent(BasicQueryInfo queryInfo, ExecutionFailur
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty(),
0,
0,
0,
Expand Down Expand Up @@ -317,6 +318,7 @@ private QueryStatistics createQueryStatistics(QueryInfo queryInfo)
Optional.of(ofMillis(queryStats.getAnalysisTime().toMillis())),
Optional.of(ofMillis(queryStats.getPlanningTime().toMillis())),
Optional.of(ofMillis(queryStats.getPlanningCpuTime().toMillis())),
Optional.of(ofMillis(queryStats.getStartingTime().toMillis())),
Optional.of(ofMillis(queryStats.getExecutionTime().toMillis())),
Optional.of(ofMillis(queryStats.getInputBlockedTime().toMillis())),
Optional.of(ofMillis(queryStats.getFailedInputBlockedTime().toMillis())),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class QueryStatistics
private final Optional<Duration> analysisTime;
private final Optional<Duration> planningTime;
private final Optional<Duration> planningCpuTime;
private final Optional<Duration> startingTime;
private final Optional<Duration> executionTime;
private final Optional<Duration> inputBlockedTime;
private final Optional<Duration> failedInputBlockedTime;
Expand Down Expand Up @@ -100,6 +101,7 @@ public QueryStatistics(
Optional<Duration> analysisTime,
Optional<Duration> planningTime,
Optional<Duration> planningCpuTime,
Optional<Duration> startingTime,
Optional<Duration> executionTime,
Optional<Duration> inputBlockedTime,
Optional<Duration> failedInputBlockedTime,
Expand Down Expand Up @@ -145,6 +147,7 @@ public QueryStatistics(
analysisTime,
planningTime,
planningCpuTime,
startingTime,
executionTime,
inputBlockedTime,
failedInputBlockedTime,
Expand Down Expand Up @@ -191,6 +194,7 @@ public QueryStatistics(
Optional<Duration> analysisTime,
Optional<Duration> planningTime,
Optional<Duration> planningCpuTime,
Optional<Duration> startingTime,
Optional<Duration> executionTime,
Optional<Duration> inputBlockedTime,
Optional<Duration> failedInputBlockedTime,
Expand Down Expand Up @@ -235,6 +239,7 @@ public QueryStatistics(
this.analysisTime = requireNonNull(analysisTime, "analysisTime is null");
this.planningTime = requireNonNull(planningTime, "planningTime is null");
this.planningCpuTime = requireNonNull(planningCpuTime, "planningCpuTime is null");
this.startingTime = requireNonNull(startingTime, "startingTime is null");
this.executionTime = requireNonNull(executionTime, "executionTime is null");
this.inputBlockedTime = requireNonNull(inputBlockedTime, "inputBlockedTime is null");
this.failedInputBlockedTime = requireNonNull(failedInputBlockedTime, "failedInputBlockedTime is null");
Expand Down Expand Up @@ -330,6 +335,12 @@ public Optional<Duration> getPlanningCpuTime()
return planningCpuTime;
}

@JsonProperty
public Optional<Duration> getStartingTime()
{
return startingTime;
}

@JsonProperty
public Optional<Duration> getExecutionTime()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ final class TestHttpEventListener
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty(),
0L,
0L,
0L,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ final class TestHttpServerEventListener
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty(),
0L,
0L,
0L,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ private TestUtils()
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty(),
0L,
0L,
0L,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ public void queryCompleted(QueryCompletedEvent event)
stats.getAnalysisTime().map(Duration::toMillis).orElse(0L),
stats.getPlanningTime().map(Duration::toMillis).orElse(0L),
stats.getPlanningCpuTime().map(Duration::toMillis).orElse(0L),
stats.getStartingTime().map(Duration::toMillis).orElse(0L),
stats.getExecutionTime().map(Duration::toMillis).orElse(0L),
stats.getInputBlockedTime().map(Duration::toMillis).orElse(0L),
stats.getFailedInputBlockedTime().map(Duration::toMillis).orElse(0L),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public interface QueryDao
" analysis_time_millis BIGINT NOT NULL,\n" +
" planning_time_millis BIGINT NOT NULL,\n" +
" planning_cpu_time_millis BIGINT NOT NULL,\n" +
" starting_time_millis BIGINT NOT NULL,\n" +
" execution_time_millis BIGINT NOT NULL,\n" +
" input_blocked_time_millis BIGINT NOT NULL,\n" +
" failed_input_blocked_time_millis BIGINT NOT NULL,\n" +
Expand Down Expand Up @@ -135,6 +136,7 @@ public interface QueryDao
" analysis_time_millis,\n" +
" planning_time_millis,\n" +
" planning_cpu_time_millis,\n" +
" starting_time_millis,\n" +
" execution_time_millis,\n" +
" input_blocked_time_millis,\n" +
" failed_input_blocked_time_millis,\n" +
Expand Down Expand Up @@ -204,6 +206,7 @@ public interface QueryDao
" :analysisTimeMillis,\n" +
" :planningTimeMillis,\n" +
" :planningCpuTimeMillis,\n" +
" :startingTimeMillis,\n" +
" :executionTimeMillis,\n" +
" :inputBlockedTimeMillis,\n" +
" :failedInputBlockedTimeMillis,\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public class QueryEntity
private final long analysisTimeMillis;
private final long planningTimeMillis;
private final long planningCpuTimeMillis;
private final long startingTimeMillis;
private final long executionTimeMillis;
private final long inputBlockedTimeMillis;
private final long failedInputBlockedTimeMillis;
Expand Down Expand Up @@ -147,6 +148,7 @@ public QueryEntity(
long analysisTimeMillis,
long planningTimeMillis,
long planningCpuTimeMillis,
long startingTimeMillis,
long executionTimeMillis,
long inputBlockedTimeMillis,
long failedInputBlockedTimeMillis,
Expand Down Expand Up @@ -215,6 +217,7 @@ public QueryEntity(
this.analysisTimeMillis = analysisTimeMillis;
this.planningTimeMillis = planningTimeMillis;
this.planningCpuTimeMillis = planningCpuTimeMillis;
this.startingTimeMillis = startingTimeMillis;
this.executionTimeMillis = executionTimeMillis;
this.inputBlockedTimeMillis = inputBlockedTimeMillis;
this.failedInputBlockedTimeMillis = failedInputBlockedTimeMillis;
Expand Down Expand Up @@ -460,6 +463,11 @@ public long getPlanningCpuTimeMillis()
return planningCpuTimeMillis;
}

public long getStartingTimeMillis()
{
return startingTimeMillis;
}

public long getExecutionTimeMillis()
{
return executionTimeMillis;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ final class TestMysqlEventListener
Optional.of(ofMillis(108)),
Optional.of(ofMillis(109)),
Optional.of(ofMillis(1091)),
Optional.of(ofMillis(1092)),
Optional.of(ofMillis(110)),
Optional.of(ofMillis(111)),
Optional.of(ofMillis(112)),
Expand Down Expand Up @@ -260,6 +261,7 @@ final class TestMysqlEventListener
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty(),
115L,
116L,
117L,
Expand Down Expand Up @@ -424,6 +426,7 @@ void testFull()
assertThat(resultSet.getLong("analysis_time_millis")).isEqualTo(108);
assertThat(resultSet.getLong("planning_time_millis")).isEqualTo(109);
assertThat(resultSet.getLong("planning_cpu_time_millis")).isEqualTo(1091);
assertThat(resultSet.getLong("starting_time_millis")).isEqualTo(1092);
assertThat(resultSet.getLong("execution_time_millis")).isEqualTo(110);
assertThat(resultSet.getLong("input_blocked_time_millis")).isEqualTo(111);
assertThat(resultSet.getLong("failed_input_blocked_time_millis")).isEqualTo(112);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ private TrinoEventData()
Optional.empty(),
Optional.empty(),
Optional.empty(),
Optional.empty(),
0L,
0L,
0L,
Expand Down

0 comments on commit 36d1a33

Please sign in to comment.