diff --git a/config/default-config.yaml b/config/default-config.yaml index d5ef74e0..094dd219 100644 --- a/config/default-config.yaml +++ b/config/default-config.yaml @@ -54,6 +54,15 @@ exporters: clickhousetraces: datasource: tcp://localhost:9000/?database=signoz_traces migrations: exporter/clickhousetracesexporter/migrations + retry_on_failure: + enabled: true + initial_interval: 5s + max_interval: 30s + max_elapsed_time: 300s + sending_queue: + enabled: true + queue_size: 100 + num_consumers: 5 clickhousemetricswrite: endpoint: tcp://localhost:9000/?database=signoz_metrics resource_to_telemetry_conversion: diff --git a/exporter/clickhousetracesexporter/clickhouse_exporter.go b/exporter/clickhousetracesexporter/clickhouse_exporter.go index 25176f15..9f34a15f 100644 --- a/exporter/clickhousetracesexporter/clickhouse_exporter.go +++ b/exporter/clickhousetracesexporter/clickhouse_exporter.go @@ -39,6 +39,10 @@ import ( // Crete new exporter. func newExporter(cfg component.Config, logger *zap.Logger) (*storage, error) { + if err := component.ValidateConfig(cfg); err != nil { + return nil, err + } + configClickHouse := cfg.(*Config) f := ClickHouseNewFactory(configClickHouse.Migrations, configClickHouse.Datasource, configClickHouse.DockerMultiNodeCluster) diff --git a/exporter/clickhousetracesexporter/config.go b/exporter/clickhousetracesexporter/config.go index bd523b69..38d6bf3b 100644 --- a/exporter/clickhousetracesexporter/config.go +++ b/exporter/clickhousetracesexporter/config.go @@ -15,7 +15,10 @@ package clickhousetracesexporter import ( + "fmt" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/exporter/exporterhelper" ) // Config defines configuration for tracing exporter. @@ -26,12 +29,26 @@ type Config struct { // Docker Multi Node Cluster is a flag to enable the docker multi node cluster. Default is false. DockerMultiNodeCluster bool `mapstructure:"docker_multi_node_cluster"` // LowCardinalExceptionGrouping is a flag to enable exception grouping by serviceName + exceptionType. Default is false. - LowCardinalExceptionGrouping bool `mapstructure:"low_cardinal_exception_grouping"` + LowCardinalExceptionGrouping bool `mapstructure:"low_cardinal_exception_grouping"` + exporterhelper.TimeoutSettings `mapstructure:",squash"` + exporterhelper.RetrySettings `mapstructure:"retry_on_failure"` + exporterhelper.QueueSettings `mapstructure:"sending_queue"` } var _ component.Config = (*Config)(nil) // Validate checks if the exporter configuration is valid func (cfg *Config) Validate() error { + if cfg.QueueSettings.QueueSize < 0 { + return fmt.Errorf("remote write queue size can't be negative") + } + + if cfg.QueueSettings.Enabled && cfg.QueueSettings.QueueSize == 0 { + return fmt.Errorf("a 0 size queue will drop all the data") + } + + if cfg.QueueSettings.NumConsumers < 0 { + return fmt.Errorf("remote write consumer number can't be negative") + } return nil } diff --git a/exporter/clickhousetracesexporter/factory.go b/exporter/clickhousetracesexporter/factory.go index 93c19496..bdfa9e37 100644 --- a/exporter/clickhousetracesexporter/factory.go +++ b/exporter/clickhousetracesexporter/factory.go @@ -51,6 +51,7 @@ func createTracesExporter( cfg component.Config, ) (exporter.Traces, error) { + c := cfg.(*Config) oce, err := newExporter(cfg, params.Logger) if err != nil { return nil, err @@ -61,5 +62,8 @@ func createTracesExporter( params, cfg, oce.pushTraceData, - exporterhelper.WithShutdown(oce.Shutdown)) + exporterhelper.WithShutdown(oce.Shutdown), + exporterhelper.WithTimeout(c.TimeoutSettings), + exporterhelper.WithQueue(c.QueueSettings), + exporterhelper.WithRetry(c.RetrySettings)) }