Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

Commit

Permalink
Copy resources when converting summary metrics. (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
rghetia committed Jun 3, 2019
1 parent 3ea76e9 commit 68e3d74
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions metrics_proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ func (se *statsExporter) convertSummaryMetrics(summary *metricspb.Metric) []*met
LabelKeys: summary.GetMetricDescriptor().GetLabelKeys(),
},
Timeseries: sumTss,
Resource: summary.Resource,
}
metrics = append(metrics, metric)
}
Expand All @@ -182,6 +183,7 @@ func (se *statsExporter) convertSummaryMetrics(summary *metricspb.Metric) []*met
LabelKeys: summary.GetMetricDescriptor().GetLabelKeys(),
},
Timeseries: countTss,
Resource: summary.Resource,
}
metrics = append(metrics, metric)
}
Expand All @@ -197,6 +199,7 @@ func (se *statsExporter) convertSummaryMetrics(summary *metricspb.Metric) []*met
LabelKeys: lks,
},
Timeseries: percentileTss,
Resource: summary.Resource,
}
metrics = append(metrics, metric)
}
Expand Down
12 changes: 12 additions & 0 deletions metrics_proto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,14 @@ func TestConvertSummaryMetrics(t *testing.T) {
Nanos: 100000997,
}

res := &resourcepb.Resource{
Type: resourcekeys.ContainerType,
Labels: map[string]string{
resourcekeys.ContainerKeyName: "container1",
resourcekeys.K8SKeyClusterName: "cluster1",
},
}

tests := []struct {
in *metricspb.Metric
want []*metricspb.Metric
Expand Down Expand Up @@ -702,6 +710,7 @@ func TestConvertSummaryMetrics(t *testing.T) {
},
},
},
Resource: res,
},
statsExporter: &statsExporter{
o: Options{ProjectID: "foo"},
Expand All @@ -717,6 +726,7 @@ func TestConvertSummaryMetrics(t *testing.T) {
Timeseries: []*metricspb.TimeSeries{
makeDoubleTs(119.0, "", startTimestamp, endTimestamp),
},
Resource: res,
},
{
MetricDescriptor: &metricspb.MetricDescriptor{
Expand All @@ -728,6 +738,7 @@ func TestConvertSummaryMetrics(t *testing.T) {
Timeseries: []*metricspb.TimeSeries{
makeInt64Ts(10, "", startTimestamp, endTimestamp),
},
Resource: res,
},
{
MetricDescriptor: &metricspb.MetricDescriptor{
Expand All @@ -745,6 +756,7 @@ func TestConvertSummaryMetrics(t *testing.T) {
makeDoubleTs(12.6, "90.000000", nil, endTimestamp),
makeDoubleTs(19.6, "99.000000", nil, endTimestamp),
},
Resource: res,
},
},
},
Expand Down

0 comments on commit 68e3d74

Please sign in to comment.