Skip to content

Commit

Permalink
Remove suffix Views from test helper funcs, avoid correlation with Op…
Browse files Browse the repository at this point in the history
…enCensus (#2934)

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
  • Loading branch information
bogdandrutu authored Apr 15, 2021
1 parent e621c62 commit b4f495f
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 49 deletions.
4 changes: 2 additions & 2 deletions exporter/exporterhelper/logshelper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ func checkRecordedMetricsForLogsExporter(t *testing.T, le component.LogsExporter

// TODO: When the new metrics correctly count partial dropped fix this.
if wantError != nil {
obsreporttest.CheckExporterLogsViews(t, fakeLogsExporterName, 0, int64(numBatches*ld.LogRecordCount()))
obsreporttest.CheckExporterLogs(t, fakeLogsExporterName, 0, int64(numBatches*ld.LogRecordCount()))
} else {
obsreporttest.CheckExporterLogsViews(t, fakeLogsExporterName, int64(numBatches*ld.LogRecordCount()), 0)
obsreporttest.CheckExporterLogs(t, fakeLogsExporterName, int64(numBatches*ld.LogRecordCount()), 0)
}
}

Expand Down
4 changes: 2 additions & 2 deletions exporter/exporterhelper/metricshelper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ func checkRecordedMetricsForMetricsExporter(t *testing.T, me component.MetricsEx
// TODO: When the new metrics correctly count partial dropped fix this.
numPoints := int64(numBatches * md.MetricCount() * 2) /* 2 points per metric*/
if wantError != nil {
obsreporttest.CheckExporterMetricsViews(t, fakeMetricsExporterName, 0, numPoints)
obsreporttest.CheckExporterMetrics(t, fakeMetricsExporterName, 0, numPoints)
} else {
obsreporttest.CheckExporterMetricsViews(t, fakeMetricsExporterName, numPoints, 0)
obsreporttest.CheckExporterMetrics(t, fakeMetricsExporterName, numPoints, 0)
}
}

Expand Down
4 changes: 2 additions & 2 deletions exporter/exporterhelper/tracehelper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ func checkRecordedMetricsForTracesExporter(t *testing.T, te component.TracesExpo

// TODO: When the new metrics correctly count partial dropped fix this.
if wantError != nil {
obsreporttest.CheckExporterTracesViews(t, fakeTracesExporterName, 0, int64(numBatches*td.SpanCount()))
obsreporttest.CheckExporterTraces(t, fakeTracesExporterName, 0, int64(numBatches*td.SpanCount()))
} else {
obsreporttest.CheckExporterTracesViews(t, fakeTracesExporterName, int64(numBatches*td.SpanCount()), 0)
obsreporttest.CheckExporterTraces(t, fakeTracesExporterName, int64(numBatches*td.SpanCount()), 0)
}
}

Expand Down
20 changes: 10 additions & 10 deletions obsreport/obsreport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func TestReceiveTraceDataOp(t *testing.T) {
assert.Equal(t, params[i].transport, span.Attributes[obsreport.TransportKey])
}
}
obsreporttest.CheckReceiverTracesViews(t, receiver, transport, int64(acceptedSpans), int64(refusedSpans))
obsreporttest.CheckReceiverTraces(t, receiver, transport, int64(acceptedSpans), int64(refusedSpans))
}

func TestReceiveLogsOp(t *testing.T) {
Expand Down Expand Up @@ -204,7 +204,7 @@ func TestReceiveLogsOp(t *testing.T) {
assert.Equal(t, params[i].transport, span.Attributes[obsreport.TransportKey])
}
}
obsreporttest.CheckReceiverLogsViews(t, receiver, transport, int64(acceptedLogRecords), int64(refusedLogRecords))
obsreporttest.CheckReceiverLogs(t, receiver, transport, int64(acceptedLogRecords), int64(refusedLogRecords))
}

func TestReceiveMetricsOp(t *testing.T) {
Expand Down Expand Up @@ -265,7 +265,7 @@ func TestReceiveMetricsOp(t *testing.T) {
}
}

obsreporttest.CheckReceiverMetricsViews(t, receiver, transport, int64(acceptedMetricPoints), int64(refusedMetricPoints))
obsreporttest.CheckReceiverMetrics(t, receiver, transport, int64(acceptedMetricPoints), int64(refusedMetricPoints))
}

func TestScrapeMetricsDataOp(t *testing.T) {
Expand Down Expand Up @@ -322,7 +322,7 @@ func TestScrapeMetricsDataOp(t *testing.T) {
}
}

obsreporttest.CheckScraperMetricsViews(t, receiver, scraper, int64(scrapedMetricPoints), int64(erroredMetricPoints))
obsreporttest.CheckScraperMetrics(t, receiver, scraper, int64(scrapedMetricPoints), int64(erroredMetricPoints))
}

func TestExportTraceDataOp(t *testing.T) {
Expand Down Expand Up @@ -369,7 +369,7 @@ func TestExportTraceDataOp(t *testing.T) {
}
}

obsreporttest.CheckExporterTracesViews(t, exporter, int64(sentSpans), int64(failedToSendSpans))
obsreporttest.CheckExporterTraces(t, exporter, int64(sentSpans), int64(failedToSendSpans))
}

func TestExportMetricsOp(t *testing.T) {
Expand Down Expand Up @@ -418,7 +418,7 @@ func TestExportMetricsOp(t *testing.T) {
}
}

obsreporttest.CheckExporterMetricsViews(t, exporter, int64(sentMetricPoints), int64(failedToSendMetricPoints))
obsreporttest.CheckExporterMetrics(t, exporter, int64(sentMetricPoints), int64(failedToSendMetricPoints))
}

func TestExportLogsOp(t *testing.T) {
Expand Down Expand Up @@ -466,7 +466,7 @@ func TestExportLogsOp(t *testing.T) {
}
}

obsreporttest.CheckExporterLogsViews(t, exporter, int64(sentLogRecords), int64(failedToSendLogRecords))
obsreporttest.CheckExporterLogs(t, exporter, int64(sentLogRecords), int64(failedToSendLogRecords))
}

func TestReceiveWithLongLivedCtx(t *testing.T) {
Expand Down Expand Up @@ -552,7 +552,7 @@ func TestProcessorTraceData(t *testing.T) {
obsrep.TracesRefused(context.Background(), refusedSpans)
obsrep.TracesDropped(context.Background(), droppedSpans)

obsreporttest.CheckProcessorTracesViews(t, processor, acceptedSpans, refusedSpans, droppedSpans)
obsreporttest.CheckProcessorTraces(t, processor, acceptedSpans, refusedSpans, droppedSpans)
}

func TestProcessorMetricsData(t *testing.T) {
Expand All @@ -569,7 +569,7 @@ func TestProcessorMetricsData(t *testing.T) {
obsrep.MetricsRefused(context.Background(), refusedPoints)
obsrep.MetricsDropped(context.Background(), droppedPoints)

obsreporttest.CheckProcessorMetricsViews(t, processor, acceptedPoints, refusedPoints, droppedPoints)
obsreporttest.CheckProcessorMetrics(t, processor, acceptedPoints, refusedPoints, droppedPoints)
}

func TestProcessorMetricViews(t *testing.T) {
Expand Down Expand Up @@ -640,7 +640,7 @@ func TestProcessorLogRecords(t *testing.T) {
obsrep.LogsRefused(context.Background(), refusedRecords)
obsrep.LogsDropped(context.Background(), droppedRecords)

obsreporttest.CheckProcessorLogsViews(t, processor, acceptedRecords, refusedRecords, droppedRecords)
obsreporttest.CheckProcessorLogs(t, processor, acceptedRecords, refusedRecords, droppedRecords)
}

type spanStore struct {
Expand Down
40 changes: 20 additions & 20 deletions obsreport/obsreporttest/obsreporttest.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,84 +55,84 @@ func SetupRecordedMetricsTest() (func(), error) {
}, err
}

// CheckExporterTracesViews checks that for the current exported values for trace exporter views match given values.
// 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 SetupRecordedMetricsTest as first thing.
func CheckExporterTracesViews(t *testing.T, exporter string, acceptedSpans, droppedSpans int64) {
func CheckExporterTraces(t *testing.T, exporter string, acceptedSpans, droppedSpans int64) {
exporterTags := tagsForExporterView(exporter)
checkValueForView(t, exporterTags, acceptedSpans, "exporter/sent_spans")
checkValueForView(t, exporterTags, droppedSpans, "exporter/send_failed_spans")
}

// CheckExporterMetricsViews checks that for the current exported values for metrics exporter views match given values.
// 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 SetupRecordedMetricsTest as first thing.
func CheckExporterMetricsViews(t *testing.T, exporter string, acceptedMetricsPoints, droppedMetricsPoints int64) {
func CheckExporterMetrics(t *testing.T, exporter string, acceptedMetricsPoints, droppedMetricsPoints int64) {
exporterTags := tagsForExporterView(exporter)
checkValueForView(t, exporterTags, acceptedMetricsPoints, "exporter/sent_metric_points")
checkValueForView(t, exporterTags, droppedMetricsPoints, "exporter/send_failed_metric_points")
}

// CheckExporterLogsViews checks that for the current exported values for logs exporter views match given values.
// 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 SetupRecordedMetricsTest as first thing.
func CheckExporterLogsViews(t *testing.T, exporter string, acceptedLogRecords, droppedLogRecords int64) {
func CheckExporterLogs(t *testing.T, exporter string, acceptedLogRecords, droppedLogRecords int64) {
exporterTags := tagsForExporterView(exporter)
checkValueForView(t, exporterTags, acceptedLogRecords, "exporter/sent_log_records")
checkValueForView(t, exporterTags, droppedLogRecords, "exporter/send_failed_log_records")
}

// CheckProcessorTracesViews checks that for the current exported values for trace exporter views match given values.
// 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 SetupRecordedMetricsTest as first thing.
func CheckProcessorTracesViews(t *testing.T, processor string, acceptedSpans, refusedSpans, droppedSpans int64) {
func CheckProcessorTraces(t *testing.T, processor string, acceptedSpans, refusedSpans, droppedSpans int64) {
processorTags := tagsForProcessorView(processor)
checkValueForView(t, processorTags, acceptedSpans, "processor/accepted_spans")
checkValueForView(t, processorTags, refusedSpans, "processor/refused_spans")
checkValueForView(t, processorTags, droppedSpans, "processor/dropped_spans")
}

// CheckProcessorMetricsViews checks that for the current exported values for metrics exporter views match given values.
// 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 SetupRecordedMetricsTest as first thing.
func CheckProcessorMetricsViews(t *testing.T, processor string, acceptedMetricPoints, refusedMetricPoints, droppedMetricPoints int64) {
func CheckProcessorMetrics(t *testing.T, processor string, acceptedMetricPoints, refusedMetricPoints, droppedMetricPoints int64) {
processorTags := tagsForProcessorView(processor)
checkValueForView(t, processorTags, acceptedMetricPoints, "processor/accepted_metric_points")
checkValueForView(t, processorTags, refusedMetricPoints, "processor/refused_metric_points")
checkValueForView(t, processorTags, droppedMetricPoints, "processor/dropped_metric_points")
}

// CheckProcessorLogsViews checks that for the current exported values for logs exporter views match given values.
// 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 SetupRecordedMetricsTest as first thing.
func CheckProcessorLogsViews(t *testing.T, processor string, acceptedLogRecords, refusedLogRecords, droppedLogRecords int64) {
func CheckProcessorLogs(t *testing.T, processor string, acceptedLogRecords, refusedLogRecords, droppedLogRecords int64) {
processorTags := tagsForProcessorView(processor)
checkValueForView(t, processorTags, acceptedLogRecords, "processor/accepted_log_records")
checkValueForView(t, processorTags, refusedLogRecords, "processor/refused_log_records")
checkValueForView(t, processorTags, droppedLogRecords, "processor/dropped_log_records")
}

// CheckReceiverTracesViews checks that for the current exported values for trace receiver views match given values.
// 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 SetupRecordedMetricsTest as first thing.
func CheckReceiverTracesViews(t *testing.T, receiver, protocol string, acceptedSpans, droppedSpans int64) {
func CheckReceiverTraces(t *testing.T, receiver, protocol string, acceptedSpans, droppedSpans int64) {
receiverTags := tagsForReceiverView(receiver, protocol)
checkValueForView(t, receiverTags, acceptedSpans, "receiver/accepted_spans")
checkValueForView(t, receiverTags, droppedSpans, "receiver/refused_spans")
}

// CheckReceiverLogsViews checks that for the current exported values for logs receiver views match given values.
// 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 SetupRecordedMetricsTest as first thing.
func CheckReceiverLogsViews(t *testing.T, receiver, protocol string, acceptedLogRecords, droppedLogRecords int64) {
func CheckReceiverLogs(t *testing.T, receiver, protocol string, acceptedLogRecords, droppedLogRecords int64) {
receiverTags := tagsForReceiverView(receiver, protocol)
checkValueForView(t, receiverTags, acceptedLogRecords, "receiver/accepted_log_records")
checkValueForView(t, receiverTags, droppedLogRecords, "receiver/refused_log_records")
}

// CheckReceiverMetricsViews checks that for the current exported values for metrics receiver views match given values.
// 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 SetupRecordedMetricsTest as first thing.
func CheckReceiverMetricsViews(t *testing.T, receiver, protocol string, acceptedMetricPoints, droppedMetricPoints int64) {
func CheckReceiverMetrics(t *testing.T, receiver, protocol string, acceptedMetricPoints, droppedMetricPoints int64) {
receiverTags := tagsForReceiverView(receiver, protocol)
checkValueForView(t, receiverTags, acceptedMetricPoints, "receiver/accepted_metric_points")
checkValueForView(t, receiverTags, droppedMetricPoints, "receiver/refused_metric_points")
}

// CheckScraperMetricsViews checks that for the current exported values for metrics scraper views match given values.
// CheckScraperMetrics checks that for the current exported values for metrics scraper metrics match given values.
// When this function is called it is required to also call SetupRecordedMetricsTest as first thing.
func CheckScraperMetricsViews(t *testing.T, receiver, scraper string, scrapedMetricPoints, erroredMetricPoints int64) {
func CheckScraperMetrics(t *testing.T, receiver, scraper string, scrapedMetricPoints, erroredMetricPoints int64) {
scraperTags := tagsForScraperView(receiver, scraper)
checkValueForView(t, scraperTags, scrapedMetricPoints, "scraper/scraped_metric_points")
checkValueForView(t, scraperTags, erroredMetricPoints, "scraper/errored_metric_points")
Expand Down
12 changes: 6 additions & 6 deletions obsreport/obsreporttest/obsreporttest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestCheckReceiverTracesViews(t *testing.T) {
7,
nil)

obsreporttest.CheckReceiverTracesViews(t, receiver, transport, 7, 0)
obsreporttest.CheckReceiverTraces(t, receiver, transport, 7, 0)
}

func TestCheckReceiverMetricsViews(t *testing.T) {
Expand All @@ -60,7 +60,7 @@ func TestCheckReceiverMetricsViews(t *testing.T) {
assert.NotNil(t, ctx)
obsreport.EndMetricsReceiveOp(ctx, format, 7, nil)

obsreporttest.CheckReceiverMetricsViews(t, receiver, transport, 7, 0)
obsreporttest.CheckReceiverMetrics(t, receiver, transport, 7, 0)
}

func TestCheckReceiverLogsViews(t *testing.T) {
Expand All @@ -73,7 +73,7 @@ func TestCheckReceiverLogsViews(t *testing.T) {
assert.NotNil(t, ctx)
obsreport.EndLogsReceiveOp(ctx, format, 7, nil)

obsreporttest.CheckReceiverLogsViews(t, receiver, transport, 7, 0)
obsreporttest.CheckReceiverLogs(t, receiver, transport, 7, 0)
}

func TestCheckExporterTracesViews(t *testing.T) {
Expand All @@ -90,7 +90,7 @@ func TestCheckExporterTracesViews(t *testing.T) {

obsrep.EndTracesExportOp(ctx, 7, nil)

obsreporttest.CheckExporterTracesViews(t, exporter, 7, 0)
obsreporttest.CheckExporterTraces(t, exporter, 7, 0)
}

func TestCheckExporterMetricsViews(t *testing.T) {
Expand All @@ -107,7 +107,7 @@ func TestCheckExporterMetricsViews(t *testing.T) {

obsrep.EndMetricsExportOp(ctx, 7, nil)

obsreporttest.CheckExporterMetricsViews(t, exporter, 7, 0)
obsreporttest.CheckExporterMetrics(t, exporter, 7, 0)
}

func TestCheckExporterLogsViews(t *testing.T) {
Expand All @@ -123,5 +123,5 @@ func TestCheckExporterLogsViews(t *testing.T) {
assert.NotNil(t, ctx)
obsrep.EndLogsExportOp(ctx, 7, nil)

obsreporttest.CheckExporterLogsViews(t, exporter, 7, 0)
obsreporttest.CheckExporterLogs(t, exporter, 7, 0)
}
4 changes: 2 additions & 2 deletions receiver/opencensusreceiver/octrace/observability_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func TestEnsureRecordedMetrics(t *testing.T) {
}
flush(traceSvcDoneFn)

obsreporttest.CheckReceiverTracesViews(t, "oc_trace", "grpc", int64(n), 0)
obsreporttest.CheckReceiverTraces(t, "oc_trace", "grpc", int64(n), 0)
}

func TestEnsureRecordedMetrics_zeroLengthSpansSender(t *testing.T) {
Expand All @@ -79,7 +79,7 @@ func TestEnsureRecordedMetrics_zeroLengthSpansSender(t *testing.T) {
}
flush(traceSvcDoneFn)

obsreporttest.CheckReceiverTracesViews(t, "oc_trace", "grpc", 0, 0)
obsreporttest.CheckReceiverTraces(t, "oc_trace", "grpc", 0, 0)
}

func TestExportSpanLinkingMaintainsParentLink(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions receiver/opencensusreceiver/opencensus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ func TestOCReceiverTrace_HandleNextConsumerResponse(t *testing.T) {
}

require.Equal(t, tt.expectedReceivedBatches, len(sink.AllTraces()))
obsreporttest.CheckReceiverTracesViews(t, exporter.receiverTag, "grpc", int64(tt.expectedReceivedBatches), int64(tt.expectedIngestionBlockedRPCs))
obsreporttest.CheckReceiverTraces(t, exporter.receiverTag, "grpc", int64(tt.expectedReceivedBatches), int64(tt.expectedIngestionBlockedRPCs))
})
}
}
Expand Down Expand Up @@ -608,7 +608,7 @@ func TestOCReceiverMetrics_HandleNextConsumerResponse(t *testing.T) {
}

require.Equal(t, tt.expectedReceivedBatches, len(sink.AllMetrics()))
obsreporttest.CheckReceiverMetricsViews(t, exporter.receiverTag, "grpc", int64(tt.expectedReceivedBatches), int64(tt.expectedIngestionBlockedRPCs))
obsreporttest.CheckReceiverMetrics(t, exporter.receiverTag, "grpc", int64(tt.expectedReceivedBatches), int64(tt.expectedIngestionBlockedRPCs))
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion receiver/otlpreceiver/otlp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ func TestOTLPReceiverTrace_HandleNextConsumerResponse(t *testing.T) {

require.Equal(t, tt.expectedReceivedBatches, len(sink.AllTraces()))

obsreporttest.CheckReceiverTracesViews(t, exporter.receiverTag, "grpc", int64(tt.expectedReceivedBatches), int64(tt.expectedIngestionBlockedRPCs))
obsreporttest.CheckReceiverTraces(t, exporter.receiverTag, "grpc", int64(tt.expectedReceivedBatches), int64(tt.expectedIngestionBlockedRPCs))
})
}
}
Expand Down
4 changes: 2 additions & 2 deletions receiver/scraperhelper/scrapercontroller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ func assertReceiverViews(t *testing.T, sink *consumertest.MetricsSink) {
_, dpc := md.MetricAndDataPointCount()
dataPointCount += dpc
}
obsreporttest.CheckReceiverMetricsViews(t, "receiver", "", int64(dataPointCount), 0)
obsreporttest.CheckReceiverMetrics(t, "receiver", "", int64(dataPointCount), 0)
}

func assertScraperSpan(t *testing.T, expectedErr error, spans []*trace.SpanData) {
Expand Down Expand Up @@ -396,7 +396,7 @@ func assertScraperViews(t *testing.T, expectedErr error, sink *consumertest.Metr
}
}

obsreporttest.CheckScraperMetricsViews(t, "receiver", "scraper", expectedScraped, expectedErrored)
obsreporttest.CheckScraperMetrics(t, "receiver", "scraper", expectedScraped, expectedErrored)
}

func singleMetric() pdata.MetricSlice {
Expand Down

0 comments on commit b4f495f

Please sign in to comment.