Stop tracking the replication end2end latency metric on the sender

The `replication_end_2_end_latency` metric is being populated by both
the sender of the fetch request and the recipient, which makes it
confusing for someone who is looking the metric to understand what
value is appropriate.

Stop tracking this metric on the sender, but calculate the time it
took and log it for diagnostic purposes.

Bug: Issue 40015571
Change-Id: I665a23c288f293b947366f5b0d172af604bac8dc
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/FetchReplicationMetrics.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/FetchReplicationMetrics.java
index 22bb073..13be628 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/FetchReplicationMetrics.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/FetchReplicationMetrics.java
@@ -87,16 +87,6 @@
   }
 
   /**
-   * Start the end-to-end replication latency timer from a source.
-   *
-   * @param name the source name.
-   * @return the timer context.
-   */
-  public Timer1.Context<String> startEnd2End(String name) {
-    return end2EndExecutionTime.start(name);
-  }
-
-  /**
    * Record the end-to-end replication latency timer from a source.
    *
    * @param name the source name.
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/ReplicationQueue.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/ReplicationQueue.java
index e0fba68..e612efa 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/ReplicationQueue.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/ReplicationQueue.java
@@ -100,7 +100,6 @@
   private ExcludedRefsFilter refsFilter;
   private Provider<RevisionReader> revReaderProvider;
   private final ApplyObjectMetrics applyObjectMetrics;
-  private final FetchReplicationMetrics fetchMetrics;
   private final ReplicationQueueMetrics queueMetrics;
   private final String instanceId;
   private final boolean useBatchUpdateEvents;
@@ -116,7 +115,6 @@
       ExcludedRefsFilter refsFilter,
       Provider<RevisionReader> revReaderProvider,
       ApplyObjectMetrics applyObjectMetrics,
-      FetchReplicationMetrics fetchMetrics,
       ReplicationQueueMetrics queueMetrics,
       @GerritInstanceId String instanceId,
       @GerritServerConfig Config gerritConfig,
@@ -132,7 +130,6 @@
     this.refsFilter = refsFilter;
     this.revReaderProvider = revReaderProvider;
     this.applyObjectMetrics = applyObjectMetrics;
-    this.fetchMetrics = fetchMetrics;
     this.queueMetrics = queueMetrics;
     this.instanceId = instanceId;
     this.useBatchUpdateEvents =
@@ -624,9 +621,9 @@
         Optional<HttpResult> result = Optional.empty();
         repLog.info(
             "Pull replication REST API batch fetch to {} for {}:[{}]", apiUrl, project, refsStr);
-        Context<String> timer = fetchMetrics.startEnd2End(source.getRemoteConfigName());
+        long startTime = System.currentTimeMillis();
         result = Optional.of(fetchClient.callBatchFetch(project, filteredRefs, uri));
-        long elapsedMs = TimeUnit.NANOSECONDS.toMillis(timer.stop());
+        long endTime = System.currentTimeMillis();
         boolean resultSuccessful = HttpResultUtils.isSuccessful(result);
         repLog.info(
             "Pull replication REST API batch fetch to {} COMPLETED for {}:[{}], HTTP Result:"
@@ -635,7 +632,7 @@
             project,
             refsStr,
             HttpResultUtils.status(result),
-            elapsedMs);
+            endTime - startTime);
         if (!resultSuccessful
             && HttpResultUtils.isProjectMissing(result, project)
             && source.isCreateMissingRepositories()) {
@@ -684,18 +681,18 @@
             FetchApiClient fetchClient = fetchClientFactory.create(source);
             repLog.info(
                 "Pull replication REST API fetch to {} for {}:{}", apiUrl, project, refName);
-            Context<String> timer = fetchMetrics.startEnd2End(source.getRemoteConfigName());
+            long startTime = System.currentTimeMillis();
             Optional<HttpResult> result = Optional.of(fetchClient.callFetch(project, refName, uri));
-            long elapsedMs = TimeUnit.NANOSECONDS.toMillis(timer.stop());
+            long endTime = System.currentTimeMillis();
             boolean resultSuccessful = HttpResultUtils.isSuccessful(result);
             repLog.info(
                 "Pull replication REST API fetch to {} COMPLETED for {}:{}, HTTP Result:"
-                    + " {} - time:{} ms",
+                    + " {} - time: {} ms",
                 apiUrl,
                 project,
                 refName,
                 HttpResultUtils.status(result),
-                elapsedMs);
+                endTime - startTime);
             if (!resultSuccessful
                 && HttpResultUtils.isProjectMissing(result, project)
                 && source.isCreateMissingRepositories()) {
diff --git a/src/test/java/com/googlesource/gerrit/plugins/replication/pull/ReplicationQueueTest.java b/src/test/java/com/googlesource/gerrit/plugins/replication/pull/ReplicationQueueTest.java
index 26bcc12..ed3ba4a 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/replication/pull/ReplicationQueueTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/replication/pull/ReplicationQueueTest.java
@@ -110,7 +110,6 @@
 
   @Mock Config config;
   ApplyObjectMetrics applyObjectMetrics;
-  FetchReplicationMetrics fetchMetrics;
   ReplicationQueueMetrics queueMetrics;
   ShutdownState shutdownState;
 
@@ -182,7 +181,6 @@
     when(applyObjectsRefsFilter.match(any())).thenReturn(false);
 
     applyObjectMetrics = new ApplyObjectMetrics("pull-replication", new DisabledMetricMaker());
-    fetchMetrics = new FetchReplicationMetrics("pull-replication", new DisabledMetricMaker());
     queueMetrics = new ReplicationQueueMetrics("pull-replication", new DisabledMetricMaker());
     shutdownState = new ShutdownState();
 
@@ -196,7 +194,6 @@
             refsFilter,
             () -> revReader,
             applyObjectMetrics,
-            fetchMetrics,
             queueMetrics,
             LOCAL_INSTANCE_ID,
             config,
@@ -228,7 +225,6 @@
             refsFilter,
             () -> revReader,
             applyObjectMetrics,
-            fetchMetrics,
             queueMetrics,
             LOCAL_INSTANCE_ID,
             config,
@@ -311,7 +307,6 @@
             refsFilter,
             () -> revReader,
             applyObjectMetrics,
-            fetchMetrics,
             queueMetrics,
             LOCAL_INSTANCE_ID,
             config,
@@ -518,7 +513,6 @@
             refsFilter,
             () -> revReader,
             applyObjectMetrics,
-            fetchMetrics,
             queueMetrics,
             LOCAL_INSTANCE_ID,
             config,