diff --git a/.chloggen/clickhouseexporter-persistentqueue-support.yaml b/.chloggen/clickhouseexporter-persistentqueue-support.yaml new file mode 100755 index 000000000000..169de5a899e8 --- /dev/null +++ b/.chloggen/clickhouseexporter-persistentqueue-support.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: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: clickhouseexporter + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Add persistent storage support to clickhouse exporter + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [27653] + +# (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: [user] diff --git a/.chloggen/clickhouseexporter-use-standard-exporterhelper-queuesettings.yml b/.chloggen/clickhouseexporter-use-standard-exporterhelper-queuesettings.yml new file mode 100755 index 000000000000..7c189b297415 --- /dev/null +++ b/.chloggen/clickhouseexporter-use-standard-exporterhelper-queuesettings.yml @@ -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: clickhouseexporter + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Replace `Config.QueueSettings` field with `exporterhelper.QueueSettings` and remove `QueueSettings` struct + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [27653] + +# (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/exporter/clickhouseexporter/config.go b/exporter/clickhouseexporter/config.go index 43dc5b756800..3986b244f0bd 100644 --- a/exporter/clickhouseexporter/config.go +++ b/exporter/clickhouseexporter/config.go @@ -18,9 +18,7 @@ import ( type Config struct { exporterhelper.TimeoutSettings `mapstructure:",squash"` exporterhelper.RetrySettings `mapstructure:"retry_on_failure"` - // QueueSettings is a subset of exporterhelper.QueueSettings, - // because only QueueSize is user-settable. - QueueSettings QueueSettings `mapstructure:"sending_queue"` + exporterhelper.QueueSettings `mapstructure:"sending_queue"` // Endpoint is the clickhouse endpoint. Endpoint string `mapstructure:"endpoint"` @@ -42,12 +40,6 @@ type Config struct { TTLDays uint `mapstructure:"ttl_days"` } -// QueueSettings is a subset of exporterhelper.QueueSettings. -type QueueSettings struct { - // QueueSize set the length of the sending queue - QueueSize int `mapstructure:"queue_size"` -} - const defaultDatabase = "default" var ( @@ -74,14 +66,6 @@ func (cfg *Config) Validate() (err error) { return err } -func (cfg *Config) enforcedQueueSettings() exporterhelper.QueueSettings { - return exporterhelper.QueueSettings{ - Enabled: true, - NumConsumers: 1, - QueueSize: cfg.QueueSettings.QueueSize, - } -} - func (cfg *Config) buildDSN(database string) (string, error) { dsnURL, err := url.Parse(cfg.Endpoint) if err != nil { diff --git a/exporter/clickhouseexporter/config_test.go b/exporter/clickhouseexporter/config_test.go index 6f65295f2bda..e0c171848f4c 100644 --- a/exporter/clickhouseexporter/config_test.go +++ b/exporter/clickhouseexporter/config_test.go @@ -31,6 +31,8 @@ func TestLoadConfig(t *testing.T) { defaultCfg := createDefaultConfig() defaultCfg.(*Config).Endpoint = defaultEndpoint + storageID := component.NewIDWithName(component.Type("file_storage"), "clickhouse") + tests := []struct { id component.ID expected component.Config @@ -63,8 +65,11 @@ func TestLoadConfig(t *testing.T) { Multiplier: backoff.DefaultMultiplier, }, ConnectionParams: map[string]string{}, - QueueSettings: QueueSettings{ - QueueSize: 100, + QueueSettings: exporterhelper.QueueSettings{ + Enabled: true, + NumConsumers: 1, + QueueSize: 100, + StorageID: &storageID, }, }, }, diff --git a/exporter/clickhouseexporter/factory.go b/exporter/clickhouseexporter/factory.go index 75193b8d5b57..43009573cb6e 100644 --- a/exporter/clickhouseexporter/factory.go +++ b/exporter/clickhouseexporter/factory.go @@ -28,9 +28,12 @@ func NewFactory() exporter.Factory { } func createDefaultConfig() component.Config { + queueSettings := exporterhelper.NewDefaultQueueSettings() + queueSettings.NumConsumers = 1 + return &Config{ TimeoutSettings: exporterhelper.NewDefaultTimeoutSettings(), - QueueSettings: QueueSettings{QueueSize: exporterhelper.NewDefaultQueueSettings().QueueSize}, + QueueSettings: queueSettings, RetrySettings: exporterhelper.NewDefaultRetrySettings(), ConnectionParams: map[string]string{}, Database: defaultDatabase, @@ -62,7 +65,7 @@ func createLogsExporter( exporterhelper.WithStart(exporter.start), exporterhelper.WithShutdown(exporter.shutdown), exporterhelper.WithTimeout(c.TimeoutSettings), - exporterhelper.WithQueue(c.enforcedQueueSettings()), + exporterhelper.WithQueue(c.QueueSettings), exporterhelper.WithRetry(c.RetrySettings), ) } @@ -88,7 +91,7 @@ func createTracesExporter( exporterhelper.WithStart(exporter.start), exporterhelper.WithShutdown(exporter.shutdown), exporterhelper.WithTimeout(c.TimeoutSettings), - exporterhelper.WithQueue(c.enforcedQueueSettings()), + exporterhelper.WithQueue(c.QueueSettings), exporterhelper.WithRetry(c.RetrySettings), ) } @@ -112,7 +115,7 @@ func createMetricExporter( exporterhelper.WithStart(exporter.start), exporterhelper.WithShutdown(exporter.shutdown), exporterhelper.WithTimeout(c.TimeoutSettings), - exporterhelper.WithQueue(c.enforcedQueueSettings()), + exporterhelper.WithQueue(c.QueueSettings), exporterhelper.WithRetry(c.RetrySettings), ) } diff --git a/exporter/clickhouseexporter/testdata/config.yaml b/exporter/clickhouseexporter/testdata/config.yaml index 6e2f65136a89..573fbe923738 100644 --- a/exporter/clickhouseexporter/testdata/config.yaml +++ b/exporter/clickhouseexporter/testdata/config.yaml @@ -16,5 +16,6 @@ clickhouse/full: max_elapsed_time: 300s sending_queue: queue_size: 100 + storage: file_storage/clickhouse clickhouse/invalid-endpoint: - endpoint: 127.0.0.1:9000 \ No newline at end of file + endpoint: 127.0.0.1:9000