You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/12/29 12:31:08 UTC
[GitHub] [iotdb] liuminghui233 commented on a diff in pull request #8529: [IOTDB-5171] Add query metrics
liuminghui233 commented on code in PR #8529:
URL: https://github.com/apache/iotdb/pull/8529#discussion_r1058925930
##########
server/src/main/java/org/apache/iotdb/db/mpp/metric/QueryMetricsManager.java:
##########
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.iotdb.db.mpp.metric;
+
+import org.apache.iotdb.commons.service.metric.MetricService;
+import org.apache.iotdb.commons.service.metric.enums.Metric;
+import org.apache.iotdb.commons.service.metric.enums.Tag;
+import org.apache.iotdb.metrics.utils.MetricInfo;
+import org.apache.iotdb.metrics.utils.MetricLevel;
+
+import java.util.concurrent.TimeUnit;
+
+import static org.apache.iotdb.db.mpp.metric.DataExchangeMetricSet.GET_DATA_BLOCK_NUM;
+
+public class QueryMetricsManager {
+
+ private final MetricService metricService = MetricService.getInstance();
+
+ public void recordPlanCost(String stage, long costTimeInNanos) {
+ metricService.timer(
+ costTimeInNanos,
+ TimeUnit.NANOSECONDS,
+ Metric.QUERY_PLAN_COST.toString(),
+ MetricLevel.IMPORTANT,
+ Tag.STAGE.toString(),
+ stage);
+ }
+
+ public void recordOperatorExecutionCost(String operatorType, long costTimeInNanos) {
+ metricService.timer(
+ costTimeInNanos,
+ TimeUnit.NANOSECONDS,
+ Metric.OPERATOR_EXECUTION_COST.toString(),
+ MetricLevel.IMPORTANT,
+ Tag.NAME.toString(),
+ operatorType);
+ }
+
+ public void recordOperatorExecutionCount(String operatorType, long count) {
+ metricService.count(
+ count,
+ Metric.OPERATOR_EXECUTION_COUNT.toString(),
+ MetricLevel.IMPORTANT,
+ Tag.NAME.toString(),
+ operatorType);
+ }
+
+ public void recordSeriesScanCost(String stage, long costTimeInNanos) {
+ MetricInfo metricInfo = SeriesScanCostMetricSet.metricInfoMap.get(stage);
+ metricService.timer(
+ costTimeInNanos,
+ TimeUnit.NANOSECONDS,
+ metricInfo.getName(),
+ MetricLevel.IMPORTANT,
+ metricInfo.getTagsInArray());
+ }
+
+ public void recordExecutionCost(String stage, long costTimeInNanos) {
+ MetricInfo metricInfo = QueryExecutionMetricSet.metricInfoMap.get(stage);
+ metricService.timer(
+ costTimeInNanos,
+ TimeUnit.NANOSECONDS,
+ metricInfo.getName(),
+ MetricLevel.IMPORTANT,
+ metricInfo.getTagsInArray());
+ }
+
+ public void recordQueryResourceNum(String type, int count) {
+ metricService.rate(
Review Comment:
fix
##########
server/src/main/java/org/apache/iotdb/db/mpp/metric/QueryMetricsManager.java:
##########
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.iotdb.db.mpp.metric;
+
+import org.apache.iotdb.commons.service.metric.MetricService;
+import org.apache.iotdb.commons.service.metric.enums.Metric;
+import org.apache.iotdb.commons.service.metric.enums.Tag;
+import org.apache.iotdb.metrics.utils.MetricInfo;
+import org.apache.iotdb.metrics.utils.MetricLevel;
+
+import java.util.concurrent.TimeUnit;
+
+import static org.apache.iotdb.db.mpp.metric.DataExchangeMetricSet.GET_DATA_BLOCK_NUM;
+
+public class QueryMetricsManager {
+
+ private final MetricService metricService = MetricService.getInstance();
+
+ public void recordPlanCost(String stage, long costTimeInNanos) {
+ metricService.timer(
+ costTimeInNanos,
+ TimeUnit.NANOSECONDS,
+ Metric.QUERY_PLAN_COST.toString(),
+ MetricLevel.IMPORTANT,
+ Tag.STAGE.toString(),
+ stage);
+ }
+
+ public void recordOperatorExecutionCost(String operatorType, long costTimeInNanos) {
+ metricService.timer(
+ costTimeInNanos,
+ TimeUnit.NANOSECONDS,
+ Metric.OPERATOR_EXECUTION_COST.toString(),
+ MetricLevel.IMPORTANT,
+ Tag.NAME.toString(),
+ operatorType);
+ }
+
+ public void recordOperatorExecutionCount(String operatorType, long count) {
+ metricService.count(
+ count,
+ Metric.OPERATOR_EXECUTION_COUNT.toString(),
+ MetricLevel.IMPORTANT,
+ Tag.NAME.toString(),
+ operatorType);
+ }
+
+ public void recordSeriesScanCost(String stage, long costTimeInNanos) {
+ MetricInfo metricInfo = SeriesScanCostMetricSet.metricInfoMap.get(stage);
+ metricService.timer(
+ costTimeInNanos,
+ TimeUnit.NANOSECONDS,
+ metricInfo.getName(),
+ MetricLevel.IMPORTANT,
+ metricInfo.getTagsInArray());
+ }
+
+ public void recordExecutionCost(String stage, long costTimeInNanos) {
+ MetricInfo metricInfo = QueryExecutionMetricSet.metricInfoMap.get(stage);
+ metricService.timer(
+ costTimeInNanos,
+ TimeUnit.NANOSECONDS,
+ metricInfo.getName(),
+ MetricLevel.IMPORTANT,
+ metricInfo.getTagsInArray());
+ }
+
+ public void recordQueryResourceNum(String type, int count) {
+ metricService.rate(
+ count, Metric.QUERY_RESOURCE.toString(), MetricLevel.IMPORTANT, Tag.TYPE.toString(), type);
+ }
+
+ public void recordDataExchangeCost(String stage, long costTimeInNanos) {
+ MetricInfo metricInfo = DataExchangeMetricSet.metricInfoMap.get(stage);
+ metricService.timer(
+ costTimeInNanos,
+ TimeUnit.NANOSECONDS,
+ metricInfo.getName(),
+ MetricLevel.IMPORTANT,
+ metricInfo.getTagsInArray());
+ }
+
+ public void recordDataBlockNum(int num) {
+ metricService.rate(
Review Comment:
fix
##########
server/src/main/java/org/apache/iotdb/db/mpp/execution/exchange/SourceHandle.java:
##########
@@ -129,14 +136,21 @@ public SourceHandle(
public synchronized TsBlock receive() {
ByteBuffer tsBlock = getSerializedTsBlock();
if (tsBlock != null) {
- return serde.deserialize(tsBlock);
+ long startTime = System.nanoTime();
+ try {
+ return serde.deserialize(tsBlock);
+ } finally {
+ QUERY_METRICS.recordDataExchangeCost(
+ SOURCE_HANDLE_SERIALIZE_TSBLOCK_REMOTE, System.nanoTime() - startTime);
Review Comment:
fix
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org