Skip to content

Commit dcc290c

Browse files
committed
Responded to Doug's comments
1 parent 20092f4 commit dcc290c

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

xds/internal/xdsclient/xdsresource/type_cds.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ type ClusterUpdate struct {
8585

8686
// Raw is the resource from the xds response.
8787
Raw *anypb.Any
88-
// All the string valued metadata of filter_metadata type
89-
// "com.google.csm.telemetry_labels".
90-
StringMD map[string]string
88+
// TelemetryLabels are the string valued metadata of filter_metadata type
89+
// "com.google.csm.telemetry_labels" with keys "service_name" or
90+
// "service_namespace".
91+
TelemetryLabels map[string]string
9192
}

xds/internal/xdsclient/xdsresource/unmarshal_cds.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,22 +82,18 @@ const (
8282
)
8383

8484
func validateClusterAndConstructClusterUpdate(cluster *v3clusterpb.Cluster) (ClusterUpdate, error) {
85-
stringMD := make(map[string]string)
85+
telemetryLabels := make(map[string]string)
8686
if fmd := cluster.GetMetadata().GetFilterMetadata(); fmd != nil {
8787
if val, ok := fmd["com.google.csm.telemetry_labels"]; ok {
88-
/*
89-
"service_name" = "",
90-
"service_namespace" = ""
91-
*/
9288
if fields := val.GetFields(); fields != nil {
9389
if val, ok := fields["service_name"]; ok {
94-
if _, isStringVal := val.GetKind().(*structpb.Value_StringValue); isStringVal {
95-
stringMD["service_name"] = val.GetStringValue()
90+
if _, ok := val.GetKind().(*structpb.Value_StringValue); ok {
91+
telemetryLabels["service_name"] = val.GetStringValue()
9692
}
9793
}
9894
if val, ok := fields["service_namespace"]; ok {
99-
if _, isStringVal := val.GetKind().(*structpb.Value_StringValue); isStringVal {
100-
stringMD["service_namespace"] = val.GetStringValue()
95+
if _, ok := val.GetKind().(*structpb.Value_StringValue); ok {
96+
telemetryLabels["service_namespace"] = val.GetStringValue()
10197
}
10298
}
10399
}
@@ -183,7 +179,7 @@ func validateClusterAndConstructClusterUpdate(cluster *v3clusterpb.Cluster) (Clu
183179
MaxRequests: circuitBreakersFromCluster(cluster),
184180
LBPolicy: lbPolicy,
185181
OutlierDetection: od,
186-
StringMD: stringMD,
182+
TelemetryLabels: telemetryLabels,
187183
}
188184

189185
// Note that this is different from the gRFC (gRFC A47 says to include the

xds/internal/xdsclient/xdsresource/unmarshal_cds_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,7 +1375,7 @@ func (s) TestUnmarshalCluster(t *testing.T) {
13751375
EDSServiceName: v3Service,
13761376
LRSServerConfig: ClusterLRSServerSelf,
13771377
Raw: v3ClusterAnyWithTelemetryLabels,
1378-
StringMD: map[string]string{
1378+
TelemetryLabels: map[string]string{
13791379
"service_name": "grpc-service",
13801380
"service_namespace": "grpc-service-namespace",
13811381
},
@@ -1390,7 +1390,7 @@ func (s) TestUnmarshalCluster(t *testing.T) {
13901390
EDSServiceName: v3Service,
13911391
LRSServerConfig: ClusterLRSServerSelf,
13921392
Raw: v3ClusterAnyWithTelemetryLabelsIgnoreSome,
1393-
StringMD: map[string]string{
1393+
TelemetryLabels: map[string]string{
13941394
"service_name": "grpc-service",
13951395
},
13961396
},

0 commit comments

Comments
 (0)