-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
xds/internal/xdsclient: Process string metadata in CDS for com.google.csm.telemetry_labels #7085
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #7085 +/- ##
==========================================
- Coverage 82.54% 81.19% -1.36%
==========================================
Files 305 345 +40
Lines 31393 33940 +2547
==========================================
+ Hits 25913 27557 +1644
- Misses 4425 5212 +787
- Partials 1055 1171 +116
|
if fields := val.GetFields(); fields != nil { | ||
if val, ok := fields["service_name"]; ok { | ||
if _, isStringVal := val.GetKind().(*structpb.Value_StringValue); isStringVal { | ||
stringMD["service_name"] = val.GetStringValue() |
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 feels weird. We check the type of a thing, then call GetStringValue
on some other thing. Does GetStringValue
do something different if the Kind()
is not StringValue
?
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.
Yeah, this is the best solution that I could come up with. GetStringValue() returns a string, not a *string, so there is no way to distinguish between an empty string (a valid label value, which will be recorded) and an unset string (should eventually record method labels as "unknown" if unset). Thus, I don't set if not a string value (not set = "unknown" in OpenTelemetry component) and set it even if it's empty if it's present.
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 believe you can do:
if s, ok := val.AsInterface().(string); ok {
stringMD["service_name"] = s
}
But I'm not sure that that's much better.
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.
There's no function on the val called AsInterface() :/. Also, I think that typecast is wrong because it's a wrapper interface which happens to contain the value string. I.e. there's another layer (not 100% sure on this, but pretty sure).
This PR adds processing in CDS for string telemetry labels with filter_metadata string "com.google.csm.telemetry_labels". Other value types and filter_metadata identifiers are ignored. This also does not introduce NACK's. This is based off the C-Core implementation, which I disagree with technically but understand there were good reasons for the decisions made. See discussion in xDS Chat room for context as to why C-Core did it this way and why I followed it.
The relevant language in the CSM Observability Design is "The above key_value pairs from
com.google.csm.telemetry_labels
are going to be parsed by xDS Client from the CDS Resource and propagated to the watcher on this resource in the “cds” load balancing policy."RELEASE NOTES: N/A