Skip to content

Commit

Permalink
Rename Push functions to be consistent across signals in exporterhelper
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <[email protected]>
  • Loading branch information
bogdandrutu committed Nov 23, 2020
1 parent cc0a999 commit c02b0fe
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 34 deletions.
12 changes: 6 additions & 6 deletions exporter/exporterhelper/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)
18 changes: 9 additions & 9 deletions exporter/exporterhelper/logshelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -59,20 +59,20 @@ 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
}

// NewLogsExporter creates an LogsExporter that records observability metrics and wraps every request with a Span.
func NewLogsExporter(
cfg configmodels.Exporter,
logger *zap.Logger,
pushLogsData PushLogsData,
pusher PushLogs,
options ...Option,
) (component.LogsExporter, error) {
if cfg == nil {
Expand All @@ -83,7 +83,7 @@ func NewLogsExporter(
return nil, errNilLogger
}

if pushLogsData == nil {
if pusher == nil {
return nil, errNilPushLogsData
}

Expand All @@ -97,7 +97,7 @@ func NewLogsExporter(

return &logsExporter{
baseExporter: be,
pushLogsData: pushLogsData,
pusher: pusher,
}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion exporter/exporterhelper/logshelper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
16 changes: 8 additions & 8 deletions exporter/exporterhelper/metricshelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -88,7 +88,7 @@ func NewMetricsExporter(
return nil, errNilLogger
}

if pushMetricsData == nil {
if pusher == nil {
return nil, errNilPushMetricsData
}

Expand All @@ -102,7 +102,7 @@ func NewMetricsExporter(

return &metricsExporter{
baseExporter: be,
pusher: pushMetricsData,
pusher: pusher,
}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion exporter/exporterhelper/metricshelper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
16 changes: 8 additions & 8 deletions exporter/exporterhelper/tracehelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 {
Expand All @@ -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) {

Expand All @@ -85,7 +85,7 @@ func NewTraceExporter(
return nil, errNilLogger
}

if dataPusher == nil {
if pusher == nil {
return nil, errNilPushTraceData
}

Expand All @@ -99,7 +99,7 @@ func NewTraceExporter(

return &traceExporter{
baseExporter: be,
pusher: dataPusher,
pusher: pusher,
}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion exporter/exporterhelper/tracehelper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit c02b0fe

Please sign in to comment.