Skip to content

Commit

Permalink
[trinodb#31] Expose three more query-related time statistics in Query…
Browse files Browse the repository at this point in the history
…Manager
  • Loading branch information
杨金德 authored and fengguangyuan committed Mar 9, 2022
1 parent 75c6b72 commit aafd909
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public class QueryManagerStats
private final CounterStat consumedCpuTimeSecs = new CounterStat();
private final TimeStat executionTime = new TimeStat(MILLISECONDS);
private final TimeStat queuedTime = new TimeStat(MILLISECONDS);
private final TimeStat elapsedTime = new TimeStat(MILLISECONDS);
private final TimeStat analysisTime = new TimeStat(MILLISECONDS);
private final TimeStat planningTime = new TimeStat(MILLISECONDS);
private final DistributionStat wallInputBytesRate = new DistributionStat();
private final DistributionStat cpuInputByteRate = new DistributionStat();

Expand Down Expand Up @@ -82,6 +85,9 @@ private void queryFinished(BasicQueryInfo info)
consumedInputRows.update(info.getQueryStats().getRawInputPositions());
executionTime.add(info.getQueryStats().getExecutionTime());
queuedTime.add(info.getQueryStats().getQueuedTime());
elapsedTime.add(info.getQueryStats().getElapsedTime());
analysisTime.add(info.getQueryStats().getAnalysisTime());
planningTime.add(info.getQueryStats().getPlanningTime());

long executionWallMillis = info.getQueryStats().getExecutionTime().toMillis();
if (executionWallMillis > 0) {
Expand Down Expand Up @@ -225,6 +231,27 @@ public TimeStat getQueuedTime()
return queuedTime;
}

@Managed
@Nested
public TimeStat getElapsedTime()
{
return elapsedTime;
}

@Managed
@Nested
public TimeStat getAnalysisTime()
{
return analysisTime;
}

@Managed
@Nested
public TimeStat getPlanningTime()
{
return planningTime;
}

@Managed
@Nested
public CounterStat getUserErrorFailures()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,8 @@ public BasicQueryInfo getBasicQueryInfo(Optional<BasicStageStats> rootStage)
queryStateTimer.getQueuedTime(),
queryStateTimer.getElapsedTime(),
queryStateTimer.getExecutionTime(),
queryStateTimer.getAnalysisTime(),
queryStateTimer.getPlanningTime(),

stageStats.getTotalDrivers(),
stageStats.getQueuedDrivers(),
Expand Down
22 changes: 22 additions & 0 deletions core/trino-main/src/main/java/io/trino/server/BasicQueryStats.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public class BasicQueryStats
private final Duration queuedTime;
private final Duration elapsedTime;
private final Duration executionTime;
private final Duration analysisTime;
private final Duration planningTime;

private final int totalDrivers;
private final int queuedDrivers;
Expand Down Expand Up @@ -75,6 +77,8 @@ public BasicQueryStats(
@JsonProperty("queuedTime") Duration queuedTime,
@JsonProperty("elapsedTime") Duration elapsedTime,
@JsonProperty("executionTime") Duration executionTime,
@JsonProperty("analysisTime") Duration analysisTime,
@JsonProperty("planningTime") Duration planningTime,
@JsonProperty("totalDrivers") int totalDrivers,
@JsonProperty("queuedDrivers") int queuedDrivers,
@JsonProperty("runningDrivers") int runningDrivers,
Expand All @@ -100,6 +104,8 @@ public BasicQueryStats(
this.queuedTime = requireNonNull(queuedTime, "queuedTime is null");
this.elapsedTime = requireNonNull(elapsedTime, "elapsedTime is null");
this.executionTime = requireNonNull(executionTime, "executionTime is null");
this.analysisTime = requireNonNull(analysisTime, "analysisTime is null");
this.planningTime = requireNonNull(planningTime, "planningTime is null");

checkArgument(totalDrivers >= 0, "totalDrivers is negative");
this.totalDrivers = totalDrivers;
Expand Down Expand Up @@ -136,6 +142,8 @@ public BasicQueryStats(QueryStats queryStats)
queryStats.getQueuedTime(),
queryStats.getElapsedTime(),
queryStats.getExecutionTime(),
queryStats.getAnalysisTime(),
queryStats.getPlanningTime(),
queryStats.getTotalDrivers(),
queryStats.getQueuedDrivers(),
queryStats.getRunningDrivers(),
Expand Down Expand Up @@ -165,6 +173,8 @@ public static BasicQueryStats immediateFailureQueryStats()
new Duration(0, MILLISECONDS),
new Duration(0, MILLISECONDS),
new Duration(0, MILLISECONDS),
new Duration(0, MILLISECONDS),
new Duration(0, MILLISECONDS),
0,
0,
0,
Expand Down Expand Up @@ -215,6 +225,18 @@ public Duration getExecutionTime()
return executionTime;
}

@JsonProperty
public Duration getAnalysisTime()
{
return analysisTime;
}

@JsonProperty
public Duration getPlanningTime()
{
return planningTime;
}

@JsonProperty
public int getTotalDrivers()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ public BasicQueryInfo getBasicQueryInfo()
new Duration(3, NANOSECONDS),
new Duration(4, NANOSECONDS),
new Duration(5, NANOSECONDS),
new Duration(23, NANOSECONDS),
new Duration(24, NANOSECONDS),
6,
7,
8,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ public void testConstructor()
assertEquals(basicInfo.getQueryStats().getEndTime(), DateTime.parse("1991-09-06T06:00-05:30"));
assertEquals(basicInfo.getQueryStats().getElapsedTime(), new Duration(8, MINUTES));
assertEquals(basicInfo.getQueryStats().getExecutionTime(), new Duration(44, MINUTES));
assertEquals(basicInfo.getQueryStats().getAnalysisTime(), new Duration(9, MINUTES));
assertEquals(basicInfo.getQueryStats().getPlanningTime(), new Duration(99, SECONDS));

assertEquals(basicInfo.getQueryStats().getTotalDrivers(), 16);
assertEquals(basicInfo.getQueryStats().getQueuedDrivers(), 17);
Expand Down
4 changes: 4 additions & 0 deletions plugin/trino-iceberg/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@
<groupId>org.apache.avro</groupId>
<artifactId>avro</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</exclusion>
</exclusions>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ private static BasicQueryInfo createQueryInfo(String queryId, QueryState state)
new Duration(8, MINUTES),
new Duration(7, MINUTES),
new Duration(34, MINUTES),
new Duration(35, MINUTES),
new Duration(36, MINUTES),
13,
14,
15,
Expand Down

0 comments on commit aafd909

Please sign in to comment.