From 3ea76e9e8292eb299c803d9710a2ebb235bbd64e Mon Sep 17 00:00:00 2001 From: rghetia Date: Fri, 31 May 2019 10:31:37 -0700 Subject: [PATCH] use container type resource instead of k8s type for resource transfomration. (#160) --- go.mod | 2 +- go.sum | 1 + metrics_proto_test.go | 6 +++--- resource.go | 2 +- resource_test.go | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index ef1ef43..c599c9d 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,7 @@ module contrib.go.opencensus.io/exporter/stackdriver require ( cloud.google.com/go v0.38.0 - contrib.go.opencensus.io/resource v0.1.0 + contrib.go.opencensus.io/resource v0.1.1 github.com/aws/aws-sdk-go v1.19.18 github.com/census-instrumentation/opencensus-proto v0.2.0 github.com/golang/protobuf v1.3.1 diff --git a/go.sum b/go.sum index ac6dc8d..cf6ff55 100644 --- a/go.sum +++ b/go.sum @@ -4,6 +4,7 @@ cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT cloud.google.com/go v0.38.0 h1:ROfEUZz+Gh5pa62DJWXSaonyu3StP6EA6lPEXPI6mCo= cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= contrib.go.opencensus.io/resource v0.1.0/go.mod h1:F361eGI91LCmW1I/Saf+rX0+OFcigGlFvXwEGEnkRLA= +contrib.go.opencensus.io/resource v0.1.1/go.mod h1:F361eGI91LCmW1I/Saf+rX0+OFcigGlFvXwEGEnkRLA= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/aws/aws-sdk-go v1.19.18 h1:Hb3+b9HCqrOrbAtFstUWg7H5TQ+/EcklJtE8VShVs8o= github.com/aws/aws-sdk-go v1.19.18/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= diff --git a/metrics_proto_test.go b/metrics_proto_test.go index 597ffe5..a8c3ca0 100644 --- a/metrics_proto_test.go +++ b/metrics_proto_test.go @@ -180,12 +180,12 @@ func TestProtoMetricWithDifferentResource(t *testing.T) { { in: &metricspb.Metric{ MetricDescriptor: &metricspb.MetricDescriptor{ - Name: "with_k8s_resource", + Name: "with_container_resource", Description: "This is a test", Unit: "By", }, Resource: &resourcepb.Resource{ - Type: resourcekeys.K8SType, + Type: resourcekeys.ContainerType, Labels: map[string]string{ resourcekeys.K8SKeyClusterName: "cluster1", resourcekeys.K8SKeyPodName: "pod1", @@ -217,7 +217,7 @@ func TestProtoMetricWithDifferentResource(t *testing.T) { TimeSeries: []*monitoringpb.TimeSeries{ { Metric: &googlemetricpb.Metric{ - Type: "custom.googleapis.com/opencensus/with_k8s_resource", + Type: "custom.googleapis.com/opencensus/with_container_resource", Labels: map[string]string{}, }, Resource: &monitoredrespb.MonitoredResource{ diff --git a/resource.go b/resource.go index 9b9d723..5e2fbce 100644 --- a/resource.go +++ b/resource.go @@ -90,7 +90,7 @@ func defaultMapResource(res *resource.Resource) *monitoredrespb.MonitoredResourc if res == nil || res.Labels == nil { return result } - if res.Type == resourcekeys.K8SType { + if res.Type == resourcekeys.ContainerType { result.Type = "k8s_container" match = k8sResourceMap } else if v, ok := res.Labels[resourcekeys.CloudKeyProvider]; ok { diff --git a/resource_test.go b/resource_test.go index c67de41..d99dfa5 100644 --- a/resource_test.go +++ b/resource_test.go @@ -33,7 +33,7 @@ func TestDefaultMapResource(t *testing.T) { // first mapping that doesn't apply. { input: &resource.Resource{ - Type: resourcekeys.K8SType, + Type: resourcekeys.ContainerType, Labels: map[string]string{ stackdriverProjectID: "proj1", resourcekeys.K8SKeyClusterName: "cluster1",