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
Conversation
There was a problem hiding this 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!
There was a problem hiding this 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!
There was a problem hiding this 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; |
There was a problem hiding this comment.
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>
?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
src/cpp/ext/otel/otel_plugin.h
Outdated
@@ -366,6 +365,17 @@ class OpenTelemetryPlugin : public grpc_core::StatsPlugin { | |||
}; | |||
|
|||
// StatsPlugin: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
switch (key) { | ||
case grpc_core::ClientCallTracer::CallAttemptTracer::OptionalLabelKey:: | ||
kLocality: | ||
return kLocality; | ||
default: | ||
grpc_core::Crash("Illegal OptionalLabelKey index"); | ||
} |
There was a problem hiding this comment.
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;
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
As per grpc/proposal#419, the experimental optional label
grpc.lb.locality
is added to the follow per-call metrics -