Skip to content

Commit

Permalink
feat: add trace exporter configs
Browse files Browse the repository at this point in the history
  • Loading branch information
makeavish committed Sep 20, 2023
1 parent e251846 commit e69851d
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
9 changes: 9 additions & 0 deletions config/default-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions exporter/clickhousetracesexporter/clickhouse_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
19 changes: 18 additions & 1 deletion exporter/clickhousetracesexporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
}
6 changes: 5 additions & 1 deletion exporter/clickhousetracesexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
}

0 comments on commit e69851d

Please sign in to comment.