Skip to content

Commit

Permalink
Change sink exporter to use the new metrics internal structs
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <[email protected]>
  • Loading branch information
bogdandrutu committed Aug 30, 2020
1 parent 7c315f9 commit 5e0a760
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion exporter/exportertest/sink_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
11 changes: 5 additions & 6 deletions exporter/exportertest/sink_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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())
Expand All @@ -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()))
Expand Down

0 comments on commit 5e0a760

Please sign in to comment.