Do not use timer.getStartTime() when propating timers metrics When the Fetch API client propagates the start time of the E2E metrics, the native Gerrit metric timer value cannot be used because it is not based on Epoch but on an internal JVM-dependent timing. Use instead the default System.currentTimeMillis() which is guaranteed to be based on the Epoch. Change-Id: I2ec7e5dc40dcb54f2cafc2be32e6c60fd93738e5
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 f3e38fd..380ac8e 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
@@ -424,7 +424,7 @@ FetchApiClient fetchClient = fetchClientFactory.create(source); repLog.info("Pull replication REST API fetch to {} for {}:{}", apiUrl, project, refName); Context<String> timer = fetchMetrics.startEnd2End(source.getRemoteConfigName()); - HttpResult result = fetchClient.callFetch(project, refName, uri, timer.getStartTime()); + HttpResult result = fetchClient.callFetch(project, refName, uri); long elapsedMs = TimeUnit.NANOSECONDS.toMillis(timer.stop()); boolean resultSuccessful = result.isSuccessful(); repLog.info(
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 48e0e71..6d4c499 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
@@ -19,7 +19,6 @@ import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.Mockito.any; import static org.mockito.Mockito.anyInt; -import static org.mockito.Mockito.anyLong; import static org.mockito.Mockito.anyString; import static org.mockito.Mockito.eq; import static org.mockito.Mockito.lenient; @@ -138,8 +137,7 @@ lenient() .when(fetchRestApiClient.callSendObjects(any(), anyString(), any(), any())) .thenReturn(httpResult); - when(fetchRestApiClient.callFetch(any(), anyString(), any(), anyLong())) - .thenReturn(fetchHttpResult); + when(fetchRestApiClient.callFetch(any(), anyString(), any())).thenReturn(fetchHttpResult); when(fetchRestApiClient.initProject(any(), any())).thenReturn(successfulHttpResult); when(successfulHttpResult.isSuccessful()).thenReturn(true); when(httpResult.isSuccessful()).thenReturn(true); @@ -216,7 +214,7 @@ objectUnderTest.onGitReferenceUpdated(event); - verify(fetchRestApiClient).callFetch(any(), anyString(), any(), anyLong()); + verify(fetchRestApiClient).callFetch(any(), anyString(), any()); } @Test @@ -229,7 +227,7 @@ objectUnderTest.onGitReferenceUpdated(event); - verify(fetchRestApiClient).callFetch(any(), anyString(), any(), anyLong()); + verify(fetchRestApiClient).callFetch(any(), anyString(), any()); } @Test @@ -245,7 +243,7 @@ objectUnderTest.onGitReferenceUpdated(event); - verify(fetchRestApiClient).callFetch(any(), anyString(), any(), anyLong()); + verify(fetchRestApiClient).callFetch(any(), anyString(), any()); } @Test