Skip to content

Conversation

@sushanb
Copy link
Contributor

@sushanb sushanb commented Oct 17, 2025

expose a metric to track the number of outstanding rpcs (unary , streaming) in channel pool

@sushanb sushanb requested review from a team as code owners October 17, 2025 21:39
@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: bigtable Issues related to the googleapis/java-bigtable API. labels Oct 17, 2025
@sushanb sushanb added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 17, 2025
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 17, 2025
@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: m Pull request size is medium. labels Oct 20, 2025
@sushanb sushanb added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 22, 2025
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 22, 2025
@sushanb sushanb changed the title feat(bigtable): add bookkeeping per unary/streaming rpcs feat(bigtable): expose a metric to track the number of outstanding rpcs (unary , streaming) in channel pool Oct 22, 2025
@sushanb sushanb requested a review from mutianf October 22, 2025 19:06
import com.google.cloud.bigtable.data.v2.stub.metrics.ErrorCountPerConnectionMetricTracker;
import com.google.cloud.bigtable.data.v2.stub.metrics.MetricsProvider;
import com.google.cloud.bigtable.data.v2.stub.metrics.NoopMetricsProvider;
import com.google.cloud.bigtable.data.v2.stub.metrics.*;
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't want to import .*, can you revert this change? It's a setting in intellij: https://screenshot.googleplex.com/6XR4NrbcZ4RMuR3

import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import javax.annotation.Nullable;

Copy link
Contributor

Choose a reason for hiding this comment

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

Add the @InternalApi annotation

return; // Not registered yet
}
String lbPolicy = lbPolicyRef.get();
if (lbPolicy == null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

if the default is round robin maybe set the default value on line 39 when we define this variable? So we don't need to do this check every time.

@Override
public void run() {
BigtableChannelPoolObserver channelInsightsProvider = bigtableChannelInsightsProviderRef.get();
if (channelInsightsProvider == null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe log a warning?

lbPolicy = "ROUND_ROBIN";
}

// Build attributes if they haven't been built yet or were invalidated
Copy link
Contributor

Choose a reason for hiding this comment

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

when will they get invalidated?


@VisibleForTesting
boolean retain(boolean isStreaming) {
AtomicInteger counter = isStreaming ? outstandingStreamingRpcs : outstandingUnaryRpcs;
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if updating maxCounter should happen after the if statement? because the rpc is not actually sent on this channel so the max shouldn't be updated?


@Override
public int getOutstandingStreamingRpcs() {
return 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

return outstandingStreamingRpcs.get(); ?

And maybe add a test case? I'm a little concerned that this is not caught by any tests :)

InstantiatingGrpcChannelProvider instantiatingGrpcChannelProvider,
ChannelPrimer channelPrimer) {
ChannelPrimer channelPrimer,
OutstandingRpcsMetricTracker outstandingRpcsMetricTracker) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't love that we're passing this in the ctor.. but I guess there isn't a better way because we need to register channel inside provider and load balancing strategy? maybe the OutstandingRpcsMetricTracker can be a generic channel level metric tracker. And I wonder if the PerConnectionErrorCount metric can be part of it? So maybe rename OutstandingRpcsMetricTracker to something like ChannelMetricTracker?

@product-auto-label product-auto-label bot added size: xl Pull request size is extra large. and removed size: l Pull request size is large. labels Oct 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: bigtable Issues related to the googleapis/java-bigtable API. size: xl Pull request size is extra large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants