diff --git a/.chloggen/kafkareceiver-checkapi.yaml b/.chloggen/kafkareceiver-checkapi.yaml new file mode 100644 index 000000000000..98b8e7df1a3c --- /dev/null +++ b/.chloggen/kafkareceiver-checkapi.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: breaking + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: kafkareceiver + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Do not export the function `WithTracesUnmarshalers`, `WithMetricsUnmarshalers`, `WithLogsUnmarshalers` + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [26304] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: + +# If your change doesn't affect end users or the exported elements of any package, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [api] diff --git a/cmd/checkapi/allowlist.txt b/cmd/checkapi/allowlist.txt index f63baf5214a7..c5632e7c69e2 100644 --- a/cmd/checkapi/allowlist.txt +++ b/cmd/checkapi/allowlist.txt @@ -1,4 +1,3 @@ connector/servicegraphconnector extension/observer -processor/servicegraphprocessor -receiver/kafkareceiver +processor/servicegraphprocessor \ No newline at end of file diff --git a/receiver/kafkareceiver/factory.go b/receiver/kafkareceiver/factory.go index cbcadf3233a8..fab1bcb8e345 100644 --- a/receiver/kafkareceiver/factory.go +++ b/receiver/kafkareceiver/factory.go @@ -40,8 +40,8 @@ const ( // FactoryOption applies changes to kafkaExporterFactory. type FactoryOption func(factory *kafkaReceiverFactory) -// WithTracesUnmarshalers adds Unmarshalers. -func WithTracesUnmarshalers(tracesUnmarshalers ...TracesUnmarshaler) FactoryOption { +// withTracesUnmarshalers adds Unmarshalers. +func withTracesUnmarshalers(tracesUnmarshalers ...TracesUnmarshaler) FactoryOption { return func(factory *kafkaReceiverFactory) { for _, unmarshaler := range tracesUnmarshalers { factory.tracesUnmarshalers[unmarshaler.Encoding()] = unmarshaler @@ -49,8 +49,8 @@ func WithTracesUnmarshalers(tracesUnmarshalers ...TracesUnmarshaler) FactoryOpti } } -// WithMetricsUnmarshalers adds MetricsUnmarshalers. -func WithMetricsUnmarshalers(metricsUnmarshalers ...MetricsUnmarshaler) FactoryOption { +// withMetricsUnmarshalers adds MetricsUnmarshalers. +func withMetricsUnmarshalers(metricsUnmarshalers ...MetricsUnmarshaler) FactoryOption { return func(factory *kafkaReceiverFactory) { for _, unmarshaler := range metricsUnmarshalers { factory.metricsUnmarshalers[unmarshaler.Encoding()] = unmarshaler @@ -58,8 +58,8 @@ func WithMetricsUnmarshalers(metricsUnmarshalers ...MetricsUnmarshaler) FactoryO } } -// WithLogsUnmarshalers adds LogsUnmarshalers. -func WithLogsUnmarshalers(logsUnmarshalers ...LogsUnmarshaler) FactoryOption { +// withLogsUnmarshalers adds LogsUnmarshalers. +func withLogsUnmarshalers(logsUnmarshalers ...LogsUnmarshaler) FactoryOption { return func(factory *kafkaReceiverFactory) { for _, unmarshaler := range logsUnmarshalers { factory.logsUnmarshalers[unmarshaler.Encoding()] = unmarshaler @@ -69,7 +69,7 @@ func WithLogsUnmarshalers(logsUnmarshalers ...LogsUnmarshaler) FactoryOption { // NewFactory creates Kafka receiver factory. func NewFactory(options ...FactoryOption) receiver.Factory { - _ = view.Register(MetricViews()...) + _ = view.Register(metricViews()...) f := &kafkaReceiverFactory{ tracesUnmarshalers: defaultTracesUnmarshalers(), diff --git a/receiver/kafkareceiver/factory_test.go b/receiver/kafkareceiver/factory_test.go index 6df28bdef17a..8dbcff101f96 100644 --- a/receiver/kafkareceiver/factory_test.go +++ b/receiver/kafkareceiver/factory_test.go @@ -51,7 +51,7 @@ func TestCreateTracesReceiver_error(t *testing.T) { func TestWithTracesUnmarshalers(t *testing.T) { unmarshaler := &customTracesUnmarshaler{} - f := NewFactory(WithTracesUnmarshalers(unmarshaler)) + f := NewFactory(withTracesUnmarshalers(unmarshaler)) cfg := createDefaultConfig().(*Config) // disable contacting broker cfg.Metadata.Full = false @@ -95,7 +95,7 @@ func TestCreateMetricsReceiver_error(t *testing.T) { func TestWithMetricsUnmarshalers(t *testing.T) { unmarshaler := &customMetricsUnmarshaler{} - f := NewFactory(WithMetricsUnmarshalers(unmarshaler)) + f := NewFactory(withMetricsUnmarshalers(unmarshaler)) cfg := createDefaultConfig().(*Config) // disable contacting broker cfg.Metadata.Full = false @@ -139,7 +139,7 @@ func TestCreateLogsReceiver_error(t *testing.T) { func TestWithLogsUnmarshalers(t *testing.T) { unmarshaler := &customLogsUnmarshaler{} - f := NewFactory(WithLogsUnmarshalers(unmarshaler)) + f := NewFactory(withLogsUnmarshalers(unmarshaler)) cfg := createDefaultConfig().(*Config) // disable contacting broker cfg.Metadata.Full = false diff --git a/receiver/kafkareceiver/kafka_receiver_test.go b/receiver/kafkareceiver/kafka_receiver_test.go index 0dfafc80b7fd..ea29e0c365a6 100644 --- a/receiver/kafkareceiver/kafka_receiver_test.go +++ b/receiver/kafkareceiver/kafka_receiver_test.go @@ -132,8 +132,8 @@ func TestTracesReceiver_error(t *testing.T) { } func TestTracesConsumerGroupHandler(t *testing.T) { - view.Unregister(MetricViews()...) - views := MetricViews() + view.Unregister(metricViews()...) + views := metricViews() require.NoError(t, view.Register(views...)) defer view.Unregister(views...) @@ -182,8 +182,8 @@ func TestTracesConsumerGroupHandler(t *testing.T) { } func TestTracesConsumerGroupHandler_session_done(t *testing.T) { - view.Unregister(MetricViews()...) - views := MetricViews() + view.Unregister(metricViews()...) + views := metricViews() require.NoError(t, view.Register(views...)) defer view.Unregister(views...) @@ -393,8 +393,8 @@ func TestMetricsReceiver_error(t *testing.T) { } func TestMetricsConsumerGroupHandler(t *testing.T) { - view.Unregister(MetricViews()...) - views := MetricViews() + view.Unregister(metricViews()...) + views := metricViews() require.NoError(t, view.Register(views...)) defer view.Unregister(views...) @@ -443,8 +443,8 @@ func TestMetricsConsumerGroupHandler(t *testing.T) { } func TestMetricsConsumerGroupHandler_session_done(t *testing.T) { - view.Unregister(MetricViews()...) - views := MetricViews() + view.Unregister(metricViews()...) + views := metricViews() require.NoError(t, view.Register(views...)) defer view.Unregister(views...) @@ -652,8 +652,8 @@ func TestLogsReceiver_error(t *testing.T) { } func TestLogsConsumerGroupHandler(t *testing.T) { - view.Unregister(MetricViews()...) - views := MetricViews() + view.Unregister(metricViews()...) + views := metricViews() require.NoError(t, view.Register(views...)) defer view.Unregister(views...) @@ -702,8 +702,8 @@ func TestLogsConsumerGroupHandler(t *testing.T) { } func TestLogsConsumerGroupHandler_session_done(t *testing.T) { - view.Unregister(MetricViews()...) - views := MetricViews() + view.Unregister(metricViews()...) + views := metricViews() require.NoError(t, view.Register(views...)) defer view.Unregister(views...) diff --git a/receiver/kafkareceiver/metrics.go b/receiver/kafkareceiver/metrics.go index f197180713a9..d9053533bc70 100644 --- a/receiver/kafkareceiver/metrics.go +++ b/receiver/kafkareceiver/metrics.go @@ -20,8 +20,8 @@ var ( statPartitionClose = stats.Int64("kafka_receiver_partition_close", "Number of finished partitions", stats.UnitDimensionless) ) -// MetricViews return metric views for Kafka receiver. -func MetricViews() []*view.View { +// metricViews return metric views for Kafka receiver. +func metricViews() []*view.View { tagKeys := []tag.Key{tagInstanceName} countMessages := &view.View{ diff --git a/receiver/kafkareceiver/metrics_test.go b/receiver/kafkareceiver/metrics_test.go index b5585a2d63ad..2b9f7d369661 100644 --- a/receiver/kafkareceiver/metrics_test.go +++ b/receiver/kafkareceiver/metrics_test.go @@ -10,7 +10,7 @@ import ( ) func TestMetrics(t *testing.T) { - metricViews := MetricViews() + metricViews := metricViews() viewNames := []string{ "kafka_receiver_messages", "kafka_receiver_current_offset",