Skip to content

Commit

Permalink
Revert "Add unit to RuntimeMetric"
Browse files Browse the repository at this point in the history
This reverts commit ca38e19.
  • Loading branch information
zacw7 authored and mbasmanova committed May 5, 2022
1 parent 6e35917 commit 9ff349f
Show file tree
Hide file tree
Showing 20 changed files with 196 additions and 341 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public void printFinalInfo()

// bytesFromCache: sum=2K count=2 min=1K max=1K
if (stats.getRuntimeStats() != null) {
stats.getRuntimeStats().getMetrics().stream().sorted(Comparator.comparing(RuntimeMetric::getName)).forEach(
stats.getRuntimeStats().getMetrics().values().stream().sorted(Comparator.comparing(RuntimeMetric::getName)).forEach(
metric -> reprintLine(format("%s: sum=%s count=%s min=%s max=%s",
metric.getName(),
autoFormatMetricValue(metric.getName(), metric.getSum()),
Expand Down Expand Up @@ -340,7 +340,7 @@ private void printQueryInfo(QueryStatusInfo results, WarningsPrinter warningsPri
}

if (stats.getRuntimeStats() != null) {
stats.getRuntimeStats().getMetrics().stream().sorted(Comparator.comparing(RuntimeMetric::getName)).forEach(
stats.getRuntimeStats().getMetrics().values().stream().sorted(Comparator.comparing(RuntimeMetric::getName)).forEach(
metric -> reprintLine(format("%s: sum=%s count=%s min=%s max=%s",
metric.getName(),
autoFormatMetricValue(metric.getName(), metric.getSum()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
public class RuntimeMetric
{
private final String name;
private final RuntimeUnit unit;
private final AtomicLong sum = new AtomicLong();
private final AtomicLong count = new AtomicLong();
private final AtomicLong max = new AtomicLong(Long.MIN_VALUE);
Expand All @@ -39,49 +38,29 @@ public class RuntimeMetric
/**
* Creates a new empty RuntimeMetric.
*
* @param name Name of this metric. If used in the presto core code base, this should be a value defined in {@link RuntimeMetricKey}. But connectors could use arbitrary names.
* @param name Name of this metric. If used in the presto core code base, this should be a value defined in {@link RuntimeMetricName}. But connectors could use arbitrary names.
*/
public RuntimeMetric(String name, RuntimeUnit unit)
public RuntimeMetric(String name)
{
this.name = requireNonNull(name, "name is null");
this.unit = requireNonNull(unit, "unit is null");
}

public RuntimeMetric(RuntimeMetricKey key)
{
requireNonNull(key, "key is null");
this.name = requireNonNull(key.getName(), "name is null");
this.unit = requireNonNull(key.getUnit(), "unit is null");
}

public static RuntimeMetric copyOf(RuntimeMetric metric)
{
requireNonNull(metric, "metric is null");
return new RuntimeMetric(metric.getName(), metric.getUnit(), metric.getSum(), metric.getCount(), metric.getMax(), metric.getMin());
return new RuntimeMetric(metric.getName(), metric.getSum(), metric.getCount(), metric.getMax(), metric.getMin());
}

@JsonCreator
@ThriftConstructor
public RuntimeMetric(
@JsonProperty("name") String name,
@JsonProperty("unit") RuntimeUnit unit,
@JsonProperty("sum") long sum,
@JsonProperty("count") long count,
@JsonProperty("max") long max,
@JsonProperty("min") long min)
{
this(name, unit);
set(sum, count, max, min);
}

public RuntimeMetric(
RuntimeMetricKey key,
long sum,
long count,
long max,
long min)
{
this(key);
this(name);
set(sum, count, max, min);
}

Expand All @@ -106,13 +85,6 @@ public String getName()
return name;
}

@JsonProperty
@ThriftField(2)
public RuntimeUnit getUnit()
{
return unit;
}

public void addValue(long value)
{
sum.addAndGet(value);
Expand Down Expand Up @@ -152,35 +124,30 @@ public void mergeWith(RuntimeMetric metric)
}

@JsonProperty
@ThriftField(3)
@ThriftField(2)
public long getSum()
{
return sum.get();
}

@JsonProperty
@ThriftField(4)
@ThriftField(3)
public long getCount()
{
return count.get();
}

@JsonProperty
@ThriftField(5)
@ThriftField(4)
public long getMax()
{
return max.get();
}

@JsonProperty
@ThriftField(6)
@ThriftField(5)
public long getMin()
{
return min.get();
}

public RuntimeMetricKey getMetricKey()
{
return new RuntimeMetricKey(name, unit);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.facebook.presto.common;

/**
* Names for RuntimeMetrics used in the core presto code base.
* Connectors could use arbitrary metric names not included in this class.
*/
public class RuntimeMetricName
{
private RuntimeMetricName()
{
}

public static final String DRIVER_COUNT_PER_TASK = "driverCountPerTask";
public static final String TASK_ELAPSED_TIME_NANOS = "taskElapsedTimeNanos";
public static final String OPTIMIZED_WITH_MATERIALIZED_VIEW_COUNT = "optimizedWithMaterializedViewCount";
public static final String MANY_PARTITIONS_MISSING_IN_MATERIALIZED_VIEW_COUNT = "manyPartitionsMissingInMaterializedViewCount";
public static final String SKIP_READING_FROM_MATERIALIZED_VIEW_COUNT = "skipReadingFromMaterializedViewCount";
public static final String FRAGMENT_RESULT_CACHE_HIT = "fragmentResultCacheHitCount";
public static final String FRAGMENT_RESULT_CACHE_MISS = "fragmentResultCacheMissCount";
public static final String GET_VIEW_TIME_NANOS = "getViewTimeNanos";
public static final String GET_MATERIALIZED_VIEW_TIME_NANOS = "getMaterializedViewTimeNanos";
public static final String GET_MATERIALIZED_VIEW_STATUS_TIME_NANOS = "getMaterializedViewStatusTimeNanos";
public static final String GET_TABLE_HANDLE_TIME_NANOS = "getTableHandleTimeNanos";
public static final String GET_TABLE_METADATA_TIME_NANOS = "getTableMetadataTimeNanos";
public static final String GET_SPLITS_TIME_NANOS = "getSplitsTimeNanos";
public static final String LOGICAL_PLANNER_TIME_NANOS = "logicalPlannerTimeNanos";
public static final String FRAGMENT_PLAN_TIME_NANOS = "fragmentPlanTimeNanos";
public static final String GET_LAYOUT_TIME_NANOS = "getLayoutTimeNanos";
public static final String REWRITE_AGGREGATION_IF_TO_FILTER_APPLIED = "rewriteAggregationIfToFilterApplied";
// Time between task creation and start.
public static final String TASK_QUEUED_TIME_NANOS = "taskQueuedTimeNanos";
// Total operation time of a task on a worker. TASK_ELAPSED_TIME_NANOS - TASK_SCHEDULED_TIME_NANOS is the time when the task is doing nothing, e.g. it might be waiting for splits/inputs.
public static final String TASK_SCHEDULED_TIME_NANOS = "taskScheduledTimeNanos";
// Blocked time for the operators due to waiting for inputs.
public static final String TASK_BLOCKED_TIME_NANOS = "taskBlockedTimeNanos";
// Time taken for a read call to storage
public static final String STORAGE_READ_TIME_NANOS = "storageReadTimeNanos";
// Size of the data retrieved by read call to storage
public static final String STORAGE_READ_DATA_BYTES = "storageReadDataBytes";
}
Loading

0 comments on commit 9ff349f

Please sign in to comment.