Skip to content

Commit 4eab95a

Browse files
committed
[receiver/kafka][exporter/kafka] Do not expose programmatic API via NewFactory
1 parent bef122e commit 4eab95a

File tree

4 files changed

+68
-32
lines changed

4 files changed

+68
-32
lines changed

.chloggen/implement_factory_api.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: breaking
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: kakfaexporter
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Disable exposing factory options programmatically on NewFactory.
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: []
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: [api]
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: breaking
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: kafkareceiver
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Disable exposing factory options programmatically on NewFactory.
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: []
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: [api]

exporter/kafkaexporter/factory.go

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,14 @@ const (
2727
defaultPartitionLogsByResourceAttributesEnabled = false
2828
)
2929

30-
// FactoryOption applies changes to kafkaExporterFactory.
31-
type FactoryOption func(factory *kafkaExporterFactory)
32-
3330
// NewFactory creates Kafka exporter factory.
34-
func NewFactory(options ...FactoryOption) exporter.Factory {
35-
f := &kafkaExporterFactory{}
36-
for _, o := range options {
37-
o(f)
38-
}
31+
func NewFactory() exporter.Factory {
3932
return exporter.NewFactory(
4033
metadata.Type,
4134
createDefaultConfig,
42-
exporter.WithTraces(f.createTracesExporter, metadata.TracesStability),
43-
exporter.WithMetrics(f.createMetricsExporter, metadata.MetricsStability),
44-
exporter.WithLogs(f.createLogsExporter, metadata.LogsStability),
35+
exporter.WithTraces(createTracesExporter, metadata.TracesStability),
36+
exporter.WithMetrics(createMetricsExporter, metadata.MetricsStability),
37+
exporter.WithLogs(createLogsExporter, metadata.LogsStability),
4538
)
4639
}
4740

@@ -60,9 +53,7 @@ func createDefaultConfig() component.Config {
6053
}
6154
}
6255

63-
type kafkaExporterFactory struct{}
64-
65-
func (f *kafkaExporterFactory) createTracesExporter(
56+
func createTracesExporter(
6657
ctx context.Context,
6758
set exporter.Settings,
6859
cfg component.Config,
@@ -90,7 +81,7 @@ func (f *kafkaExporterFactory) createTracesExporter(
9081
exporterhelper.WithShutdown(exp.Close))
9182
}
9283

93-
func (f *kafkaExporterFactory) createMetricsExporter(
84+
func createMetricsExporter(
9485
ctx context.Context,
9586
set exporter.Settings,
9687
cfg component.Config,
@@ -118,7 +109,7 @@ func (f *kafkaExporterFactory) createMetricsExporter(
118109
exporterhelper.WithShutdown(exp.Close))
119110
}
120111

121-
func (f *kafkaExporterFactory) createLogsExporter(
112+
func createLogsExporter(
122113
ctx context.Context,
123114
set exporter.Settings,
124115
cfg component.Config,

receiver/kafkareceiver/factory.go

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,14 @@ const (
4444

4545
var errUnrecognizedEncoding = errors.New("unrecognized encoding")
4646

47-
// FactoryOption applies changes to kafkaExporterFactory.
48-
type FactoryOption func(factory *kafkaReceiverFactory)
49-
5047
// NewFactory creates Kafka receiver factory.
51-
func NewFactory(options ...FactoryOption) receiver.Factory {
52-
f := &kafkaReceiverFactory{}
53-
for _, o := range options {
54-
o(f)
55-
}
48+
func NewFactory() receiver.Factory {
5649
return receiver.NewFactory(
5750
metadata.Type,
5851
createDefaultConfig,
59-
receiver.WithTraces(f.createTracesReceiver, metadata.TracesStability),
60-
receiver.WithMetrics(f.createMetricsReceiver, metadata.MetricsStability),
61-
receiver.WithLogs(f.createLogsReceiver, metadata.LogsStability),
52+
receiver.WithTraces(createTracesReceiver, metadata.TracesStability),
53+
receiver.WithMetrics(createMetricsReceiver, metadata.MetricsStability),
54+
receiver.WithLogs(createLogsReceiver, metadata.LogsStability),
6255
)
6356
}
6457

@@ -89,9 +82,7 @@ func createDefaultConfig() component.Config {
8982
}
9083
}
9184

92-
type kafkaReceiverFactory struct{}
93-
94-
func (f *kafkaReceiverFactory) createTracesReceiver(
85+
func createTracesReceiver(
9586
_ context.Context,
9687
set receiver.Settings,
9788
cfg component.Config,
@@ -109,7 +100,7 @@ func (f *kafkaReceiverFactory) createTracesReceiver(
109100
return r, nil
110101
}
111102

112-
func (f *kafkaReceiverFactory) createMetricsReceiver(
103+
func createMetricsReceiver(
113104
_ context.Context,
114105
set receiver.Settings,
115106
cfg component.Config,
@@ -127,7 +118,7 @@ func (f *kafkaReceiverFactory) createMetricsReceiver(
127118
return r, nil
128119
}
129120

130-
func (f *kafkaReceiverFactory) createLogsReceiver(
121+
func createLogsReceiver(
131122
_ context.Context,
132123
set receiver.Settings,
133124
cfg component.Config,

0 commit comments

Comments
 (0)