Remove PerformanceMetrics
The metrics have performance issues[1] and we will still have perflog for performance investigations.
[1] https://crbug.com/gerrit/15531
Google-Bug-Id:b/280273216
Change-Id: Ib1191a2e66cd7428e81b4c5e6e55b37a1665beb1
Release-Notes: removed perfMetrics
diff --git a/Documentation/config-gerrit.txt b/Documentation/config-gerrit.txt
index 4c666b9..171c922 100644
--- a/Documentation/config-gerrit.txt
+++ b/Documentation/config-gerrit.txt
@@ -5545,18 +5545,6 @@
+
By default, false.
-[[tracing.exportPerformanceMetrics]]tracing.exportPerformanceMetrics::
-+
-Whether to export performance metrics.
-+
-Performace logged when link:#tracing.performanceLogging[`performanceLogging`] is
-enabled, can be exported as metrics.
-+
-NOTE: Since the payload returned could be of tens of thousands metrics,
-assess the latency of the metrics endpoint before enabling this option.
-+
-By default, false.
-
[[tracing.traceid]]
==== Subsection tracing.<trace-id>
diff --git a/Documentation/metrics.txt b/Documentation/metrics.txt
index 6c9dfef..2f43538 100644
--- a/Documentation/metrics.txt
+++ b/Documentation/metrics.txt
@@ -73,30 +73,6 @@
** `cancellation_type`:
The cancellation type (graceful or forceful).
-[[performance]]
-=== Performance
-
-* `performance/operations`: Latency of performing operations
-** `operation_name`:
- The operation that was performed.
-** `request`:
- The request for which the operation was performed (format = '<request-type>
- <redacted-request-uri>').
-** `plugin`:
- The name of the plugin that performed the operation.
-* `performance/operations_count`: Number of performed operations
-** `operation_name`:
- The operation that was performed.
-** `request`:
- The request for which the operation was performed (format = '<request-type>
- <redacted-request-uri>').
-** `plugin`:
- The name of the plugin that performed the operation.
-
-Performance metrics can be enabled via the
-link:config.gerrit.html#tracing.exportPerformanceMetrics[`tracing.exportPerformanceMetrics`]
-setting.
-
=== Pushes
* `receivecommits/changes`: histogram of number of changes processed in a single
diff --git a/java/com/google/gerrit/server/PerformanceMetrics.java b/java/com/google/gerrit/server/PerformanceMetrics.java
deleted file mode 100644
index 845ed80..0000000
--- a/java/com/google/gerrit/server/PerformanceMetrics.java
+++ /dev/null
@@ -1,91 +0,0 @@
-// Copyright (C) 2021 The Android Open Source Project
-//
-// 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.google.gerrit.server;
-
-import com.google.gerrit.common.Nullable;
-import com.google.gerrit.metrics.Counter3;
-import com.google.gerrit.metrics.Description;
-import com.google.gerrit.metrics.Field;
-import com.google.gerrit.metrics.MetricMaker;
-import com.google.gerrit.metrics.Timer3;
-import com.google.gerrit.server.logging.Metadata;
-import com.google.gerrit.server.logging.PerformanceLogger;
-import com.google.gerrit.server.logging.TraceContext;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import java.util.concurrent.TimeUnit;
-
-/** Performance logger that records the execution times as a metric. */
-@Singleton
-public class PerformanceMetrics implements PerformanceLogger {
- private static final String OPERATION_LATENCY_METRIC_NAME = "performance/operations";
- private static final String OPERATION_COUNT_METRIC_NAME = "performance/operations_count";
-
- public final Timer3<String, String, String> operationsLatency;
- public final Counter3<String, String, String> operationsCounter;
-
- @Inject
- PerformanceMetrics(MetricMaker metricMaker) {
- Field<String> operationNameField =
- Field.ofString(
- "operation_name",
- (metadataBuilder, fieldValue) -> metadataBuilder.operationName(fieldValue))
- .description("The operation that was performed.")
- .build();
- Field<String> requestField =
- Field.ofString("request", (metadataBuilder, fieldValue) -> {})
- .description(
- "The request for which the operation was performed"
- + " (format = '<request-type> <redacted-request-uri>').")
- .build();
- Field<String> pluginField =
- Field.ofString(
- "plugin", (metadataBuilder, fieldValue) -> metadataBuilder.pluginName(fieldValue))
- .description("The name of the plugin that performed the operation.")
- .build();
-
- this.operationsLatency =
- metricMaker
- .newTimer(
- OPERATION_LATENCY_METRIC_NAME,
- new Description("Latency of performing operations")
- .setCumulative()
- .setUnit(Description.Units.MILLISECONDS),
- operationNameField,
- requestField,
- pluginField)
- .suppressLogging();
- this.operationsCounter =
- metricMaker.newCounter(
- OPERATION_COUNT_METRIC_NAME,
- new Description("Number of performed operations").setRate(),
- operationNameField,
- requestField,
- pluginField);
- }
-
- @Override
- public void log(String operation, long durationMs) {
- log(operation, durationMs, /* metadata= */ null);
- }
-
- @Override
- public void log(String operation, long durationMs, @Nullable Metadata metadata) {
- String requestTag = TraceContext.getTag(TraceRequestListener.TAG_REQUEST).orElse("");
- String pluginTag = TraceContext.getPluginTag().orElse("");
- operationsLatency.record(operation, requestTag, pluginTag, durationMs, TimeUnit.MILLISECONDS);
- operationsCounter.increment(operation, requestTag, pluginTag);
- }
-}
diff --git a/java/com/google/gerrit/server/config/GerritGlobalModule.java b/java/com/google/gerrit/server/config/GerritGlobalModule.java
index b823115..ae125a4 100644
--- a/java/com/google/gerrit/server/config/GerritGlobalModule.java
+++ b/java/com/google/gerrit/server/config/GerritGlobalModule.java
@@ -88,7 +88,6 @@
import com.google.gerrit.server.ExceptionHookImpl;
import com.google.gerrit.server.ExternalUser;
import com.google.gerrit.server.IdentifiedUser;
-import com.google.gerrit.server.PerformanceMetrics;
import com.google.gerrit.server.RequestListener;
import com.google.gerrit.server.TraceRequestListener;
import com.google.gerrit.server.account.AccountCacheImpl;
@@ -444,9 +443,6 @@
DynamicSet.setOf(binder(), SubmitRequirement.class);
DynamicSet.setOf(binder(), QuotaEnforcer.class);
DynamicSet.setOf(binder(), PerformanceLogger.class);
- if (cfg.getBoolean("tracing", "exportPerformanceMetrics", false)) {
- DynamicSet.bind(binder(), PerformanceLogger.class).to(PerformanceMetrics.class);
- }
DynamicSet.setOf(binder(), RequestListener.class);
DynamicSet.bind(binder(), RequestListener.class).to(TraceRequestListener.class);
DynamicSet.setOf(binder(), ChangeETagComputation.class);