Skip to content

Commit

Permalink
Merge branch 'main' into issue_186
Browse files Browse the repository at this point in the history
  • Loading branch information
nityanandagohain authored Oct 11, 2023
2 parents b465924 + 49769fd commit afa872c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 21 deletions.
18 changes: 1 addition & 17 deletions exporter/clickhouselogsexporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,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"`

// DSN is the ClickHouse server Data Source Name.
// For tcp protocol reference: [ClickHouse/clickhouse-go#dsn](https://github.com/ClickHouse/clickhouse-go#dsn).
Expand All @@ -37,12 +35,6 @@ type Config struct {
DockerMultiNodeCluster bool `mapstructure:"docker_multi_node_cluster" default:"false"`
}

// QueueSettings is a subset of exporterhelper.QueueSettings.
type QueueSettings struct {
// QueueSize set the length of the sending queue
QueueSize int `mapstructure:"queue_size"`
}

var (
errConfigNoDSN = errors.New("dsn must be specified")
)
Expand All @@ -54,11 +46,3 @@ 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,
}
}
6 changes: 4 additions & 2 deletions exporter/clickhouselogsexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ func TestLoadConfig(t *testing.T) {
RandomizationFactor: 0.7,
Multiplier: 1.3,
},
QueueSettings: QueueSettings{
QueueSize: 100,
QueueSettings: exporterhelper.QueueSettings{
Enabled: true,
NumConsumers: 10,
QueueSize: 100,
},
})
}
Expand Down
4 changes: 2 additions & 2 deletions exporter/clickhouselogsexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func NewFactory() exporter.Factory {
func createDefaultConfig() component.Config {
return &Config{
TimeoutSettings: exporterhelper.NewDefaultTimeoutSettings(),
QueueSettings: QueueSettings{QueueSize: exporterhelper.NewDefaultQueueSettings().QueueSize},
QueueSettings: exporterhelper.NewDefaultQueueSettings(),
RetrySettings: exporterhelper.NewDefaultRetrySettings(),
}
}
Expand All @@ -91,7 +91,7 @@ func createLogsExporter(
exporter.pushLogsData,
exporterhelper.WithShutdown(exporter.Shutdown),
exporterhelper.WithTimeout(c.TimeoutSettings),
exporterhelper.WithQueue(c.enforcedQueueSettings()),
exporterhelper.WithQueue(c.QueueSettings),
exporterhelper.WithRetry(c.RetrySettings),
)
}

0 comments on commit afa872c

Please sign in to comment.