Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change processor tests to use the new metrics internal structs #1680

Merged
merged 1 commit into from
Aug 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions processor/cloningfanoutconnector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"go.opentelemetry.io/collector/consumer/pdatautil"
"go.opentelemetry.io/collector/exporter/exportertest"
"go.opentelemetry.io/collector/internal/data/testdata"
"go.opentelemetry.io/collector/internal/dataold/testdataold"
)

func TestTraceProcessorCloningNotMultiplexing(t *testing.T) {
Expand Down Expand Up @@ -83,12 +82,12 @@ func TestMetricsProcessorCloningMultiplexing(t *testing.T) {
}

mfc := NewMetricsCloningFanOutConnector(processors)
md := testdataold.GenerateMetricDataWithCountersHistogramAndSummary()
md := testdata.GenerateMetricsWithCountersHistograms()

var wantMetricsCount = 0
for i := 0; i < 2; i++ {
wantMetricsCount += md.MetricCount()
err := mfc.ConsumeMetrics(context.Background(), pdatautil.MetricsFromOldInternalMetrics(md))
err := mfc.ConsumeMetrics(context.Background(), pdatautil.MetricsFromInternalMetrics(md))
if err != nil {
t.Errorf("Wanted nil got error")
return
Expand All @@ -100,15 +99,15 @@ func TestMetricsProcessorCloningMultiplexing(t *testing.T) {
assert.Equal(t, wantMetricsCount, m.MetricsCount())
metricOrig := md.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(0)
allMetrics := m.AllMetrics()
metricClone := pdatautil.MetricsToOldInternalMetrics(allMetrics[0]).ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(0)
metricClone := pdatautil.MetricsToInternalMetrics(allMetrics[0]).ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(0)
if i < len(processors)-1 {
assert.True(t, md.ResourceMetrics().At(0).Resource() != pdatautil.MetricsToOldInternalMetrics(allMetrics[0]).ResourceMetrics().At(0).Resource())
assert.True(t, md.ResourceMetrics().At(0).Resource() != pdatautil.MetricsToInternalMetrics(allMetrics[0]).ResourceMetrics().At(0).Resource())
assert.True(t, metricOrig != metricClone)
} else {
assert.True(t, md.ResourceMetrics().At(0).Resource() == pdatautil.MetricsToOldInternalMetrics(allMetrics[0]).ResourceMetrics().At(0).Resource())
assert.True(t, md.ResourceMetrics().At(0).Resource() == pdatautil.MetricsToInternalMetrics(allMetrics[0]).ResourceMetrics().At(0).Resource())
assert.True(t, metricOrig == metricClone)
}
assert.EqualValues(t, md.ResourceMetrics().At(0).Resource(), pdatautil.MetricsToOldInternalMetrics(allMetrics[0]).ResourceMetrics().At(0).Resource())
assert.EqualValues(t, md.ResourceMetrics().At(0).Resource(), pdatautil.MetricsToInternalMetrics(allMetrics[0]).ResourceMetrics().At(0).Resource())
assert.EqualValues(t, metricOrig, metricClone)
}
}
Expand Down
11 changes: 5 additions & 6 deletions processor/fanoutconnector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"go.opentelemetry.io/collector/consumer/pdatautil"
"go.opentelemetry.io/collector/exporter/exportertest"
"go.opentelemetry.io/collector/internal/data/testdata"
"go.opentelemetry.io/collector/internal/dataold/testdataold"
)

func TestTracesProcessorNotMultiplexing(t *testing.T) {
Expand Down Expand Up @@ -100,12 +99,12 @@ func TestMetricsProcessorMultiplexing(t *testing.T) {
}

mfc := NewMetricsFanOutConnector(processors)
md := testdataold.GenerateMetricDataOneMetric()
md := testdata.GenerateMetricsOneMetric()

var wantMetricsCount = 0
for i := 0; i < 2; i++ {
wantMetricsCount += md.MetricCount()
err := mfc.ConsumeMetrics(context.Background(), pdatautil.MetricsFromOldInternalMetrics(md))
err := mfc.ConsumeMetrics(context.Background(), pdatautil.MetricsFromInternalMetrics(md))
if err != nil {
t.Errorf("Wanted nil got error")
return
Expand All @@ -115,7 +114,7 @@ func TestMetricsProcessorMultiplexing(t *testing.T) {
for _, p := range processors {
m := p.(*exportertest.SinkMetricsExporter)
assert.Equal(t, wantMetricsCount, m.MetricsCount())
assert.EqualValues(t, md, pdatautil.MetricsToOldInternalMetrics(m.AllMetrics()[0]))
assert.EqualValues(t, md, pdatautil.MetricsToInternalMetrics(m.AllMetrics()[0]))
}
}

Expand All @@ -129,12 +128,12 @@ func TestMetricsProcessorWhenOneErrors(t *testing.T) {
processors[1].(*exportertest.SinkMetricsExporter).SetConsumeMetricsError(errors.New("my_error"))

mfc := NewMetricsFanOutConnector(processors)
md := testdataold.GenerateMetricDataOneMetric()
md := testdata.GenerateMetricsOneMetric()

var wantMetricsCount = 0
for i := 0; i < 2; i++ {
wantMetricsCount += md.MetricCount()
err := mfc.ConsumeMetrics(context.Background(), pdatautil.MetricsFromOldInternalMetrics(md))
err := mfc.ConsumeMetrics(context.Background(), pdatautil.MetricsFromInternalMetrics(md))
if err == nil {
t.Errorf("Wanted error got nil")
return
Expand Down