Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ public void outboundMessageSent(int seqNo, long optionalWireSize, long optionalU
tracer.grpcMessageSent();
}

@Override
public void outboundHeaders() {
tracer.grpcHeadersSent();
}

@Override
public void inboundHeaders() {
tracer.grpcHeadersReceived();
}

static class Factory extends ClientStreamTracer.Factory {

private final BigtableTracer tracer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class BuiltinMetricsTracer extends BigtableTracer {
private volatile Duration remainingDeadlineAtAttemptStart = Duration.ZERO;

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

BuiltinMetricsTracer(
MetricRegistry.RecorderRegistry recorder, ClientInfo clientInfo, MethodInfo methodInfo) {
Expand Down Expand Up @@ -263,6 +264,16 @@ public void grpcMessageSent() {
grpcMessageSentDelay.set(attemptTimer.elapsed(TimeUnit.NANOSECONDS));
}

@Override
public void grpcHeadersSent() {
faket4t7 = Optional.of(Stopwatch.createStarted());
}

@Override
public void grpcHeadersReceived() {
faket4t7.ifPresent(Stopwatch::stop);
}

@Override
public void setTotalTimeoutDuration(java.time.Duration totalTimeoutDuration) {
// This method is called by BigtableTracerStreamingCallable and
Expand Down Expand Up @@ -386,7 +397,8 @@ private void recordAttemptCompletion(@Nullable Throwable throwable) {
code,
Comparators.max(remainingDeadlineAtAttemptStart, Duration.ZERO));
}

// if we don't have t4t7 latency from gfe, we use dur between initial metadata sent and initial
// metadata recv
if (sidebandData.getGfeTiming() != null) {
recorder.serverLatency.record(
clientInfo,
Expand All @@ -395,6 +407,16 @@ private void recordAttemptCompletion(@Nullable Throwable throwable) {
sidebandData.getClusterInfo(),
code,
sidebandData.getGfeTiming());
} else {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is expanding scope to what we talked about. This was supposed to be only for DirectAccess. This implementation expands the scope to any time the header is missing. Which means that we wont be able to tell what we are actually measuring. In our original conversation scoping it only to DA, we could reason that when transport_type is DA, we measuring client headers until response headers. In all other cases we are measuring gfe latency. And if the DistributionCount() drops we know that we couldnt reach a gfe. With this approach, we muddy our ability to reason about the metric

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we have connectivity error count for measuring that particular usecase you are talking about?

faket4t7.ifPresent(
stopwatch ->
recorder.serverLatency.record(
clientInfo,
tableId,
methodInfo,
sidebandData.getClusterInfo(),
code,
stopwatch.elapsed()));
}

boolean seenServer =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,20 @@ public void grpcMessageSent() {
}
}

@Override
public void grpcHeadersSent() {
for (BigtableTracer tracer : bigtableTracers) {
tracer.grpcHeadersSent();
}
}

@Override
public void grpcHeadersReceived() {
for (BigtableTracer tracer : bigtableTracers) {
tracer.grpcHeadersReceived();
}
}

@Override
public void setTotalTimeoutDuration(java.time.Duration totalTimeoutDuration) {
for (BigtableTracer tracer : bigtableTracers) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ public void grpcMessageSent() {
// noop
}

/** Called when the header is sent on a grpc channel. */
public void grpcHeadersSent() {
// noop
}

/** Called when the header is received on a grpc channel. */
public void grpcHeadersReceived() {
// noop
}

/**
* Record the operation timeout from user settings for calculating remaining deadline. Currently,
* it's called in BuiltinMetricsTracer on attempt start from {@link BigtableTracerUnaryCallable}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,4 +271,18 @@ public void testGrpcMessageSent() {
verify(child3, times(1)).grpcMessageSent();
verify(child4, times(1)).grpcMessageSent();
}

@Test
public void testGrpcHeadersSent() {
compositeTracer.grpcHeadersSent();
verify(child3, times(1)).grpcHeadersSent();
verify(child4, times(1)).grpcHeadersSent();
}

@Test
public void testGrpcHeadersReceived() {
compositeTracer.grpcHeadersReceived();
verify(child3, times(1)).grpcHeadersReceived();
verify(child4, times(1)).grpcHeadersReceived();
}
}
Loading