From 474f475be2ba5c2149a6c9e504a642e03b2e43bd Mon Sep 17 00:00:00 2001 From: Bogdan Drutu Date: Sun, 30 Aug 2020 21:56:50 -0700 Subject: [PATCH] Change sink exporter to use the new metrics internal structs (#1678) Signed-off-by: Bogdan Drutu --- exporter/exportertest/sink_exporter.go | 2 +- exporter/exportertest/sink_exporter_test.go | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/exporter/exportertest/sink_exporter.go b/exporter/exportertest/sink_exporter.go index 45e1751f1ac..4eff3c32c6a 100644 --- a/exporter/exportertest/sink_exporter.go +++ b/exporter/exportertest/sink_exporter.go @@ -123,7 +123,7 @@ func (sme *SinkMetricsExporter) ConsumeMetrics(_ context.Context, md pdata.Metri } sme.metrics = append(sme.metrics, md) - sme.metricsCount += pdatautil.MetricsToOldInternalMetrics(md).MetricCount() + sme.metricsCount += pdatautil.MetricCount(md) return nil } diff --git a/exporter/exportertest/sink_exporter_test.go b/exporter/exportertest/sink_exporter_test.go index b3006dcbb64..4c022ff8b9a 100644 --- a/exporter/exportertest/sink_exporter_test.go +++ b/exporter/exportertest/sink_exporter_test.go @@ -25,7 +25,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" ) func TestSinkTraceExporter(t *testing.T) { @@ -59,11 +58,11 @@ func TestSinkTraceExporter_Error(t *testing.T) { func TestSinkMetricsExporter(t *testing.T) { sink := new(SinkMetricsExporter) require.NoError(t, sink.Start(context.Background(), componenttest.NewNopHost())) - md := testdataold.GenerateMetricDataOneMetric() + md := testdata.GenerateMetricsOneMetric() want := make([]pdata.Metrics, 0, 7) for i := 0; i < 7; i++ { - require.NoError(t, sink.ConsumeMetrics(context.Background(), pdatautil.MetricsFromOldInternalMetrics(md))) - want = append(want, pdatautil.MetricsFromOldInternalMetrics(md)) + require.NoError(t, sink.ConsumeMetrics(context.Background(), pdatautil.MetricsFromInternalMetrics(md))) + want = append(want, pdatautil.MetricsFromInternalMetrics(md)) } assert.Equal(t, want, sink.AllMetrics()) assert.Equal(t, len(want), sink.MetricsCount()) @@ -77,8 +76,8 @@ func TestSinkMetricsExporter_Error(t *testing.T) { sink := new(SinkMetricsExporter) require.NoError(t, sink.Start(context.Background(), componenttest.NewNopHost())) sink.SetConsumeMetricsError(errors.New("my error")) - md := testdataold.GenerateMetricDataOneMetric() - require.Error(t, sink.ConsumeMetrics(context.Background(), pdatautil.MetricsFromOldInternalMetrics(md))) + md := testdata.GenerateMetricsOneMetric() + require.Error(t, sink.ConsumeMetrics(context.Background(), pdatautil.MetricsFromInternalMetrics(md))) assert.Len(t, sink.AllMetrics(), 0) assert.Equal(t, 0, sink.MetricsCount()) require.NoError(t, sink.Shutdown(context.Background()))