Skip to content

Commit 8006b6e

Browse files
Replace ExporterCreateParams with ExporterCreateSettings.
Replace all dependencies in Exporters. Signed-off-by: Patryk Matyjasek <pmatyjasek@sumologic.com> # Conflicts: # exporter/prometheusremotewriteexporter/factory.go
1 parent 25cc9ff commit 8006b6e

File tree

44 files changed

+213
-213
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+213
-213
lines changed

component/componenttest/nop_exporter.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func (f *nopExporterFactory) CreateDefaultConfig() config.Exporter {
5252
// CreateTracesExporter implements component.ExporterFactory interface.
5353
func (f *nopExporterFactory) CreateTracesExporter(
5454
_ context.Context,
55-
_ component.ExporterCreateParams,
55+
_ component.ExporterCreateSettings,
5656
_ config.Exporter,
5757
) (component.TracesExporter, error) {
5858
return nopExporterInstance, nil
@@ -61,7 +61,7 @@ func (f *nopExporterFactory) CreateTracesExporter(
6161
// CreateMetricsExporter implements component.ExporterFactory interface.
6262
func (f *nopExporterFactory) CreateMetricsExporter(
6363
_ context.Context,
64-
_ component.ExporterCreateParams,
64+
_ component.ExporterCreateSettings,
6565
_ config.Exporter,
6666
) (component.MetricsExporter, error) {
6767
return nopExporterInstance, nil
@@ -70,7 +70,7 @@ func (f *nopExporterFactory) CreateMetricsExporter(
7070
// CreateLogsExporter implements component.ExporterFactory interface.
7171
func (f *nopExporterFactory) CreateLogsExporter(
7272
_ context.Context,
73-
_ component.ExporterCreateParams,
73+
_ component.ExporterCreateSettings,
7474
_ config.Exporter,
7575
) (component.LogsExporter, error) {
7676
return nopExporterInstance, nil

component/componenttest/nop_exporter_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,19 @@ func TestNewNopExporterFactory(t *testing.T) {
3333
cfg := factory.CreateDefaultConfig()
3434
assert.Equal(t, &nopExporterConfig{ExporterSettings: config.NewExporterSettings(config.NewID("nop"))}, cfg)
3535

36-
traces, err := factory.CreateTracesExporter(context.Background(), component.ExporterCreateParams{}, cfg)
36+
traces, err := factory.CreateTracesExporter(context.Background(), component.ExporterCreateSettings{}, cfg)
3737
require.NoError(t, err)
3838
assert.NoError(t, traces.Start(context.Background(), NewNopHost()))
3939
assert.NoError(t, traces.ConsumeTraces(context.Background(), pdata.NewTraces()))
4040
assert.NoError(t, traces.Shutdown(context.Background()))
4141

42-
metrics, err := factory.CreateMetricsExporter(context.Background(), component.ExporterCreateParams{}, cfg)
42+
metrics, err := factory.CreateMetricsExporter(context.Background(), component.ExporterCreateSettings{}, cfg)
4343
require.NoError(t, err)
4444
assert.NoError(t, metrics.Start(context.Background(), NewNopHost()))
4545
assert.NoError(t, metrics.ConsumeMetrics(context.Background(), pdata.NewMetrics()))
4646
assert.NoError(t, metrics.Shutdown(context.Background()))
4747

48-
logs, err := factory.CreateLogsExporter(context.Background(), component.ExporterCreateParams{}, cfg)
48+
logs, err := factory.CreateLogsExporter(context.Background(), component.ExporterCreateSettings{}, cfg)
4949
require.NoError(t, err)
5050
assert.NoError(t, logs.Start(context.Background(), NewNopHost()))
5151
assert.NoError(t, logs.ConsumeLogs(context.Background(), pdata.NewLogs()))

component/exporter.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ type LogsExporter interface {
4646
consumer.Logs
4747
}
4848

49-
// ExporterCreateParams configures Exporter creators.
50-
type ExporterCreateParams struct {
49+
// ExporterCreateSettings configures Exporter creators.
50+
type ExporterCreateSettings struct {
5151
// Logger that the factory can use during creation and can pass to the created
5252
// component to be used later as well.
5353
Logger *zap.Logger
@@ -73,18 +73,18 @@ type ExporterFactory interface {
7373
// CreateTracesExporter creates a trace exporter based on this config.
7474
// If the exporter type does not support tracing or if the config is not valid
7575
// error will be returned instead.
76-
CreateTracesExporter(ctx context.Context, params ExporterCreateParams,
76+
CreateTracesExporter(ctx context.Context, set ExporterCreateSettings,
7777
cfg config.Exporter) (TracesExporter, error)
7878

7979
// CreateMetricsExporter creates a metrics exporter based on this config.
8080
// If the exporter type does not support metrics or if the config is not valid
8181
// error will be returned instead.
82-
CreateMetricsExporter(ctx context.Context, params ExporterCreateParams,
82+
CreateMetricsExporter(ctx context.Context, set ExporterCreateSettings,
8383
cfg config.Exporter) (MetricsExporter, error)
8484

8585
// CreateLogsExporter creates an exporter based on the config.
8686
// If the exporter type does not support logs or if the config is not valid
8787
// error will be returned instead.
88-
CreateLogsExporter(ctx context.Context, params ExporterCreateParams,
88+
CreateLogsExporter(ctx context.Context, set ExporterCreateSettings,
8989
cfg config.Exporter) (LogsExporter, error)
9090
}

component/exporter_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@ func (f *TestExporterFactory) CreateDefaultConfig() config.Exporter {
3939
}
4040

4141
// CreateTracesExporter creates a trace exporter based on this config.
42-
func (f *TestExporterFactory) CreateTracesExporter(context.Context, ExporterCreateParams, config.Exporter) (TracesExporter, error) {
42+
func (f *TestExporterFactory) CreateTracesExporter(context.Context, ExporterCreateSettings, config.Exporter) (TracesExporter, error) {
4343
return nil, componenterror.ErrDataTypeIsNotSupported
4444
}
4545

4646
// CreateMetricsExporter creates a metrics exporter based on this config.
47-
func (f *TestExporterFactory) CreateMetricsExporter(context.Context, ExporterCreateParams, config.Exporter) (MetricsExporter, error) {
47+
func (f *TestExporterFactory) CreateMetricsExporter(context.Context, ExporterCreateSettings, config.Exporter) (MetricsExporter, error) {
4848
return nil, componenterror.ErrDataTypeIsNotSupported
4949
}
5050

5151
// CreateLogsExporter creates a logs exporter based on this config.
52-
func (f *TestExporterFactory) CreateLogsExporter(context.Context, ExporterCreateParams, config.Exporter) (LogsExporter, error) {
52+
func (f *TestExporterFactory) CreateLogsExporter(context.Context, ExporterCreateSettings, config.Exporter) (LogsExporter, error) {
5353
return nil, componenterror.ErrDataTypeIsNotSupported
5454
}
5555

exporter/exporterhelper/factory.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ type FactoryOption func(o *factory)
2929
type CreateDefaultConfig func() config.Exporter
3030

3131
// CreateTracesExporter is the equivalent of component.ExporterFactory.CreateTracesExporter()
32-
type CreateTracesExporter func(context.Context, component.ExporterCreateParams, config.Exporter) (component.TracesExporter, error)
32+
type CreateTracesExporter func(context.Context, component.ExporterCreateSettings, config.Exporter) (component.TracesExporter, error)
3333

3434
// CreateMetricsExporter is the equivalent of component.ExporterFactory.CreateMetricsExporter()
35-
type CreateMetricsExporter func(context.Context, component.ExporterCreateParams, config.Exporter) (component.MetricsExporter, error)
35+
type CreateMetricsExporter func(context.Context, component.ExporterCreateSettings, config.Exporter) (component.MetricsExporter, error)
3636

3737
// CreateLogsExporter is the equivalent of component.ExporterFactory.CreateLogsExporter()
38-
type CreateLogsExporter func(context.Context, component.ExporterCreateParams, config.Exporter) (component.LogsExporter, error)
38+
type CreateLogsExporter func(context.Context, component.ExporterCreateSettings, config.Exporter) (component.LogsExporter, error)
3939

4040
type factory struct {
4141
cfgType config.Type
@@ -94,33 +94,33 @@ func (f *factory) CreateDefaultConfig() config.Exporter {
9494
// CreateTracesExporter creates a component.TracesExporter based on this config.
9595
func (f *factory) CreateTracesExporter(
9696
ctx context.Context,
97-
params component.ExporterCreateParams,
97+
set component.ExporterCreateSettings,
9898
cfg config.Exporter) (component.TracesExporter, error) {
9999
if f.createTracesExporter != nil {
100-
return f.createTracesExporter(ctx, params, cfg)
100+
return f.createTracesExporter(ctx, set, cfg)
101101
}
102102
return nil, componenterror.ErrDataTypeIsNotSupported
103103
}
104104

105105
// CreateMetricsExporter creates a component.MetricsExporter based on this config.
106106
func (f *factory) CreateMetricsExporter(
107107
ctx context.Context,
108-
params component.ExporterCreateParams,
108+
set component.ExporterCreateSettings,
109109
cfg config.Exporter) (component.MetricsExporter, error) {
110110
if f.createMetricsExporter != nil {
111-
return f.createMetricsExporter(ctx, params, cfg)
111+
return f.createMetricsExporter(ctx, set, cfg)
112112
}
113113
return nil, componenterror.ErrDataTypeIsNotSupported
114114
}
115115

116116
// CreateLogsExporter creates a metrics processor based on this config.
117117
func (f *factory) CreateLogsExporter(
118118
ctx context.Context,
119-
params component.ExporterCreateParams,
119+
set component.ExporterCreateSettings,
120120
cfg config.Exporter,
121121
) (component.LogsExporter, error) {
122122
if f.createLogsExporter != nil {
123-
return f.createLogsExporter(ctx, params, cfg)
123+
return f.createLogsExporter(ctx, set, cfg)
124124
}
125125
return nil, componenterror.ErrDataTypeIsNotSupported
126126
}

exporter/exporterhelper/factory_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ func TestNewFactory(t *testing.T) {
4848
defaultConfig)
4949
assert.EqualValues(t, typeStr, factory.Type())
5050
assert.EqualValues(t, &defaultCfg, factory.CreateDefaultConfig())
51-
_, err := factory.CreateTracesExporter(context.Background(), component.ExporterCreateParams{Logger: zap.NewNop()}, &defaultCfg)
51+
_, err := factory.CreateTracesExporter(context.Background(), component.ExporterCreateSettings{Logger: zap.NewNop()}, &defaultCfg)
5252
assert.Equal(t, componenterror.ErrDataTypeIsNotSupported, err)
53-
_, err = factory.CreateMetricsExporter(context.Background(), component.ExporterCreateParams{Logger: zap.NewNop()}, &defaultCfg)
53+
_, err = factory.CreateMetricsExporter(context.Background(), component.ExporterCreateSettings{Logger: zap.NewNop()}, &defaultCfg)
5454
assert.Equal(t, componenterror.ErrDataTypeIsNotSupported, err)
55-
_, err = factory.CreateLogsExporter(context.Background(), component.ExporterCreateParams{Logger: zap.NewNop()}, &defaultCfg)
55+
_, err = factory.CreateLogsExporter(context.Background(), component.ExporterCreateSettings{Logger: zap.NewNop()}, &defaultCfg)
5656
assert.Equal(t, componenterror.ErrDataTypeIsNotSupported, err)
5757
}
5858

@@ -66,15 +66,15 @@ func TestNewFactory_WithConstructors(t *testing.T) {
6666
assert.EqualValues(t, typeStr, factory.Type())
6767
assert.EqualValues(t, &defaultCfg, factory.CreateDefaultConfig())
6868

69-
te, err := factory.CreateTracesExporter(context.Background(), component.ExporterCreateParams{Logger: zap.NewNop()}, &defaultCfg)
69+
te, err := factory.CreateTracesExporter(context.Background(), component.ExporterCreateSettings{Logger: zap.NewNop()}, &defaultCfg)
7070
assert.NoError(t, err)
7171
assert.Same(t, nopTracesExporter, te)
7272

73-
me, err := factory.CreateMetricsExporter(context.Background(), component.ExporterCreateParams{Logger: zap.NewNop()}, &defaultCfg)
73+
me, err := factory.CreateMetricsExporter(context.Background(), component.ExporterCreateSettings{Logger: zap.NewNop()}, &defaultCfg)
7474
assert.NoError(t, err)
7575
assert.Same(t, nopMetricsExporter, me)
7676

77-
le, err := factory.CreateLogsExporter(context.Background(), component.ExporterCreateParams{Logger: zap.NewNop()}, &defaultCfg)
77+
le, err := factory.CreateLogsExporter(context.Background(), component.ExporterCreateSettings{Logger: zap.NewNop()}, &defaultCfg)
7878
assert.NoError(t, err)
7979
assert.Same(t, nopLogsExporter, le)
8080
}
@@ -83,14 +83,14 @@ func defaultConfig() config.Exporter {
8383
return &defaultCfg
8484
}
8585

86-
func createTracesExporter(context.Context, component.ExporterCreateParams, config.Exporter) (component.TracesExporter, error) {
86+
func createTracesExporter(context.Context, component.ExporterCreateSettings, config.Exporter) (component.TracesExporter, error) {
8787
return nopTracesExporter, nil
8888
}
8989

90-
func createMetricsExporter(context.Context, component.ExporterCreateParams, config.Exporter) (component.MetricsExporter, error) {
90+
func createMetricsExporter(context.Context, component.ExporterCreateSettings, config.Exporter) (component.MetricsExporter, error) {
9191
return nopMetricsExporter, nil
9292
}
9393

94-
func createLogsExporter(context.Context, component.ExporterCreateParams, config.Exporter) (component.LogsExporter, error) {
94+
func createLogsExporter(context.Context, component.ExporterCreateSettings, config.Exporter) (component.LogsExporter, error) {
9595
return nopLogsExporter, nil
9696
}

exporter/fileexporter/factory.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,35 +46,35 @@ func createDefaultConfig() config.Exporter {
4646

4747
func createTracesExporter(
4848
_ context.Context,
49-
params component.ExporterCreateParams,
49+
set component.ExporterCreateSettings,
5050
cfg config.Exporter,
5151
) (component.TracesExporter, error) {
5252
fe := exporters.GetOrAdd(cfg, func() component.Component {
5353
return &fileExporter{path: cfg.(*Config).Path}
5454
})
55-
return exporterhelper.NewTracesExporter(cfg, params.Logger, fe.Unwrap().(*fileExporter).ConsumeTraces)
55+
return exporterhelper.NewTracesExporter(cfg, set.Logger, fe.Unwrap().(*fileExporter).ConsumeTraces)
5656
}
5757

5858
func createMetricsExporter(
5959
_ context.Context,
60-
params component.ExporterCreateParams,
60+
set component.ExporterCreateSettings,
6161
cfg config.Exporter,
6262
) (component.MetricsExporter, error) {
6363
fe := exporters.GetOrAdd(cfg, func() component.Component {
6464
return &fileExporter{path: cfg.(*Config).Path}
6565
})
66-
return exporterhelper.NewMetricsExporter(cfg, params.Logger, fe.Unwrap().(*fileExporter).ConsumeMetrics)
66+
return exporterhelper.NewMetricsExporter(cfg, set.Logger, fe.Unwrap().(*fileExporter).ConsumeMetrics)
6767
}
6868

6969
func createLogsExporter(
7070
_ context.Context,
71-
params component.ExporterCreateParams,
71+
set component.ExporterCreateSettings,
7272
cfg config.Exporter,
7373
) (component.LogsExporter, error) {
7474
fe := exporters.GetOrAdd(cfg, func() component.Component {
7575
return &fileExporter{path: cfg.(*Config).Path}
7676
})
77-
return exporterhelper.NewLogsExporter(cfg, params.Logger, fe.Unwrap().(*fileExporter).ConsumeLogs)
77+
return exporterhelper.NewLogsExporter(cfg, set.Logger, fe.Unwrap().(*fileExporter).ConsumeLogs)
7878
}
7979

8080
// This is the map of already created File exporters for particular configurations.

exporter/fileexporter/factory_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func TestCreateMetricsExporter(t *testing.T) {
3636
cfg := createDefaultConfig()
3737
exp, err := createMetricsExporter(
3838
context.Background(),
39-
component.ExporterCreateParams{Logger: zap.NewNop()},
39+
component.ExporterCreateSettings{Logger: zap.NewNop()},
4040
cfg)
4141
assert.NoError(t, err)
4242
require.NotNil(t, exp)
@@ -46,7 +46,7 @@ func TestCreateTracesExporter(t *testing.T) {
4646
cfg := createDefaultConfig()
4747
exp, err := createTracesExporter(
4848
context.Background(),
49-
component.ExporterCreateParams{Logger: zap.NewNop()},
49+
component.ExporterCreateSettings{Logger: zap.NewNop()},
5050
cfg)
5151
assert.NoError(t, err)
5252
require.NotNil(t, exp)
@@ -56,7 +56,7 @@ func TestCreateLogsExporter(t *testing.T) {
5656
cfg := createDefaultConfig()
5757
exp, err := createLogsExporter(
5858
context.Background(),
59-
component.ExporterCreateParams{Logger: zap.NewNop()},
59+
component.ExporterCreateSettings{Logger: zap.NewNop()},
6060
cfg)
6161
assert.NoError(t, err)
6262
require.NotNil(t, exp)

exporter/jaegerexporter/config_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ func TestLoadConfig(t *testing.T) {
7171
},
7272
})
7373

74-
params := component.ExporterCreateParams{Logger: zap.NewNop()}
75-
te, err := factory.CreateTracesExporter(context.Background(), params, e1)
74+
set := component.ExporterCreateSettings{Logger: zap.NewNop()}
75+
te, err := factory.CreateTracesExporter(context.Background(), set, e1)
7676
require.NoError(t, err)
7777
require.NotNil(t, te)
7878
}

exporter/jaegerexporter/exporter_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ func TestMutualTLS(t *testing.T) {
223223
ServerName: "localhost",
224224
},
225225
}
226-
exporter, err := factory.CreateTracesExporter(context.Background(), component.ExporterCreateParams{Logger: zap.NewNop()}, cfg)
226+
exporter, err := factory.CreateTracesExporter(context.Background(), component.ExporterCreateSettings{Logger: zap.NewNop()}, cfg)
227227
require.NoError(t, err)
228228
err = exporter.Start(context.Background(), componenttest.NewNopHost())
229229
require.NoError(t, err)

0 commit comments

Comments
 (0)