Skip to content

Commit

Permalink
Fix small nits in service/internal/builder (#4324)
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <[email protected]>
  • Loading branch information
bogdandrutu authored Oct 30, 2021
1 parent 09f1cf2 commit ac25e4e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions service/internal/builder/exporters_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ func (bexp *builtExporter) getTracesExporter() component.TracesExporter {
return exp.(component.TracesExporter)
}

func (bexp *builtExporter) getMetricExporter() component.MetricsExporter {
func (bexp *builtExporter) getMetricsExporter() component.MetricsExporter {
exp := bexp.expByDataType[config.MetricsDataType]
if exp == nil {
return nil
}
return exp.(component.MetricsExporter)
}

func (bexp *builtExporter) getLogExporter() component.LogsExporter {
func (bexp *builtExporter) getLogsExporter() component.LogsExporter {
exp := bexp.expByDataType[config.LogsDataType]
if exp == nil {
return nil
Expand Down Expand Up @@ -149,7 +149,7 @@ func BuildExporters(

exporters := make(Exporters)

// Build exporters exporters based on configuration and required input data types.
// Build exporters based on configuration and required input data types.
for expID, expCfg := range cfg.Exporters {
set := component.ExporterCreateSettings{
TelemetrySettings: component.TelemetrySettings{
Expand Down
16 changes: 8 additions & 8 deletions service/internal/builder/exporters_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ func TestBuildExporters(t *testing.T) {
// Ensure exporter has its fields correctly populated.
require.NotNil(t, e1)
assert.NotNil(t, e1.getTracesExporter())
assert.Nil(t, e1.getMetricExporter())
assert.Nil(t, e1.getLogExporter())
assert.Nil(t, e1.getMetricsExporter())
assert.Nil(t, e1.getLogsExporter())

// Ensure it can be started.
assert.NoError(t, exporters.StartAll(context.Background(), componenttest.NewNopHost()))
Expand All @@ -97,8 +97,8 @@ func TestBuildExporters(t *testing.T) {
// Ensure exporter has its fields correctly populated, ie TracesExporter and MetricsExporter are nil.
require.NotNil(t, e1)
assert.Nil(t, e1.getTracesExporter())
assert.Nil(t, e1.getMetricExporter())
assert.Nil(t, e1.getLogExporter())
assert.Nil(t, e1.getMetricsExporter())
assert.Nil(t, e1.getLogsExporter())

// TODO: once we have an exporter that supports metrics data type test it too.
}
Expand Down Expand Up @@ -134,9 +134,9 @@ func TestBuildExporters_BuildLogs(t *testing.T) {

// Ensure exporter has its fields correctly populated.
require.NotNil(t, e1)
assert.NotNil(t, e1.getLogExporter())
assert.NotNil(t, e1.getLogsExporter())
assert.Nil(t, e1.getTracesExporter())
assert.Nil(t, e1.getMetricExporter())
assert.Nil(t, e1.getMetricsExporter())

// Ensure it can be started.
err = exporters.StartAll(context.Background(), componenttest.NewNopHost())
Expand All @@ -160,8 +160,8 @@ func TestBuildExporters_BuildLogs(t *testing.T) {
// Metrics Exporter are nil.
require.NotNil(t, e1)
assert.Nil(t, e1.getTracesExporter())
assert.Nil(t, e1.getMetricExporter())
assert.Nil(t, e1.getLogExporter())
assert.Nil(t, e1.getMetricsExporter())
assert.Nil(t, e1.getLogsExporter())
}

func TestBuildExporters_StartStopAll(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions service/internal/builder/pipelines_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ func (pb *pipelinesBuilder) buildFanoutExportersMetricsConsumer(exporterIDs []co

var exporters []consumer.Metrics
for _, builtExp := range builtExporters {
exporters = append(exporters, builtExp.getMetricExporter())
exporters = append(exporters, builtExp.getMetricsExporter())
}

// Create a junction point that fans out to all exporters.
Expand All @@ -271,7 +271,7 @@ func (pb *pipelinesBuilder) buildFanoutExportersLogsConsumer(exporterIDs []confi

exporters := make([]consumer.Logs, len(builtExporters))
for i, builtExp := range builtExporters {
exporters[i] = builtExp.getLogExporter()
exporters[i] = builtExp.getLogsExporter()
}

// Create a junction point that fans out to all exporters.
Expand Down
2 changes: 1 addition & 1 deletion service/internal/builder/pipelines_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func TestBuildPipelines_BuildVarious(t *testing.T) {
// First check that there are no logs in the exporters yet.
var exporterConsumers []*testcomponents.ExampleExporterConsumer
for _, exporter := range exporters {
expConsumer := exporter.getLogExporter().(*testcomponents.ExampleExporterConsumer)
expConsumer := exporter.getLogsExporter().(*testcomponents.ExampleExporterConsumer)
exporterConsumers = append(exporterConsumers, expConsumer)
require.Equal(t, len(expConsumer.Logs), 0)
}
Expand Down
6 changes: 3 additions & 3 deletions service/internal/builder/receivers_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func testReceivers(t *testing.T, test testCase) {

// Validate metrics.
if test.hasMetrics {
metricsConsumer := exporter.getMetricExporter().(*testcomponents.ExampleExporterConsumer)
metricsConsumer := exporter.getMetricsExporter().(*testcomponents.ExampleExporterConsumer)
require.Equal(t, 1, len(metricsConsumer.Metrics))
assert.EqualValues(t, md, metricsConsumer.Metrics[0])
}
Expand Down Expand Up @@ -230,7 +230,7 @@ func TestBuildReceivers_BuildCustom(t *testing.T) {

// First check that there are no traces in the exporters yet.
for _, exporter := range exporters {
consumer := exporter.getLogExporter().(*testcomponents.ExampleExporterConsumer)
consumer := exporter.getLogsExporter().(*testcomponents.ExampleExporterConsumer)
require.Equal(t, len(consumer.Logs), 0)
}

Expand All @@ -245,7 +245,7 @@ func TestBuildReceivers_BuildCustom(t *testing.T) {
exporter := allExporters[expID]

// Validate exported data.
consumer := exporter.getLogExporter().(*testcomponents.ExampleExporterConsumer)
consumer := exporter.getLogsExporter().(*testcomponents.ExampleExporterConsumer)
require.Equal(t, 1, len(consumer.Logs))
assert.EqualValues(t, log, consumer.Logs[0])
}
Expand Down

0 comments on commit ac25e4e

Please sign in to comment.