From c02b0fe458255cda2d11a0ab9127ff0386f7d2be Mon Sep 17 00:00:00 2001 From: Bogdan Drutu Date: Mon, 23 Nov 2020 06:34:32 -0800 Subject: [PATCH] Rename Push functions to be consistent across signals in exporterhelper Signed-off-by: Bogdan Drutu --- exporter/exporterhelper/constants.go | 12 ++++++------ exporter/exporterhelper/logshelper.go | 18 +++++++++--------- exporter/exporterhelper/logshelper_test.go | 2 +- exporter/exporterhelper/metricshelper.go | 16 ++++++++-------- exporter/exporterhelper/metricshelper_test.go | 2 +- exporter/exporterhelper/tracehelper.go | 16 ++++++++-------- exporter/exporterhelper/tracehelper_test.go | 2 +- 7 files changed, 34 insertions(+), 34 deletions(-) diff --git a/exporter/exporterhelper/constants.go b/exporter/exporterhelper/constants.go index f004221277e..2fb7511a438 100644 --- a/exporter/exporterhelper/constants.go +++ b/exporter/exporterhelper/constants.go @@ -23,10 +23,10 @@ var ( errNilConfig = errors.New("nil config") // errNilLogger is returned when a logger is nil errNilLogger = errors.New("nil logger") - // errNilPushTraceData is returned when a nil traceDataPusher is given. - errNilPushTraceData = errors.New("nil traceDataPusher") - // errNilPushMetricsData is returned when a nil pushMetricsData is given. - errNilPushMetricsData = errors.New("nil pushMetricsData") - // errNilPushLogsData is returned when a nil pushLogsData is given. - errNilPushLogsData = errors.New("nil pushLogsData") + // errNilPushTraceData is returned when a nil PushTraces is given. + errNilPushTraceData = errors.New("nil PushTraces") + // errNilPushMetricsData is returned when a nil PushMetrics is given. + errNilPushMetricsData = errors.New("nil PushMetrics") + // errNilPushLogsData is returned when a nil PushLogs is given. + errNilPushLogsData = errors.New("nil PushLogs") ) diff --git a/exporter/exporterhelper/logshelper.go b/exporter/exporterhelper/logshelper.go index e552399218a..cb79d2b0fd2 100644 --- a/exporter/exporterhelper/logshelper.go +++ b/exporter/exporterhelper/logshelper.go @@ -27,17 +27,17 @@ import ( "go.opentelemetry.io/collector/obsreport" ) -// PushLogsData is a helper function that is similar to ConsumeLogsData but also returns +// PushLogs is a helper function that is similar to ConsumeLogs but also returns // the number of dropped logs. -type PushLogsData func(ctx context.Context, md pdata.Logs) (droppedTimeSeries int, err error) +type PushLogs func(ctx context.Context, md pdata.Logs) (droppedTimeSeries int, err error) type logsRequest struct { baseRequest ld pdata.Logs - pusher PushLogsData + pusher PushLogs } -func newLogsRequest(ctx context.Context, ld pdata.Logs, pusher PushLogsData) request { +func newLogsRequest(ctx context.Context, ld pdata.Logs, pusher PushLogs) request { return &logsRequest{ baseRequest: baseRequest{ctx: ctx}, ld: ld, @@ -59,12 +59,12 @@ func (req *logsRequest) count() int { type logsExporter struct { *baseExporter - pushLogsData PushLogsData + pusher PushLogs } func (lexp *logsExporter) ConsumeLogs(ctx context.Context, ld pdata.Logs) error { exporterCtx := obsreport.ExporterContext(ctx, lexp.cfg.Name()) - _, err := lexp.sender.send(newLogsRequest(exporterCtx, ld, lexp.pushLogsData)) + _, err := lexp.sender.send(newLogsRequest(exporterCtx, ld, lexp.pusher)) return err } @@ -72,7 +72,7 @@ func (lexp *logsExporter) ConsumeLogs(ctx context.Context, ld pdata.Logs) error func NewLogsExporter( cfg configmodels.Exporter, logger *zap.Logger, - pushLogsData PushLogsData, + pusher PushLogs, options ...Option, ) (component.LogsExporter, error) { if cfg == nil { @@ -83,7 +83,7 @@ func NewLogsExporter( return nil, errNilLogger } - if pushLogsData == nil { + if pusher == nil { return nil, errNilPushLogsData } @@ -97,7 +97,7 @@ func NewLogsExporter( return &logsExporter{ baseExporter: be, - pushLogsData: pushLogsData, + pusher: pusher, }, nil } diff --git a/exporter/exporterhelper/logshelper_test.go b/exporter/exporterhelper/logshelper_test.go index e036ceaef4d..9455f7bc68d 100644 --- a/exporter/exporterhelper/logshelper_test.go +++ b/exporter/exporterhelper/logshelper_test.go @@ -163,7 +163,7 @@ func TestLogsExporter_WithShutdown_ReturnError(t *testing.T) { assert.Equal(t, le.Shutdown(context.Background()), want) } -func newPushLogsData(droppedTimeSeries int, retError error) PushLogsData { +func newPushLogsData(droppedTimeSeries int, retError error) PushLogs { return func(ctx context.Context, td pdata.Logs) (int, error) { return droppedTimeSeries, retError } diff --git a/exporter/exporterhelper/metricshelper.go b/exporter/exporterhelper/metricshelper.go index ac1f88e4c2f..013d4672ef7 100644 --- a/exporter/exporterhelper/metricshelper.go +++ b/exporter/exporterhelper/metricshelper.go @@ -27,17 +27,17 @@ import ( "go.opentelemetry.io/collector/obsreport" ) -// PushMetricsData is a helper function that is similar to ConsumeMetricsData but also returns +// PushMetrics is a helper function that is similar to ConsumeMetrics but also returns // the number of dropped metrics. -type PushMetricsData func(ctx context.Context, md pdata.Metrics) (droppedTimeSeries int, err error) +type PushMetrics func(ctx context.Context, md pdata.Metrics) (droppedTimeSeries int, err error) type metricsRequest struct { baseRequest md pdata.Metrics - pusher PushMetricsData + pusher PushMetrics } -func newMetricsRequest(ctx context.Context, md pdata.Metrics, pusher PushMetricsData) request { +func newMetricsRequest(ctx context.Context, md pdata.Metrics, pusher PushMetrics) request { return &metricsRequest{ baseRequest: baseRequest{ctx: ctx}, md: md, @@ -60,7 +60,7 @@ func (req *metricsRequest) count() int { type metricsExporter struct { *baseExporter - pusher PushMetricsData + pusher PushMetrics } func (mexp *metricsExporter) ConsumeMetrics(ctx context.Context, md pdata.Metrics) error { @@ -77,7 +77,7 @@ func (mexp *metricsExporter) ConsumeMetrics(ctx context.Context, md pdata.Metric func NewMetricsExporter( cfg configmodels.Exporter, logger *zap.Logger, - pushMetricsData PushMetricsData, + pusher PushMetrics, options ...Option, ) (component.MetricsExporter, error) { if cfg == nil { @@ -88,7 +88,7 @@ func NewMetricsExporter( return nil, errNilLogger } - if pushMetricsData == nil { + if pusher == nil { return nil, errNilPushMetricsData } @@ -102,7 +102,7 @@ func NewMetricsExporter( return &metricsExporter{ baseExporter: be, - pusher: pushMetricsData, + pusher: pusher, }, nil } diff --git a/exporter/exporterhelper/metricshelper_test.go b/exporter/exporterhelper/metricshelper_test.go index ad1c1da6b5c..4cc0f3a2e62 100644 --- a/exporter/exporterhelper/metricshelper_test.go +++ b/exporter/exporterhelper/metricshelper_test.go @@ -183,7 +183,7 @@ func TestMetricsExporter_WithShutdown_ReturnError(t *testing.T) { assert.Equal(t, me.Shutdown(context.Background()), want) } -func newPushMetricsData(droppedTimeSeries int, retError error) PushMetricsData { +func newPushMetricsData(droppedTimeSeries int, retError error) PushMetrics { return func(ctx context.Context, td pdata.Metrics) (int, error) { return droppedTimeSeries, retError } diff --git a/exporter/exporterhelper/tracehelper.go b/exporter/exporterhelper/tracehelper.go index a94ca63b534..9e6f30a3334 100644 --- a/exporter/exporterhelper/tracehelper.go +++ b/exporter/exporterhelper/tracehelper.go @@ -27,17 +27,17 @@ import ( "go.opentelemetry.io/collector/obsreport" ) -// traceDataPusher is a helper function that is similar to ConsumeTraceData but also +// PushTraces is a helper function that is similar to ConsumeTraces but also // returns the number of dropped spans. -type traceDataPusher func(ctx context.Context, td pdata.Traces) (droppedSpans int, err error) +type PushTraces func(ctx context.Context, td pdata.Traces) (droppedSpans int, err error) type tracesRequest struct { baseRequest td pdata.Traces - pusher traceDataPusher + pusher PushTraces } -func newTracesRequest(ctx context.Context, td pdata.Traces, pusher traceDataPusher) request { +func newTracesRequest(ctx context.Context, td pdata.Traces, pusher PushTraces) request { return &tracesRequest{ baseRequest: baseRequest{ctx: ctx}, td: td, @@ -59,7 +59,7 @@ func (req *tracesRequest) count() int { type traceExporter struct { *baseExporter - pusher traceDataPusher + pusher PushTraces } func (texp *traceExporter) ConsumeTraces(ctx context.Context, td pdata.Traces) error { @@ -73,7 +73,7 @@ func (texp *traceExporter) ConsumeTraces(ctx context.Context, td pdata.Traces) e func NewTraceExporter( cfg configmodels.Exporter, logger *zap.Logger, - dataPusher traceDataPusher, + pusher PushTraces, options ...Option, ) (component.TracesExporter, error) { @@ -85,7 +85,7 @@ func NewTraceExporter( return nil, errNilLogger } - if dataPusher == nil { + if pusher == nil { return nil, errNilPushTraceData } @@ -99,7 +99,7 @@ func NewTraceExporter( return &traceExporter{ baseExporter: be, - pusher: dataPusher, + pusher: pusher, }, nil } diff --git a/exporter/exporterhelper/tracehelper_test.go b/exporter/exporterhelper/tracehelper_test.go index cf953eb1793..9f25d95b3de 100644 --- a/exporter/exporterhelper/tracehelper_test.go +++ b/exporter/exporterhelper/tracehelper_test.go @@ -177,7 +177,7 @@ func TestTraceExporter_WithShutdown_ReturnError(t *testing.T) { assert.Equal(t, te.Shutdown(context.Background()), want) } -func newTraceDataPusher(droppedSpans int, retError error) traceDataPusher { +func newTraceDataPusher(droppedSpans int, retError error) PushTraces { return func(ctx context.Context, td pdata.Traces) (int, error) { return droppedSpans, retError }