Skip to content

Commit

Permalink
Change resource processor to use the new metrics internal structs
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
  • Loading branch information
bogdandrutu committed Aug 30, 2020
1 parent 52c9e7f commit ba845e2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions processor/resourceprocessor/resource_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (rp *resourceProcessor) ProcessTraces(_ context.Context, td pdata.Traces) (

// ProcessMetrics implements the MProcessor interface
func (rp *resourceProcessor) ProcessMetrics(_ context.Context, md pdata.Metrics) (pdata.Metrics, error) {
imd := pdatautil.MetricsToOldInternalMetrics(md)
imd := pdatautil.MetricsToInternalMetrics(md)
rms := imd.ResourceMetrics()
for i := 0; i < rms.Len(); i++ {
resource := rms.At(i).Resource()
Expand All @@ -54,5 +54,5 @@ func (rp *resourceProcessor) ProcessMetrics(_ context.Context, md pdata.Metrics)
}
rp.attrProc.Process(resource.Attributes())
}
return pdatautil.MetricsFromOldInternalMetrics(imd), nil
return pdatautil.MetricsFromInternalMetrics(imd), nil
}
9 changes: 4 additions & 5 deletions processor/resourceprocessor/resource_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"go.opentelemetry.io/collector/consumer/pdata"
"go.opentelemetry.io/collector/consumer/pdatautil"
"go.opentelemetry.io/collector/internal/data/testdata"
"go.opentelemetry.io/collector/internal/dataold/testdataold"
"go.opentelemetry.io/collector/processor/processorhelper"
)

Expand Down Expand Up @@ -147,17 +146,17 @@ func generateTraceData(attributes map[string]string) pdata.Traces {
}

func generateMetricData(attributes map[string]string) pdata.Metrics {
md := testdataold.GenerateMetricDataOneMetricNoResource()
md := testdata.GenerateMetricsOneMetricNoResource()
if attributes == nil {
return pdatautil.MetricsFromOldInternalMetrics(md)
return pdatautil.MetricsFromInternalMetrics(md)
}
resource := md.ResourceMetrics().At(0).Resource()
resource.InitEmpty()
for k, v := range attributes {
resource.Attributes().InsertString(k, v)
}
resource.Attributes().Sort()
return pdatautil.MetricsFromOldInternalMetrics(md)
return pdatautil.MetricsFromInternalMetrics(md)
}

type testTraceConsumer struct {
Expand All @@ -179,7 +178,7 @@ type testMetricsConsumer struct {

func (tmn *testMetricsConsumer) ConsumeMetrics(_ context.Context, md pdata.Metrics) error {
// sort attributes to be able to compare traces
imd := pdatautil.MetricsToOldInternalMetrics(md)
imd := pdatautil.MetricsToInternalMetrics(md)
for i := 0; i < imd.ResourceMetrics().Len(); i++ {
sortResourceAttributes(imd.ResourceMetrics().At(i).Resource())
}
Expand Down

0 comments on commit ba845e2

Please sign in to comment.