Skip to content

Commit cfa5ae4

Browse files
committed
Adding shard operation changes
Signed-off-by: nishchay21 <nishcha@amazon.com>
1 parent 19df885 commit cfa5ae4

2 files changed

Lines changed: 5 additions & 12 deletions

File tree

src/main/java/org/opensearch/performanceanalyzer/listener/RTFPerformanceAnalyzerSearchListener.java

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,13 @@ public void preQueryPhase(SearchContext searchContext) {
189189
@Override
190190
public void queryPhase(SearchContext searchContext, long tookInNanos) {
191191
long queryStartTime = threadLocal.get().getOrDefault(QUERY_START_TIME, System.nanoTime());
192-
long queryTime = (System.nanoTime() - queryStartTime);
193-
double queryTimeInMills = queryTime / 1_000_000.0;
192+
double queryTimeInMills = tookInNanos / 1_000_000.0;
194193

195194
searchLatencyHistogram.record(
196195
queryTimeInMills, createTags(searchContext, SHARD_QUERY_PHASE, false));
197196

198197
addResourceTrackingCompletionListener(
199-
searchContext, queryStartTime, queryTime, SHARD_QUERY_PHASE, false);
198+
searchContext, queryStartTime, tookInNanos, SHARD_QUERY_PHASE, false);
200199
}
201200

202201
@Override
@@ -215,14 +214,12 @@ public void preFetchPhase(SearchContext searchContext) {
215214
@Override
216215
public void fetchPhase(SearchContext searchContext, long tookInNanos) {
217216
long fetchStartTime = threadLocal.get().getOrDefault(FETCH_START_TIME, System.nanoTime());
218-
long fetchTime = (System.nanoTime() - fetchStartTime);
219-
double fetchTimeInMills = fetchTime / 1_000_000.0;
220-
217+
double fetchTimeInMills = tookInNanos / 1_000_000.0;
221218
searchLatencyHistogram.record(
222219
fetchTimeInMills, createTags(searchContext, SHARD_FETCH_PHASE, false));
223220

224221
addResourceTrackingCompletionListenerForFetchPhase(
225-
searchContext, fetchStartTime, fetchTime, SHARD_FETCH_PHASE, false);
222+
searchContext, fetchStartTime, tookInNanos, SHARD_FETCH_PHASE, false);
226223
}
227224

228225
@Override
@@ -291,11 +288,7 @@ protected void innerOnResponse(Task task) {
291288
* overall start time.
292289
*/
293290
long totalTime = System.nanoTime() - startTime;
294-
double totalTimeInMills = totalTime / 1_000_000.0;
295291
double shareFactor = computeShareFactor(phaseTookTime, totalTime);
296-
297-
searchLatencyHistogram.record(
298-
totalTimeInMills, createTags(searchContext, phase, isFailed));
299292
cpuUtilizationHistogram.record(
300293
Utils.calculateCPUUtilization(
301294
numProcessors,

src/test/java/org/opensearch/performanceanalyzer/listener/RTFPerformanceAnalyzerSearchListenerTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public void testTaskCompletionListener() {
174174
NotifyOnceListener<Task> taskCompletionListener =
175175
rtfSearchListener.createListener(searchContext, 0l, 0l, "test", false);
176176
taskCompletionListener.onResponse(task);
177-
Mockito.verify(searchLatencyHistogram).record(Mockito.anyDouble(), Mockito.any(Tags.class));
177+
178178
Mockito.verify(cpuUtilizationHistogram)
179179
.record(Mockito.anyDouble(), Mockito.any(Tags.class));
180180
Mockito.verify(heapUsedHistogram).record(Mockito.anyDouble(), Mockito.any(Tags.class));

0 commit comments

Comments
 (0)