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

Rename [Traces|Metrics|Logs]Consumer to [Traces|Metrics|Logs] #2761

Merged
merged 2 commits into from
Mar 23, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 7 additions & 7 deletions component/componenttest/nop_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,16 @@ func (f *nopExporterFactory) CreateLogsExporter(
}

var nopExporterInstance = &nopExporter{
Component: componenthelper.NewComponent(componenthelper.DefaultComponentSettings()),
TracesConsumer: consumertest.NewTracesNop(),
MetricsConsumer: consumertest.NewMetricsNop(),
LogsConsumer: consumertest.NewLogsNop(),
Component: componenthelper.NewComponent(componenthelper.DefaultComponentSettings()),
Traces: consumertest.NewTracesNop(),
Metrics: consumertest.NewMetricsNop(),
Logs: consumertest.NewLogsNop(),
}

// nopExporter stores consumed traces and metrics for testing purposes.
type nopExporter struct {
component.Component
consumer.TracesConsumer
consumer.MetricsConsumer
consumer.LogsConsumer
consumer.Traces
consumer.Metrics
consumer.Logs
}
20 changes: 10 additions & 10 deletions component/componenttest/nop_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (f *nopProcessorFactory) CreateTracesProcessor(
_ context.Context,
_ component.ProcessorCreateParams,
_ configmodels.Processor,
_ consumer.TracesConsumer,
_ consumer.Traces,
) (component.TracesProcessor, error) {
return nopProcessorInstance, nil
}
Expand All @@ -61,7 +61,7 @@ func (f *nopProcessorFactory) CreateMetricsProcessor(
_ context.Context,
_ component.ProcessorCreateParams,
_ configmodels.Processor,
_ consumer.MetricsConsumer,
_ consumer.Metrics,
) (component.MetricsProcessor, error) {
return nopProcessorInstance, nil
}
Expand All @@ -71,24 +71,24 @@ func (f *nopProcessorFactory) CreateLogsProcessor(
_ context.Context,
_ component.ProcessorCreateParams,
_ configmodels.Processor,
_ consumer.LogsConsumer,
_ consumer.Logs,
) (component.LogsProcessor, error) {
return nopProcessorInstance, nil
}

var nopProcessorInstance = &nopProcessor{
Component: componenthelper.NewComponent(componenthelper.DefaultComponentSettings()),
TracesConsumer: consumertest.NewTracesNop(),
MetricsConsumer: consumertest.NewMetricsNop(),
LogsConsumer: consumertest.NewLogsNop(),
Component: componenthelper.NewComponent(componenthelper.DefaultComponentSettings()),
Traces: consumertest.NewTracesNop(),
Metrics: consumertest.NewMetricsNop(),
Logs: consumertest.NewLogsNop(),
}

// nopProcessor stores consumed traces and metrics for testing purposes.
type nopProcessor struct {
component.Component
consumer.TracesConsumer
consumer.MetricsConsumer
consumer.LogsConsumer
consumer.Traces
consumer.Metrics
consumer.Logs
}

func (*nopProcessor) GetCapabilities() component.ProcessorCapabilities {
Expand Down
6 changes: 3 additions & 3 deletions component/componenttest/nop_receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (f *nopReceiverFactory) CreateTracesReceiver(
_ context.Context,
_ component.ReceiverCreateParams,
_ configmodels.Receiver,
_ consumer.TracesConsumer,
_ consumer.Traces,
) (component.TracesReceiver, error) {
return nopReceiverInstance, nil
}
Expand All @@ -60,7 +60,7 @@ func (f *nopReceiverFactory) CreateMetricsReceiver(
_ context.Context,
_ component.ReceiverCreateParams,
_ configmodels.Receiver,
_ consumer.MetricsConsumer,
_ consumer.Metrics,
) (component.MetricsReceiver, error) {
return nopReceiverInstance, nil
}
Expand All @@ -70,7 +70,7 @@ func (f *nopReceiverFactory) CreateLogsReceiver(
_ context.Context,
_ component.ReceiverCreateParams,
_ configmodels.Receiver,
_ consumer.LogsConsumer,
_ consumer.Logs,
) (component.LogsReceiver, error) {
return nopReceiverInstance, nil
}
Expand Down
6 changes: 3 additions & 3 deletions component/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ type Exporter interface {
// TracesExporter is a Exporter that can consume traces.
type TracesExporter interface {
Exporter
consumer.TracesConsumer
consumer.Traces
}

// MetricsExporter is an Exporter that can consume metrics.
type MetricsExporter interface {
Exporter
consumer.MetricsConsumer
consumer.Metrics
}

// LogsExporter is an Exporter that can consume logs.
type LogsExporter interface {
Exporter
consumer.LogsConsumer
consumer.Logs
}

// ExporterCreateParams is passed to Create*Exporter functions.
Expand Down
12 changes: 6 additions & 6 deletions component/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ type Processor interface {
// TracesProcessor is a processor that can consume traces.
type TracesProcessor interface {
Processor
consumer.TracesConsumer
consumer.Traces
}

// MetricsProcessor is a processor that can consume metrics.
type MetricsProcessor interface {
Processor
consumer.MetricsConsumer
consumer.Metrics
}

// LogsProcessor is a processor that can consume logs.
type LogsProcessor interface {
Processor
consumer.LogsConsumer
consumer.Logs
}

// ProcessorCapabilities describes the capabilities of a Processor.
Expand Down Expand Up @@ -91,7 +91,7 @@ type ProcessorFactory interface {
ctx context.Context,
params ProcessorCreateParams,
cfg configmodels.Processor,
nextConsumer consumer.TracesConsumer,
nextConsumer consumer.Traces,
) (TracesProcessor, error)

// CreateMetricsProcessor creates a metrics processor based on this config.
Expand All @@ -101,7 +101,7 @@ type ProcessorFactory interface {
ctx context.Context,
params ProcessorCreateParams,
cfg configmodels.Processor,
nextConsumer consumer.MetricsConsumer,
nextConsumer consumer.Metrics,
) (MetricsProcessor, error)

// CreateLogsProcessor creates a processor based on the config.
Expand All @@ -111,6 +111,6 @@ type ProcessorFactory interface {
ctx context.Context,
params ProcessorCreateParams,
cfg configmodels.Processor,
nextConsumer consumer.LogsConsumer,
nextConsumer consumer.Logs,
) (LogsProcessor, error)
}
6 changes: 3 additions & 3 deletions component/processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ func (f *TestProcessorFactory) CreateDefaultConfig() configmodels.Processor {
}

// CreateTraceProcessor creates a trace processor based on this config.
func (f *TestProcessorFactory) CreateTracesProcessor(context.Context, ProcessorCreateParams, configmodels.Processor, consumer.TracesConsumer) (TracesProcessor, error) {
func (f *TestProcessorFactory) CreateTracesProcessor(context.Context, ProcessorCreateParams, configmodels.Processor, consumer.Traces) (TracesProcessor, error) {
return nil, configerror.ErrDataTypeIsNotSupported
}

// CreateMetricsProcessor creates a metrics processor based on this config.
func (f *TestProcessorFactory) CreateMetricsProcessor(context.Context, ProcessorCreateParams, configmodels.Processor, consumer.MetricsConsumer) (MetricsProcessor, error) {
func (f *TestProcessorFactory) CreateMetricsProcessor(context.Context, ProcessorCreateParams, configmodels.Processor, consumer.Metrics) (MetricsProcessor, error) {
return nil, configerror.ErrDataTypeIsNotSupported
}

// CreateMetricsProcessor creates a metrics processor based on this config.
func (f *TestProcessorFactory) CreateLogsProcessor(context.Context, ProcessorCreateParams, configmodels.Processor, consumer.LogsConsumer) (LogsProcessor, error) {
func (f *TestProcessorFactory) CreateLogsProcessor(context.Context, ProcessorCreateParams, configmodels.Processor, consumer.Logs) (LogsProcessor, error) {
return nil, configerror.ErrDataTypeIsNotSupported
}

Expand Down
12 changes: 6 additions & 6 deletions component/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type Receiver interface {

// A TracesReceiver is an "arbitrary data"-to-"internal format" converter.
// Its purpose is to translate data from the wild into internal trace format.
// TracesReceiver feeds a consumer.TracesConsumer with data.
// TracesReceiver feeds a consumer.Traces with data.
//
// For example it could be Zipkin data source which translates Zipkin spans into pdata.Traces.
type TracesReceiver interface {
Expand All @@ -39,7 +39,7 @@ type TracesReceiver interface {

// A MetricsReceiver is an "arbitrary data"-to-"internal format" converter.
// Its purpose is to translate data from the wild into internal metrics format.
// MetricsReceiver feeds a consumer.MetricsConsumer with data.
// MetricsReceiver feeds a consumer.Metrics with data.
//
// For example it could be Prometheus data source which translates Prometheus metrics into pdata.Metrics.
type MetricsReceiver interface {
Expand All @@ -48,7 +48,7 @@ type MetricsReceiver interface {

// A LogsReceiver is a "log data"-to-"internal format" converter.
// Its purpose is to translate data from the wild into internal data format.
// LogsReceiver feeds a consumer.LogsConsumer with data.
// LogsReceiver feeds a consumer.Logs with data.
type LogsReceiver interface {
Receiver
}
Expand Down Expand Up @@ -81,17 +81,17 @@ type ReceiverFactory interface {
// If the receiver type does not support tracing or if the config is not valid
// error will be returned instead.
CreateTracesReceiver(ctx context.Context, params ReceiverCreateParams,
cfg configmodels.Receiver, nextConsumer consumer.TracesConsumer) (TracesReceiver, error)
cfg configmodels.Receiver, nextConsumer consumer.Traces) (TracesReceiver, error)

// CreateMetricsReceiver creates a metrics receiver based on this config.
// If the receiver type does not support metrics or if the config is not valid
// error will be returned instead.
CreateMetricsReceiver(ctx context.Context, params ReceiverCreateParams,
cfg configmodels.Receiver, nextConsumer consumer.MetricsConsumer) (MetricsReceiver, error)
cfg configmodels.Receiver, nextConsumer consumer.Metrics) (MetricsReceiver, error)

// CreateLogsReceiver creates a log receiver based on this config.
// If the receiver type does not support the data type or if the config is not valid
// error will be returned instead.
CreateLogsReceiver(ctx context.Context, params ReceiverCreateParams,
cfg configmodels.Receiver, nextConsumer consumer.LogsConsumer) (LogsReceiver, error)
cfg configmodels.Receiver, nextConsumer consumer.Logs) (LogsReceiver, error)
}
6 changes: 3 additions & 3 deletions component/receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ func (f *TestReceiverFactory) CreateDefaultConfig() configmodels.Receiver {
}

// CreateTraceReceiver creates a trace receiver based on this config.
func (f *TestReceiverFactory) CreateTracesReceiver(context.Context, ReceiverCreateParams, configmodels.Receiver, consumer.TracesConsumer) (TracesReceiver, error) {
func (f *TestReceiverFactory) CreateTracesReceiver(context.Context, ReceiverCreateParams, configmodels.Receiver, consumer.Traces) (TracesReceiver, error) {
return nil, configerror.ErrDataTypeIsNotSupported
}

// CreateMetricsReceiver creates a metrics receiver based on this config.
func (f *TestReceiverFactory) CreateMetricsReceiver(context.Context, ReceiverCreateParams, configmodels.Receiver, consumer.MetricsConsumer) (MetricsReceiver, error) {
func (f *TestReceiverFactory) CreateMetricsReceiver(context.Context, ReceiverCreateParams, configmodels.Receiver, consumer.Metrics) (MetricsReceiver, error) {
return nil, configerror.ErrDataTypeIsNotSupported
}

// CreateMetricsReceiver creates a metrics receiver based on this config.
func (f *TestReceiverFactory) CreateLogsReceiver(context.Context, ReceiverCreateParams, configmodels.Receiver, consumer.LogsConsumer) (LogsReceiver, error) {
func (f *TestReceiverFactory) CreateLogsReceiver(context.Context, ReceiverCreateParams, configmodels.Receiver, consumer.Logs) (LogsReceiver, error) {
return nil, configerror.ErrDataTypeIsNotSupported
}

Expand Down
12 changes: 6 additions & 6 deletions consumer/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@ import (
"go.opentelemetry.io/collector/consumer/pdata"
)

// MetricsConsumer is the new metrics consumer interface that receives pdata.Metrics, processes it
// Metrics is the new metrics consumer interface that receives pdata.Metrics, processes it
// as needed, and sends it to the next processing node if any or to the destination.
type MetricsConsumer interface {
type Metrics interface {
// ConsumeMetrics receives pdata.Metrics for consumption.
ConsumeMetrics(ctx context.Context, md pdata.Metrics) error
}

// TracesConsumer is an interface that receives pdata.Traces, processes it
// Traces is an interface that receives pdata.Traces, processes it
// as needed, and sends it to the next processing node if any or to the destination.
type TracesConsumer interface {
type Traces interface {
// ConsumeTraces receives pdata.Traces for consumption.
ConsumeTraces(ctx context.Context, td pdata.Traces) error
}

// LogsConsumer is an interface that receives pdata.Logs, processes it
// Logs is an interface that receives pdata.Logs, processes it
// as needed, and sends it to the next processing node if any or to the destination.
type LogsConsumer interface {
type Logs interface {
// ConsumeLogs receives pdata.Logs for consumption.
ConsumeLogs(ctx context.Context, ld pdata.Logs) error
}
12 changes: 6 additions & 6 deletions consumer/consumertest/err.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ func (er *errConsumer) ConsumeLogs(context.Context, pdata.Logs) error {
return er.err
}

// NewTracesErr returns a consumer.TracesConsumer that just drops all received data and returns the given error.
func NewTracesErr(err error) consumer.TracesConsumer {
// NewTracesErr returns a consumer.Traces that just drops all received data and returns the given error.
func NewTracesErr(err error) consumer.Traces {
return &errConsumer{err: err}
}

// NewMetricsErr returns a consumer.MetricsConsumer that just drops all received data and returns the given error.
func NewMetricsErr(err error) consumer.MetricsConsumer {
// NewMetricsErr returns a consumer.Metrics that just drops all received data and returns the given error.
func NewMetricsErr(err error) consumer.Metrics {
return &errConsumer{err: err}
}

// NewLogsErr returns a consumer.LogsConsumer that just drops all received data and returns the given error.
func NewLogsErr(err error) consumer.LogsConsumer {
// NewLogsErr returns a consumer.Logs that just drops all received data and returns the given error.
func NewLogsErr(err error) consumer.Logs {
return &errConsumer{err: err}
}
12 changes: 6 additions & 6 deletions consumer/consumertest/nop.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ func (nc *nopConsumer) ConsumeLogs(context.Context, pdata.Logs) error {
return nil
}

// NewTracesNop returns a consumer.TracesConsumer that just drops all received data and returns no error.
func NewTracesNop() consumer.TracesConsumer {
// NewTracesNop returns a consumer.Traces that just drops all received data and returns no error.
func NewTracesNop() consumer.Traces {
return nopInstance
}

// NewMetricsNop returns a consumer.MetricsConsumer that just drops all received data and returns no error.
func NewMetricsNop() consumer.MetricsConsumer {
// NewMetricsNop returns a consumer.Metrics that just drops all received data and returns no error.
func NewMetricsNop() consumer.Metrics {
return nopInstance
}

// NewLogsNop returns a consumer.LogsConsumer that just drops all received data and returns no error.
func NewLogsNop() consumer.LogsConsumer {
// NewLogsNop returns a consumer.Logs that just drops all received data and returns no error.
func NewLogsNop() consumer.Logs {
return nopInstance
}
12 changes: 6 additions & 6 deletions consumer/consumertest/sink.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ import (
"go.opentelemetry.io/collector/consumer/pdata"
)

// TracesSink is a consumer.TracesConsumer that acts like a sink that
// TracesSink is a consumer.Traces that acts like a sink that
// stores all traces and allows querying them for testing.
type TracesSink struct {
mu sync.Mutex
traces []pdata.Traces
spansCount int
}

var _ consumer.TracesConsumer = (*TracesSink)(nil)
var _ consumer.Traces = (*TracesSink)(nil)

// ConsumeTraces stores traces to this sink.
func (ste *TracesSink) ConsumeTraces(_ context.Context, td pdata.Traces) error {
Expand Down Expand Up @@ -69,15 +69,15 @@ func (ste *TracesSink) Reset() {
ste.spansCount = 0
}

// MetricsSink is a consumer.MetricsConsumer that acts like a sink that
// MetricsSink is a consumer.Metrics that acts like a sink that
// stores all metrics and allows querying them for testing.
type MetricsSink struct {
mu sync.Mutex
metrics []pdata.Metrics
metricsCount int
}

var _ consumer.MetricsConsumer = (*MetricsSink)(nil)
var _ consumer.Metrics = (*MetricsSink)(nil)

// ConsumeMetrics stores metrics to this sink.
func (sme *MetricsSink) ConsumeMetrics(_ context.Context, md pdata.Metrics) error {
Expand Down Expand Up @@ -116,15 +116,15 @@ func (sme *MetricsSink) Reset() {
sme.metricsCount = 0
}

// LogsSink is a consumer.LogsConsumer that acts like a sink that
// LogsSink is a consumer.Logs that acts like a sink that
// stores all logs and allows querying them for testing.
type LogsSink struct {
mu sync.Mutex
logs []pdata.Logs
logRecordsCount int
}

var _ consumer.LogsConsumer = (*LogsSink)(nil)
var _ consumer.Logs = (*LogsSink)(nil)

// ConsumeLogs stores logs to this sink.
func (sle *LogsSink) ConsumeLogs(_ context.Context, ld pdata.Logs) error {
Expand Down
Loading