Skip to content

channel pool metric prototype - #16324

Draft
scotthart wants to merge 3 commits into
googleapis:mainfrom
scotthart:bigtable_metric_channel_pool
Draft

channel pool metric prototype#16324
scotthart wants to merge 3 commits into
googleapis:mainfrom
scotthart:bigtable_metric_channel_pool

Conversation

@scotthart

Copy link
Copy Markdown
Member

No description provided.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces tracking for outstanding RPCs on selected channels within the Bigtable client's connection pool. It updates the BigtableStub interface and its decorators to accept an OperationContext parameter across all synchronous and asynchronous RPC methods. Additionally, it renames ResourceLabels and DataLabels to TableResourceLabels and TableDataLabels respectively, while introducing ClientResourceLabels and the OutstandingRpcs metric. Feedback on the changes suggests simplifying the label filtering logic in metrics.cc by replacing a complex std::set_difference call with a simpler loop, adhering to the repository's "Reject 'Code Poetry'" style guide principle.

Comment on lines +143 to +157
struct Compare {
bool operator()(std::pair<std::string const, std::string> const& a,
std::string const& b) {
return a.first < b;
}

bool operator()(std::string const& a,
std::pair<std::string const, std::string> const& b) {
return a < b.first;
}
};

std::set_difference(data.begin(), data.end(), filtered_data_labels.begin(),
filtered_data_labels.end(),
std::inserter(labels, labels.begin()), Compare());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Reject "Code Poetry": Simplify Label Filtering

The data map contains exactly 3 elements. Using std::set_difference with a custom Compare struct is overly complex for filtering such a small number of elements.

Per the repository style guide (Reject "Code Poetry"), we should prefer simplicity over cleverness. A simple loop checking if each key is in filtered_data_labels is much easier to read, maintain, and is likely more performant by avoiding the overhead of std::set_difference and custom comparators.

  for (auto const& kv : data) {
    if (filtered_data_labels.find(kv.first) == filtered_data_labels.end()) {
      labels.insert(kv);
    }
  }
References
  1. Reject "Code Poetry": Dismantle complex abstractions used for simple tasks. Prefer simplicity over cleverness. (link)

@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.07342% with 125 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.27%. Comparing base (9820e3d) to head (79de35f).
⚠️ Report is 17 commits behind head on main.

Files with missing lines Patch % Lines
...d/bigtable/tests/observability_integration_test.cc 3.75% 77 Missing ⚠️
...loud/bigtable/internal/bigtable_channel_refresh.cc 5.55% 17 Missing ⚠️
...oud/bigtable/internal/operation_context_factory.cc 88.97% 14 Missing ⚠️
google/cloud/bigtable/internal/metrics.cc 87.50% 10 Missing ⚠️
...oud/bigtable/internal/data_connection_impl_test.cc 97.69% 3 Missing ⚠️
...gle/cloud/bigtable/internal/dynamic_channel_pool.h 90.00% 2 Missing ⚠️
google/cloud/bigtable/internal/metrics.h 66.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16324      +/-   ##
==========================================
- Coverage   92.31%   92.27%   -0.05%     
==========================================
  Files        2226     2227       +1     
  Lines      208851   209264     +413     
==========================================
+ Hits       192796   193089     +293     
- Misses      16055    16175     +120     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant