Skip to content

Commit

Permalink
Merge branch 'main' into 0reviews/2024/08/05/albertzaharovits/trustst…
Browse files Browse the repository at this point in the history
…ore-must-be-jks-for-azure-ITs
  • Loading branch information
DaveCTurner committed Aug 5, 2024
2 parents b0c4a99 + e58678d commit 2547df7
Showing 1 changed file with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,13 @@ private void maybeRecordHttpRequestTime(Request<?> request) {
return;
}

final long totalTimeInMillis = getTotalTimeInMillis(requestTimesIncludingRetries);
if (totalTimeInMillis == 0) {
final long totalTimeInNanos = getTotalTimeInNanos(requestTimesIncludingRetries);
if (totalTimeInNanos == 0) {
logger.warn("Expected HttpRequestTime to be tracked for request [{}] but found no count.", request);
} else {
s3RepositoriesMetrics.common().httpRequestTimeInMillisHistogram().record(totalTimeInMillis, attributes);
s3RepositoriesMetrics.common()
.httpRequestTimeInMillisHistogram()
.record(TimeUnit.NANOSECONDS.toMillis(totalTimeInNanos), attributes);
}
}

Expand Down Expand Up @@ -271,19 +273,20 @@ private static long getCountForMetric(TimingInfo info, AWSRequestMetrics.Field f
}
}

private static long getTotalTimeInMillis(List<TimingInfo> requestTimesIncludingRetries) {
// Here we calculate the timing in Milliseconds for the sum of the individual subMeasurements with the goal of deriving the TTFB
// (time to first byte). We calculate the time in millis for later use with an APM style counter (exposed as a long), rather than
// using the default double exposed by getTimeTakenMillisIfKnown(). We don't need sub-millisecond precision. So no need perform
// the data type castings.
long totalTimeInMillis = 0;
private static long getTotalTimeInNanos(List<TimingInfo> requestTimesIncludingRetries) {
// Here we calculate the timing in Nanoseconds for the sum of the individual subMeasurements with the goal of deriving the TTFB
// (time to first byte). We use high precision time here to tell from the case when request time metric is missing (0).
// The time is converted to milliseconds for later use with an APM style counter (exposed as a long), rather than using the
// default double exposed by getTimeTakenMillisIfKnown().
// We don't need sub-millisecond precision. So no need perform the data type castings.
long totalTimeInNanos = 0;
for (TimingInfo timingInfo : requestTimesIncludingRetries) {
var endTimeInNanos = timingInfo.getEndTimeNanoIfKnown();
if (endTimeInNanos != null) {
totalTimeInMillis += TimeUnit.NANOSECONDS.toMillis(endTimeInNanos - timingInfo.getStartTimeNano());
totalTimeInNanos += endTimeInNanos - timingInfo.getStartTimeNano();
}
}
return totalTimeInMillis;
return totalTimeInNanos;
}

@Override
Expand Down

0 comments on commit 2547df7

Please sign in to comment.