Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OTel C++] Add experimental optional locality label available to client per-attempt metrics #36254

Closed
wants to merge 19 commits into from

Conversation

yashykt
Copy link
Member

@yashykt yashykt commented Apr 4, 2024

As per grpc/proposal#419, the experimental optional label grpc.lb.locality is added to the follow per-call metrics -

  • grpc.client.attempt.duration
  • grpc.client.attempt.sent_total_compressed_message_size
  • grpc.client.attempt.rcvd_total_compressed_message_size

@yashykt yashykt requested a review from markdroth as a code owner April 4, 2024 02:17
@yashykt yashykt changed the title [OTel C++] Make optional locality label available to client per-attempt metrics [OTel C++] Add experimental optional locality label available to client per-attempt metrics Apr 4, 2024
@yashykt yashykt added the release notes: yes Indicates if PR needs to be in release notes label Apr 4, 2024
@yashykt yashykt requested a review from yijiem April 4, 2024 02:19
Copy link
Member

@markdroth markdroth left a comment

Choose a reason for hiding this comment

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

This looks like the right approach! There are a few noteworthy comments, though,

PLMK if you have any questions. Thanks!

src/core/ext/xds/xds_client_stats.h Outdated Show resolved Hide resolved
src/core/ext/xds/xds_cluster.h Outdated Show resolved Hide resolved
src/core/lib/channel/call_tracer.h Outdated Show resolved Hide resolved
src/core/lib/channel/call_tracer.h Outdated Show resolved Hide resolved
src/core/lib/channel/call_tracer.h Outdated Show resolved Hide resolved
src/cpp/ext/otel/otel_client_call_tracer.h Outdated Show resolved Hide resolved
src/cpp/ext/otel/otel_plugin.h Outdated Show resolved Hide resolved
src/cpp/ext/otel/key_value_iterable.h Outdated Show resolved Hide resolved
src/cpp/ext/otel/key_value_iterable.h Outdated Show resolved Hide resolved
test/cpp/ext/otel/otel_plugin_test.cc Show resolved Hide resolved
Copy link
Member

@markdroth markdroth left a comment

Choose a reason for hiding this comment

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

Only one really significant comment left, which is the one in xds_cluster_stats.h.

PLMK if you have any questions. Thanks!

src/core/lib/channel/call_tracer.h Outdated Show resolved Hide resolved
src/core/ext/xds/xds_client_stats.h Outdated Show resolved Hide resolved
src/core/resolver/xds/xds_dependency_manager.cc Outdated Show resolved Hide resolved
src/core/ext/xds/xds_cluster.h Outdated Show resolved Hide resolved
src/cpp/ext/otel/key_value_iterable.h Outdated Show resolved Hide resolved
src/cpp/ext/otel/key_value_iterable.h Outdated Show resolved Hide resolved
src/cpp/ext/otel/otel_plugin.h Outdated Show resolved Hide resolved
src/cpp/ext/otel/otel_plugin.h Show resolved Hide resolved
test/core/xds/xds_cluster_resource_type_test.cc Outdated Show resolved Hide resolved
test/core/xds/xds_cluster_resource_type_test.cc Outdated Show resolved Hide resolved
src/core/ext/xds/xds_client_stats.h Outdated Show resolved Hide resolved
src/core/load_balancing/xds/cds.cc Outdated Show resolved Hide resolved
src/core/ext/xds/xds_cluster.h Outdated Show resolved Hide resolved
Copy link
Member

@yijiem yijiem left a comment

Choose a reason for hiding this comment

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

Thanks Yash!

@@ -167,15 +167,15 @@ absl::Status XdsWrrLocalityLb::UpdateLocked(UpdateArgs args) {
}
auto config = args.config.TakeAsSubclass<XdsWrrLocalityLbConfig>();
// Scan the addresses to find the weight for each locality.
std::map<std::string, uint32_t> locality_weights;
std::map<RefCountedStringValue, uint32_t> locality_weights;
Copy link
Member

Choose a reason for hiding this comment

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

Does this needs to be std::map<RefCountedStringValue, uint32_t, RefCountedStringValueLessThan>?

Copy link
Member Author

Choose a reason for hiding this comment

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

Haven't gotten a complaint from the compiler, maybe because I'm just comparing it with other RefCountedStringValue. We can add it if needed.

Copy link
Member

Choose a reason for hiding this comment

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

We define operator<(RefCountedStringValue, RefCountredStringValue), so it shouldn't be necessary to use RefCountedStringValueLessThan unless we need heterogeneous lookups.

@@ -366,6 +365,17 @@ class OpenTelemetryPlugin : public grpc_core::StatsPlugin {
};

// StatsPlugin:
Copy link
Member

Choose a reason for hiding this comment

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

Maybe move this comment to line 379 which marks the start of the StatsPlugin's methods.

Copy link
Member Author

Choose a reason for hiding this comment

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

I see, I didn't realize what you meant by StatsPlugin's methods

Comment on lines +552 to +558
switch (key) {
case grpc_core::ClientCallTracer::CallAttemptTracer::OptionalLabelKey::
kLocality:
return kLocality;
default:
grpc_core::Crash("Illegal OptionalLabelKey index");
}
Copy link
Member

Choose a reason for hiding this comment

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

Since we only have one valid OptionalLabelKey that the user can set for now, we could also write it like:

  GPR_ASSERT(key ==
      grpc_core::ClientCallTracer::CallAttemptTracer::OptionalLabelKey::kLocality);
  return kLocality;

Copy link
Member Author

Choose a reason for hiding this comment

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

The current structure makes it easier to add new labels, and I think the compiler would be smart enough to optimize it.

Copy link
Member

@markdroth markdroth left a comment

Choose a reason for hiding this comment

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

Just one small remaining issue. Feel free to merge after addressing.

src/core/load_balancing/xds/xds_cluster_impl.cc Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants