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

Commit 68e3d74

Browse files
authored
Copy resources when converting summary metrics. (#162)
1 parent 3ea76e9 commit 68e3d74

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

metrics_proto.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ func (se *statsExporter) convertSummaryMetrics(summary *metricspb.Metric) []*met
169169
LabelKeys: summary.GetMetricDescriptor().GetLabelKeys(),
170170
},
171171
Timeseries: sumTss,
172+
Resource: summary.Resource,
172173
}
173174
metrics = append(metrics, metric)
174175
}
@@ -182,6 +183,7 @@ func (se *statsExporter) convertSummaryMetrics(summary *metricspb.Metric) []*met
182183
LabelKeys: summary.GetMetricDescriptor().GetLabelKeys(),
183184
},
184185
Timeseries: countTss,
186+
Resource: summary.Resource,
185187
}
186188
metrics = append(metrics, metric)
187189
}
@@ -197,6 +199,7 @@ func (se *statsExporter) convertSummaryMetrics(summary *metricspb.Metric) []*met
197199
LabelKeys: lks,
198200
},
199201
Timeseries: percentileTss,
202+
Resource: summary.Resource,
200203
}
201204
metrics = append(metrics, metric)
202205
}

metrics_proto_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,14 @@ func TestConvertSummaryMetrics(t *testing.T) {
665665
Nanos: 100000997,
666666
}
667667

668+
res := &resourcepb.Resource{
669+
Type: resourcekeys.ContainerType,
670+
Labels: map[string]string{
671+
resourcekeys.ContainerKeyName: "container1",
672+
resourcekeys.K8SKeyClusterName: "cluster1",
673+
},
674+
}
675+
668676
tests := []struct {
669677
in *metricspb.Metric
670678
want []*metricspb.Metric
@@ -702,6 +710,7 @@ func TestConvertSummaryMetrics(t *testing.T) {
702710
},
703711
},
704712
},
713+
Resource: res,
705714
},
706715
statsExporter: &statsExporter{
707716
o: Options{ProjectID: "foo"},
@@ -717,6 +726,7 @@ func TestConvertSummaryMetrics(t *testing.T) {
717726
Timeseries: []*metricspb.TimeSeries{
718727
makeDoubleTs(119.0, "", startTimestamp, endTimestamp),
719728
},
729+
Resource: res,
720730
},
721731
{
722732
MetricDescriptor: &metricspb.MetricDescriptor{
@@ -728,6 +738,7 @@ func TestConvertSummaryMetrics(t *testing.T) {
728738
Timeseries: []*metricspb.TimeSeries{
729739
makeInt64Ts(10, "", startTimestamp, endTimestamp),
730740
},
741+
Resource: res,
731742
},
732743
{
733744
MetricDescriptor: &metricspb.MetricDescriptor{
@@ -745,6 +756,7 @@ func TestConvertSummaryMetrics(t *testing.T) {
745756
makeDoubleTs(12.6, "90.000000", nil, endTimestamp),
746757
makeDoubleTs(19.6, "99.000000", nil, endTimestamp),
747758
},
759+
Resource: res,
748760
},
749761
},
750762
},

0 commit comments

Comments
 (0)