From e7edb006e63f82bbc87b5e31a392236ac4ead0c2 Mon Sep 17 00:00:00 2001 From: Bogdan Drutu Date: Mon, 5 Dec 2022 11:13:28 -0800 Subject: [PATCH] Deprecate obsreporttest.Check* in favor of TestTelemetry.Check (#6678) Signed-off-by: Bogdan Drutu --- .chloggen/deprecatechecks.yaml | 11 +++ exporter/exporterhelper/logs_test.go | 4 +- exporter/exporterhelper/metrics_test.go | 4 +- exporter/exporterhelper/traces_test.go | 4 +- obsreport/obsreport_test.go | 18 ++-- obsreport/obsreporttest/obsreporttest.go | 81 ++++++++++++---- obsreport/obsreporttest/obsreporttest_test.go | 96 +++++++++---------- receiver/otlpreceiver/otlp_test.go | 2 +- .../scraperhelper/scrapercontroller_test.go | 2 +- 9 files changed, 139 insertions(+), 83 deletions(-) create mode 100755 .chloggen/deprecatechecks.yaml diff --git a/.chloggen/deprecatechecks.yaml b/.chloggen/deprecatechecks.yaml new file mode 100755 index 000000000000..eaeadf8f4edd --- /dev/null +++ b/.chloggen/deprecatechecks.yaml @@ -0,0 +1,11 @@ +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: deprecation + +# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver) +component: obsreporttest + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Deprecate obsreporttest.Check* in favor of TestTelemetry.Check + +# One or more tracking issues or pull requests related to the change +issues: [6678] diff --git a/exporter/exporterhelper/logs_test.go b/exporter/exporterhelper/logs_test.go index 717825e47929..f85e83073362 100644 --- a/exporter/exporterhelper/logs_test.go +++ b/exporter/exporterhelper/logs_test.go @@ -221,9 +221,9 @@ func checkRecordedMetricsForLogsExporter(t *testing.T, tt obsreporttest.TestTele // TODO: When the new metrics correctly count partial dropped fix this. if wantError != nil { - require.NoError(t, obsreporttest.CheckExporterLogs(tt, fakeLogsExporterName, 0, int64(numBatches*ld.LogRecordCount()))) + require.NoError(t, tt.CheckExporterLogs(0, int64(numBatches*ld.LogRecordCount()))) } else { - require.NoError(t, obsreporttest.CheckExporterLogs(tt, fakeLogsExporterName, int64(numBatches*ld.LogRecordCount()), 0)) + require.NoError(t, tt.CheckExporterLogs(int64(numBatches*ld.LogRecordCount()), 0)) } } diff --git a/exporter/exporterhelper/metrics_test.go b/exporter/exporterhelper/metrics_test.go index 5c7d61a2db24..831ace6a1507 100644 --- a/exporter/exporterhelper/metrics_test.go +++ b/exporter/exporterhelper/metrics_test.go @@ -223,9 +223,9 @@ func checkRecordedMetricsForMetricsExporter(t *testing.T, tt obsreporttest.TestT // TODO: When the new metrics correctly count partial dropped fix this. numPoints := int64(numBatches * md.MetricCount() * 2) /* 2 points per metric*/ if wantError != nil { - require.NoError(t, obsreporttest.CheckExporterMetrics(tt, fakeMetricsExporterName, 0, numPoints)) + require.NoError(t, tt.CheckExporterMetrics(0, numPoints)) } else { - require.NoError(t, obsreporttest.CheckExporterMetrics(tt, fakeMetricsExporterName, numPoints, 0)) + require.NoError(t, tt.CheckExporterMetrics(numPoints, 0)) } } diff --git a/exporter/exporterhelper/traces_test.go b/exporter/exporterhelper/traces_test.go index 1860fc094526..8c3e3ecb4a94 100644 --- a/exporter/exporterhelper/traces_test.go +++ b/exporter/exporterhelper/traces_test.go @@ -222,9 +222,9 @@ func checkRecordedMetricsForTracesExporter(t *testing.T, tt obsreporttest.TestTe // TODO: When the new metrics correctly count partial dropped fix this. if wantError != nil { - require.NoError(t, obsreporttest.CheckExporterTraces(tt, fakeTracesExporterName, 0, int64(numBatches*td.SpanCount()))) + require.NoError(t, tt.CheckExporterTraces(0, int64(numBatches*td.SpanCount()))) } else { - require.NoError(t, obsreporttest.CheckExporterTraces(tt, fakeTracesExporterName, int64(numBatches*td.SpanCount()), 0)) + require.NoError(t, tt.CheckExporterTraces(int64(numBatches*td.SpanCount()), 0)) } } diff --git a/obsreport/obsreport_test.go b/obsreport/obsreport_test.go index da026487f201..1c62b73c7eee 100644 --- a/obsreport/obsreport_test.go +++ b/obsreport/obsreport_test.go @@ -117,7 +117,7 @@ func TestReceiveTraceDataOp(t *testing.T) { t.Fatalf("unexpected param: %v", params[i]) } } - require.NoError(t, obsreporttest.CheckReceiverTraces(tt, receiver, transport, int64(acceptedSpans), int64(refusedSpans))) + require.NoError(t, tt.CheckReceiverTraces(transport, int64(acceptedSpans), int64(refusedSpans))) }) } @@ -165,7 +165,7 @@ func TestReceiveLogsOp(t *testing.T) { t.Fatalf("unexpected param: %v", params[i]) } } - require.NoError(t, obsreporttest.CheckReceiverLogs(tt, receiver, transport, int64(acceptedLogRecords), int64(refusedLogRecords))) + require.NoError(t, tt.CheckReceiverLogs(transport, int64(acceptedLogRecords), int64(refusedLogRecords))) }) } @@ -214,7 +214,7 @@ func TestReceiveMetricsOp(t *testing.T) { } } - require.NoError(t, obsreporttest.CheckReceiverMetrics(tt, receiver, transport, int64(acceptedMetricPoints), int64(refusedMetricPoints))) + require.NoError(t, tt.CheckReceiverMetrics(transport, int64(acceptedMetricPoints), int64(refusedMetricPoints))) }) } @@ -321,7 +321,7 @@ func TestExportTraceDataOp(t *testing.T) { } } - require.NoError(t, obsreporttest.CheckExporterTraces(tt, exporter, int64(sentSpans), int64(failedToSendSpans))) + require.NoError(t, tt.CheckExporterTraces(int64(sentSpans), int64(failedToSendSpans))) }) } @@ -371,7 +371,7 @@ func TestExportMetricsOp(t *testing.T) { } } - require.NoError(t, obsreporttest.CheckExporterMetrics(tt, exporter, int64(sentMetricPoints), int64(failedToSendMetricPoints))) + require.NoError(t, tt.CheckExporterMetrics(int64(sentMetricPoints), int64(failedToSendMetricPoints))) }) } @@ -420,7 +420,7 @@ func TestExportLogsOp(t *testing.T) { } } - require.NoError(t, obsreporttest.CheckExporterLogs(tt, exporter, int64(sentLogRecords), int64(failedToSendLogRecords))) + require.NoError(t, tt.CheckExporterLogs(int64(sentLogRecords), int64(failedToSendLogRecords))) }) } @@ -495,7 +495,7 @@ func testProcessorTraceData(t *testing.T, tt obsreporttest.TestTelemetry, regist obsrep.TracesRefused(context.Background(), refusedSpans) obsrep.TracesDropped(context.Background(), droppedSpans) - require.NoError(t, obsreporttest.CheckProcessorTraces(tt, processor, acceptedSpans, refusedSpans, droppedSpans)) + require.NoError(t, tt.CheckProcessorTraces(acceptedSpans, refusedSpans, droppedSpans)) } func TestProcessorMetricsData(t *testing.T) { @@ -516,7 +516,7 @@ func testProcessorMetricsData(t *testing.T, tt obsreporttest.TestTelemetry, regi obsrep.MetricsRefused(context.Background(), refusedPoints) obsrep.MetricsDropped(context.Background(), droppedPoints) - require.NoError(t, obsreporttest.CheckProcessorMetrics(tt, processor, acceptedPoints, refusedPoints, droppedPoints)) + require.NoError(t, tt.CheckProcessorMetrics(acceptedPoints, refusedPoints, droppedPoints)) } func TestBuildProcessorCustomMetricName(t *testing.T) { @@ -559,5 +559,5 @@ func testProcessorLogRecords(t *testing.T, tt obsreporttest.TestTelemetry, regis obsrep.LogsRefused(context.Background(), refusedRecords) obsrep.LogsDropped(context.Background(), droppedRecords) - require.NoError(t, obsreporttest.CheckProcessorLogs(tt, processor, acceptedRecords, refusedRecords, droppedRecords)) + require.NoError(t, tt.CheckProcessorLogs(acceptedRecords, refusedRecords, droppedRecords)) } diff --git a/obsreport/obsreporttest/obsreporttest.go b/obsreport/obsreporttest/obsreporttest.go index 7718ae2fe912..8146756c1a18 100644 --- a/obsreport/obsreporttest/obsreporttest.go +++ b/obsreport/obsreporttest/obsreporttest.go @@ -82,6 +82,60 @@ func (tts *TestTelemetry) ToReceiverCreateSettings() component.ReceiverCreateSet return set } +// CheckExporterTraces checks that for the current exported values for trace exporter metrics match given values. +// When this function is called it is required to also call SetupTelemetry as first thing. +func (tts *TestTelemetry) CheckExporterTraces(sentSpans, sendFailedSpans int64) error { + return tts.otelPrometheusChecker.checkExporterTraces(tts.id, sentSpans, sendFailedSpans) +} + +// CheckExporterMetrics checks that for the current exported values for metrics exporter metrics match given values. +// When this function is called it is required to also call SetupTelemetry as first thing. +func (tts *TestTelemetry) CheckExporterMetrics(sentMetricsPoints, sendFailedMetricsPoints int64) error { + return tts.otelPrometheusChecker.checkExporterMetrics(tts.id, sentMetricsPoints, sendFailedMetricsPoints) +} + +// CheckExporterLogs checks that for the current exported values for logs exporter metrics match given values. +// When this function is called it is required to also call SetupTelemetry as first thing. +func (tts *TestTelemetry) CheckExporterLogs(sentLogRecords, sendFailedLogRecords int64) error { + return tts.otelPrometheusChecker.checkExporterLogs(tts.id, sentLogRecords, sendFailedLogRecords) +} + +// CheckProcessorTraces checks that for the current exported values for trace exporter metrics match given values. +// When this function is called it is required to also call SetupTelemetry as first thing. +func (tts *TestTelemetry) CheckProcessorTraces(acceptedSpans, refusedSpans, droppedSpans int64) error { + return tts.otelPrometheusChecker.checkProcessorTraces(tts.id, acceptedSpans, refusedSpans, droppedSpans) +} + +// CheckProcessorMetrics checks that for the current exported values for metrics exporter metrics match given values. +// When this function is called it is required to also call SetupTelemetry as first thing. +func (tts *TestTelemetry) CheckProcessorMetrics(acceptedMetricPoints, refusedMetricPoints, droppedMetricPoints int64) error { + return tts.otelPrometheusChecker.checkProcessorMetrics(tts.id, acceptedMetricPoints, refusedMetricPoints, droppedMetricPoints) +} + +// CheckProcessorLogs checks that for the current exported values for logs exporter metrics match given values. +// When this function is called it is required to also call SetupTelemetry as first thing. +func (tts *TestTelemetry) CheckProcessorLogs(acceptedLogRecords, refusedLogRecords, droppedLogRecords int64) error { + return tts.otelPrometheusChecker.checkProcessorLogs(tts.id, acceptedLogRecords, refusedLogRecords, droppedLogRecords) +} + +// CheckReceiverTraces checks that for the current exported values for trace receiver metrics match given values. +// When this function is called it is required to also call SetupTelemetry as first thing. +func (tts *TestTelemetry) CheckReceiverTraces(protocol string, acceptedSpans, droppedSpans int64) error { + return tts.otelPrometheusChecker.checkReceiverTraces(tts.id, protocol, acceptedSpans, droppedSpans) +} + +// CheckReceiverLogs checks that for the current exported values for logs receiver metrics match given values. +// When this function is called it is required to also call SetupTelemetry as first thing. +func (tts *TestTelemetry) CheckReceiverLogs(protocol string, acceptedLogRecords, droppedLogRecords int64) error { + return tts.otelPrometheusChecker.checkReceiverLogs(tts.id, protocol, acceptedLogRecords, droppedLogRecords) +} + +// CheckReceiverMetrics checks that for the current exported values for metrics receiver metrics match given values. +// When this function is called it is required to also call SetupTelemetry as first thing. +func (tts *TestTelemetry) CheckReceiverMetrics(protocol string, acceptedMetricPoints, droppedMetricPoints int64) error { + return tts.otelPrometheusChecker.checkReceiverMetrics(tts.id, protocol, acceptedMetricPoints, droppedMetricPoints) +} + // Shutdown unregisters any views and shuts down the SpanRecorder func (tts *TestTelemetry) Shutdown(ctx context.Context) error { view.Unregister(tts.views...) @@ -144,56 +198,47 @@ func SetupTelemetryWithID(id component.ID) (TestTelemetry, error) { return settings, nil } -// CheckExporterTraces checks that for the current exported values for trace exporter metrics match given values. -// When this function is called it is required to also call SetupTelemetry as first thing. +// Deprecated: [v0.67.0] use TestTelemetry.CheckExporterTraces. func CheckExporterTraces(tts TestTelemetry, exporter component.ID, sentSpans, sendFailedSpans int64) error { return tts.otelPrometheusChecker.checkExporterTraces(exporter, sentSpans, sendFailedSpans) } -// CheckExporterMetrics checks that for the current exported values for metrics exporter metrics match given values. -// When this function is called it is required to also call SetupTelemetry as first thing. +// Deprecated: [v0.67.0] use TestTelemetry.CheckExporterMetrics. func CheckExporterMetrics(tts TestTelemetry, exporter component.ID, sentMetricsPoints, sendFailedMetricsPoints int64) error { return tts.otelPrometheusChecker.checkExporterMetrics(exporter, sentMetricsPoints, sendFailedMetricsPoints) } -// CheckExporterLogs checks that for the current exported values for logs exporter metrics match given values. -// When this function is called it is required to also call SetupTelemetry as first thing. +// Deprecated: [v0.67.0] use TestTelemetry.CheckExporterLogs. func CheckExporterLogs(tts TestTelemetry, exporter component.ID, sentLogRecords, sendFailedLogRecords int64) error { return tts.otelPrometheusChecker.checkExporterLogs(exporter, sentLogRecords, sendFailedLogRecords) } -// CheckProcessorTraces checks that for the current exported values for trace exporter metrics match given values. -// When this function is called it is required to also call SetupTelemetry as first thing. +// Deprecated: [v0.67.0] use TestTelemetry.CheckProcessorTraces. func CheckProcessorTraces(tts TestTelemetry, processor component.ID, acceptedSpans, refusedSpans, droppedSpans int64) error { return tts.otelPrometheusChecker.checkProcessorTraces(processor, acceptedSpans, refusedSpans, droppedSpans) } -// CheckProcessorMetrics checks that for the current exported values for metrics exporter metrics match given values. -// When this function is called it is required to also call SetupTelemetry as first thing. +// Deprecated: [v0.67.0] use TestTelemetry.CheckProcessorMetrics. func CheckProcessorMetrics(tts TestTelemetry, processor component.ID, acceptedMetricPoints, refusedMetricPoints, droppedMetricPoints int64) error { return tts.otelPrometheusChecker.checkProcessorMetrics(processor, acceptedMetricPoints, refusedMetricPoints, droppedMetricPoints) } -// CheckProcessorLogs checks that for the current exported values for logs exporter metrics match given values. -// When this function is called it is required to also call SetupTelemetry as first thing. +// Deprecated: [v0.67.0] use TestTelemetry.CheckProcessorLogs. func CheckProcessorLogs(tts TestTelemetry, processor component.ID, acceptedLogRecords, refusedLogRecords, droppedLogRecords int64) error { return tts.otelPrometheusChecker.checkProcessorLogs(processor, acceptedLogRecords, refusedLogRecords, droppedLogRecords) } -// CheckReceiverTraces checks that for the current exported values for trace receiver metrics match given values. -// When this function is called it is required to also call SetupTelemetry as first thing. +// Deprecated: [v0.67.0] use TestTelemetry.CheckReceiverTraces. func CheckReceiverTraces(tts TestTelemetry, receiver component.ID, protocol string, acceptedSpans, droppedSpans int64) error { return tts.otelPrometheusChecker.checkReceiverTraces(receiver, protocol, acceptedSpans, droppedSpans) } -// CheckReceiverLogs checks that for the current exported values for logs receiver metrics match given values. -// When this function is called it is required to also call SetupTelemetry as first thing. +// Deprecated: [v0.67.0] use TestTelemetry.CheckReceiverLogs. func CheckReceiverLogs(tts TestTelemetry, receiver component.ID, protocol string, acceptedLogRecords, droppedLogRecords int64) error { return tts.otelPrometheusChecker.checkReceiverLogs(receiver, protocol, acceptedLogRecords, droppedLogRecords) } -// CheckReceiverMetrics checks that for the current exported values for metrics receiver metrics match given values. -// When this function is called it is required to also call SetupTelemetry as first thing. +// Deprecated: [v0.67.0] use TestTelemetry.CheckReceiverMetrics. func CheckReceiverMetrics(tts TestTelemetry, receiver component.ID, protocol string, acceptedMetricPoints, droppedMetricPoints int64) error { return tts.otelPrometheusChecker.checkReceiverMetrics(receiver, protocol, acceptedMetricPoints, droppedMetricPoints) } diff --git a/obsreport/obsreporttest/obsreporttest_test.go b/obsreport/obsreporttest/obsreporttest_test.go index d453b828273f..dcccadc96d13 100644 --- a/obsreport/obsreporttest/obsreporttest_test.go +++ b/obsreport/obsreporttest/obsreporttest_test.go @@ -74,10 +74,10 @@ func TestCheckReceiverTracesViews(t *testing.T) { require.NotNil(t, ctx) rec.EndTracesOp(ctx, format, 7, nil) - assert.NoError(t, obsreporttest.CheckReceiverTraces(tt, receiver, transport, 7, 0)) - assert.Error(t, obsreporttest.CheckReceiverTraces(tt, receiver, transport, 7, 7)) - assert.Error(t, obsreporttest.CheckReceiverTraces(tt, receiver, transport, 0, 0)) - assert.Error(t, obsreporttest.CheckReceiverTraces(tt, receiver, transport, 0, 7)) + assert.NoError(t, tt.CheckReceiverTraces(transport, 7, 0)) + assert.Error(t, tt.CheckReceiverTraces(transport, 7, 7)) + assert.Error(t, tt.CheckReceiverTraces(transport, 0, 0)) + assert.Error(t, tt.CheckReceiverTraces(transport, 0, 7)) } func TestCheckReceiverMetricsViews(t *testing.T) { @@ -95,10 +95,10 @@ func TestCheckReceiverMetricsViews(t *testing.T) { require.NotNil(t, ctx) rec.EndMetricsOp(ctx, format, 7, nil) - assert.NoError(t, obsreporttest.CheckReceiverMetrics(tt, receiver, transport, 7, 0)) - assert.Error(t, obsreporttest.CheckReceiverMetrics(tt, receiver, transport, 7, 7)) - assert.Error(t, obsreporttest.CheckReceiverMetrics(tt, receiver, transport, 0, 0)) - assert.Error(t, obsreporttest.CheckReceiverMetrics(tt, receiver, transport, 0, 7)) + assert.NoError(t, tt.CheckReceiverMetrics(transport, 7, 0)) + assert.Error(t, tt.CheckReceiverMetrics(transport, 7, 7)) + assert.Error(t, tt.CheckReceiverMetrics(transport, 0, 0)) + assert.Error(t, tt.CheckReceiverMetrics(transport, 0, 7)) } func TestCheckReceiverLogsViews(t *testing.T) { @@ -116,10 +116,10 @@ func TestCheckReceiverLogsViews(t *testing.T) { require.NotNil(t, ctx) rec.EndLogsOp(ctx, format, 7, nil) - assert.NoError(t, obsreporttest.CheckReceiverLogs(tt, receiver, transport, 7, 0)) - assert.Error(t, obsreporttest.CheckReceiverLogs(tt, receiver, transport, 7, 7)) - assert.Error(t, obsreporttest.CheckReceiverLogs(tt, receiver, transport, 0, 0)) - assert.Error(t, obsreporttest.CheckReceiverLogs(tt, receiver, transport, 0, 7)) + assert.NoError(t, tt.CheckReceiverLogs(transport, 7, 0)) + assert.Error(t, tt.CheckReceiverLogs(transport, 7, 7)) + assert.Error(t, tt.CheckReceiverLogs(transport, 0, 0)) + assert.Error(t, tt.CheckReceiverLogs(transport, 0, 7)) } func TestCheckProcessorTracesViews(t *testing.T) { @@ -137,14 +137,14 @@ func TestCheckProcessorTracesViews(t *testing.T) { por.TracesRefused(context.Background(), 8) por.TracesDropped(context.Background(), 9) - assert.NoError(t, obsreporttest.CheckProcessorTraces(tt, processor, 7, 8, 9)) - assert.Error(t, obsreporttest.CheckProcessorTraces(tt, processor, 0, 0, 0)) - assert.Error(t, obsreporttest.CheckProcessorTraces(tt, processor, 7, 0, 0)) - assert.Error(t, obsreporttest.CheckProcessorTraces(tt, processor, 7, 8, 0)) - assert.Error(t, obsreporttest.CheckProcessorTraces(tt, processor, 7, 0, 9)) - assert.Error(t, obsreporttest.CheckProcessorTraces(tt, processor, 0, 8, 0)) - assert.Error(t, obsreporttest.CheckProcessorTraces(tt, processor, 0, 8, 9)) - assert.Error(t, obsreporttest.CheckProcessorTraces(tt, processor, 0, 0, 9)) + assert.NoError(t, tt.CheckProcessorTraces(7, 8, 9)) + assert.Error(t, tt.CheckProcessorTraces(0, 0, 0)) + assert.Error(t, tt.CheckProcessorTraces(7, 0, 0)) + assert.Error(t, tt.CheckProcessorTraces(7, 8, 0)) + assert.Error(t, tt.CheckProcessorTraces(7, 0, 9)) + assert.Error(t, tt.CheckProcessorTraces(0, 8, 0)) + assert.Error(t, tt.CheckProcessorTraces(0, 8, 9)) + assert.Error(t, tt.CheckProcessorTraces(0, 0, 9)) } func TestCheckProcessorMetricsViews(t *testing.T) { @@ -162,14 +162,14 @@ func TestCheckProcessorMetricsViews(t *testing.T) { por.MetricsRefused(context.Background(), 8) por.MetricsDropped(context.Background(), 9) - assert.NoError(t, obsreporttest.CheckProcessorMetrics(tt, processor, 7, 8, 9)) - assert.Error(t, obsreporttest.CheckProcessorMetrics(tt, processor, 0, 0, 0)) - assert.Error(t, obsreporttest.CheckProcessorMetrics(tt, processor, 7, 0, 0)) - assert.Error(t, obsreporttest.CheckProcessorMetrics(tt, processor, 7, 8, 0)) - assert.Error(t, obsreporttest.CheckProcessorMetrics(tt, processor, 7, 0, 9)) - assert.Error(t, obsreporttest.CheckProcessorMetrics(tt, processor, 0, 8, 0)) - assert.Error(t, obsreporttest.CheckProcessorMetrics(tt, processor, 0, 8, 9)) - assert.Error(t, obsreporttest.CheckProcessorMetrics(tt, processor, 0, 0, 9)) + assert.NoError(t, tt.CheckProcessorMetrics(7, 8, 9)) + assert.Error(t, tt.CheckProcessorMetrics(0, 0, 0)) + assert.Error(t, tt.CheckProcessorMetrics(7, 0, 0)) + assert.Error(t, tt.CheckProcessorMetrics(7, 8, 0)) + assert.Error(t, tt.CheckProcessorMetrics(7, 0, 9)) + assert.Error(t, tt.CheckProcessorMetrics(0, 8, 0)) + assert.Error(t, tt.CheckProcessorMetrics(0, 8, 9)) + assert.Error(t, tt.CheckProcessorMetrics(0, 0, 9)) } func TestCheckProcessorLogViews(t *testing.T) { @@ -187,14 +187,14 @@ func TestCheckProcessorLogViews(t *testing.T) { por.LogsRefused(context.Background(), 8) por.LogsDropped(context.Background(), 9) - assert.NoError(t, obsreporttest.CheckProcessorLogs(tt, processor, 7, 8, 9)) - assert.Error(t, obsreporttest.CheckProcessorLogs(tt, processor, 0, 0, 0)) - assert.Error(t, obsreporttest.CheckProcessorLogs(tt, processor, 7, 0, 0)) - assert.Error(t, obsreporttest.CheckProcessorLogs(tt, processor, 7, 8, 0)) - assert.Error(t, obsreporttest.CheckProcessorLogs(tt, processor, 7, 0, 9)) - assert.Error(t, obsreporttest.CheckProcessorLogs(tt, processor, 0, 8, 0)) - assert.Error(t, obsreporttest.CheckProcessorLogs(tt, processor, 0, 8, 9)) - assert.Error(t, obsreporttest.CheckProcessorLogs(tt, processor, 0, 0, 9)) + assert.NoError(t, tt.CheckProcessorLogs(7, 8, 9)) + assert.Error(t, tt.CheckProcessorLogs(0, 0, 0)) + assert.Error(t, tt.CheckProcessorLogs(7, 0, 0)) + assert.Error(t, tt.CheckProcessorLogs(7, 8, 0)) + assert.Error(t, tt.CheckProcessorLogs(7, 0, 9)) + assert.Error(t, tt.CheckProcessorLogs(0, 8, 0)) + assert.Error(t, tt.CheckProcessorLogs(0, 8, 9)) + assert.Error(t, tt.CheckProcessorLogs(0, 0, 9)) } func TestCheckExporterTracesViews(t *testing.T) { @@ -211,10 +211,10 @@ func TestCheckExporterTracesViews(t *testing.T) { require.NotNil(t, ctx) obsrep.EndTracesOp(ctx, 7, nil) - assert.NoError(t, obsreporttest.CheckExporterTraces(tt, exporter, 7, 0)) - assert.Error(t, obsreporttest.CheckExporterTraces(tt, exporter, 7, 7)) - assert.Error(t, obsreporttest.CheckExporterTraces(tt, exporter, 0, 0)) - assert.Error(t, obsreporttest.CheckExporterTraces(tt, exporter, 0, 7)) + assert.NoError(t, tt.CheckExporterTraces(7, 0)) + assert.Error(t, tt.CheckExporterTraces(7, 7)) + assert.Error(t, tt.CheckExporterTraces(0, 0)) + assert.Error(t, tt.CheckExporterTraces(0, 7)) } func TestCheckExporterMetricsViews(t *testing.T) { @@ -231,10 +231,10 @@ func TestCheckExporterMetricsViews(t *testing.T) { require.NotNil(t, ctx) obsrep.EndMetricsOp(ctx, 7, nil) - assert.NoError(t, obsreporttest.CheckExporterMetrics(tt, exporter, 7, 0)) - assert.Error(t, obsreporttest.CheckExporterMetrics(tt, exporter, 7, 7)) - assert.Error(t, obsreporttest.CheckExporterMetrics(tt, exporter, 0, 0)) - assert.Error(t, obsreporttest.CheckExporterMetrics(tt, exporter, 0, 7)) + assert.NoError(t, tt.CheckExporterMetrics(7, 0)) + assert.Error(t, tt.CheckExporterMetrics(7, 7)) + assert.Error(t, tt.CheckExporterMetrics(0, 0)) + assert.Error(t, tt.CheckExporterMetrics(0, 7)) } func TestCheckExporterLogsViews(t *testing.T) { @@ -251,8 +251,8 @@ func TestCheckExporterLogsViews(t *testing.T) { require.NotNil(t, ctx) obsrep.EndLogsOp(ctx, 7, nil) - assert.NoError(t, obsreporttest.CheckExporterLogs(tt, exporter, 7, 0)) - assert.Error(t, obsreporttest.CheckExporterLogs(tt, exporter, 7, 7)) - assert.Error(t, obsreporttest.CheckExporterLogs(tt, exporter, 0, 0)) - assert.Error(t, obsreporttest.CheckExporterLogs(tt, exporter, 0, 7)) + assert.NoError(t, tt.CheckExporterLogs(7, 0)) + assert.Error(t, tt.CheckExporterLogs(7, 7)) + assert.Error(t, tt.CheckExporterLogs(0, 0)) + assert.Error(t, tt.CheckExporterLogs(0, 7)) } diff --git a/receiver/otlpreceiver/otlp_test.go b/receiver/otlpreceiver/otlp_test.go index 4d40876f5408..5b8338cbe29b 100644 --- a/receiver/otlpreceiver/otlp_test.go +++ b/receiver/otlpreceiver/otlp_test.go @@ -702,7 +702,7 @@ func TestOTLPReceiverTrace_HandleNextConsumerResponse(t *testing.T) { require.Equal(t, test.expectedReceivedBatches, len(sink.AllTraces())) - require.NoError(t, obsreporttest.CheckReceiverTraces(tt, component.NewIDWithName(typeStr, exporter.receiverTag), "grpc", int64(test.expectedReceivedBatches), int64(test.expectedIngestionBlockedRPCs))) + require.NoError(t, tt.CheckReceiverTraces("grpc", int64(test.expectedReceivedBatches), int64(test.expectedIngestionBlockedRPCs))) }) } } diff --git a/receiver/scraperhelper/scrapercontroller_test.go b/receiver/scraperhelper/scrapercontroller_test.go index 71b0d983e715..7e5b5e38d971 100644 --- a/receiver/scraperhelper/scrapercontroller_test.go +++ b/receiver/scraperhelper/scrapercontroller_test.go @@ -287,7 +287,7 @@ func assertReceiverViews(t *testing.T, tt obsreporttest.TestTelemetry, sink *con for _, md := range sink.AllMetrics() { dataPointCount += md.DataPointCount() } - require.NoError(t, obsreporttest.CheckReceiverMetrics(tt, component.NewID("receiver"), "", int64(dataPointCount), 0)) + require.NoError(t, tt.CheckReceiverMetrics("", int64(dataPointCount), 0)) } func assertScraperSpan(t *testing.T, expectedErr error, spans []sdktrace.ReadOnlySpan) {