Skip to content
This repository was archived by the owner on May 8, 2026. It is now read-only.

Commit b126bed

Browse files
committed
fix
1 parent 0399eb1 commit b126bed

1 file changed

Lines changed: 12 additions & 17 deletions

File tree

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/internal/csm/tracers/BuiltinMetricsTracer.java

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,12 @@ class BuiltinMetricsTracer extends BigtableTracer {
8282
private final AtomicLong totalClientBlockingTime = new AtomicLong(0);
8383

8484
private final AtomicLong grpcMessageSentDelay = new AtomicLong(0);
85-
private final AtomicLong grpcHeadersSentNanos = new AtomicLong(0);
86-
private final AtomicLong grpcHeadersOutHeaderInLatency = new AtomicLong(0);
8785

8886
private Deadline operationDeadline = null;
8987
private volatile Duration remainingDeadlineAtAttemptStart = Duration.ZERO;
9088

9189
private volatile MetadataExtractorInterceptor.SidebandData sidebandData = new SidebandData();
90+
private volatile Optional<Stopwatch> faket4t7 = Optional.empty();
9291

9392
BuiltinMetricsTracer(
9493
MetricRegistry.RecorderRegistry recorder, ClientInfo clientInfo, MethodInfo methodInfo) {
@@ -267,14 +266,12 @@ public void grpcMessageSent() {
267266

268267
@Override
269268
public void grpcHeadersSent() {
270-
grpcHeadersSentNanos.set(attemptTimer.elapsed(TimeUnit.NANOSECONDS));
269+
faket4t7 = Optional.of(Stopwatch.createStarted());
271270
}
272271

273272
@Override
274273
public void grpcHeadersReceived() {
275-
long receivedNanos = attemptTimer.elapsed(TimeUnit.NANOSECONDS);
276-
long sentNanos = grpcHeadersSentNanos.get();
277-
grpcHeadersOutHeaderInLatency.set(receivedNanos - sentNanos);
274+
faket4t7.map(Stopwatch::stop);
278275
}
279276

280277
@Override
@@ -411,17 +408,15 @@ private void recordAttemptCompletion(@Nullable Throwable throwable) {
411408
code,
412409
sidebandData.getGfeTiming());
413410
} else {
414-
// Fallback to header latency if GFE timing is not available
415-
long fallbackLatencyNanos = grpcHeadersOutHeaderInLatency.get();
416-
if (fallbackLatencyNanos > 0) {
417-
recorder.serverLatency.record(
418-
clientInfo,
419-
tableId,
420-
methodInfo,
421-
sidebandData.getClusterInfo(),
422-
code,
423-
Duration.ofNanos(fallbackLatencyNanos));
424-
}
411+
faket4t7.ifPresent(
412+
stopwatch ->
413+
recorder.serverLatency.record(
414+
clientInfo,
415+
tableId,
416+
methodInfo,
417+
sidebandData.getClusterInfo(),
418+
code,
419+
stopwatch.elapsed()));
425420
}
426421

427422
boolean seenServer =

0 commit comments

Comments
 (0)