Skip to content

Commit

Permalink
clickhousetraces: Support specifying cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
davispuh committed Oct 18, 2024
1 parent 8c4fc43 commit 16cbf29
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion exporter/clickhousetracesexporter/clickhouse_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func newExporter(cfg component.Config, logger *zap.Logger) (*storage, error) {

id := uuid.New()

f := ClickHouseNewFactory(id, configClickHouse.Migrations, configClickHouse.Datasource, configClickHouse.DockerMultiNodeCluster, configClickHouse.QueueConfig.NumConsumers)
f := ClickHouseNewFactory(id, *configClickHouse)

err := f.Initialize(logger)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions exporter/clickhousetracesexporter/clickhouse_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ var (
)

// NewFactory creates a new Factory.
func ClickHouseNewFactory(exporterId uuid.UUID, migrations string, datasource string, dockerMultiNodeCluster bool, numConsumers int) *Factory {
func ClickHouseNewFactory(exporterId uuid.UUID, config Config) *Factory {
writeLatencyDistribution := view.Distribution(100, 250, 500, 750, 1000, 2000, 4000, 8000, 16000, 32000, 64000, 128000, 256000, 512000)

writeLatencyView := &view.View{
Expand All @@ -65,7 +65,7 @@ func ClickHouseNewFactory(exporterId uuid.UUID, migrations string, datasource st

view.Register(writeLatencyView)
return &Factory{
Options: NewOptions(exporterId, migrations, datasource, dockerMultiNodeCluster, numConsumers, primaryNamespace, archiveNamespace),
Options: NewOptions(exporterId, config, primaryNamespace, archiveNamespace),
// makeReader: func(db *clickhouse.Conn, operationsTable, indexTable, spansTable string) (spanstore.Reader, error) {
// return store.NewTraceReader(db, operationsTable, indexTable, spansTable), nil
// },
Expand Down
1 change: 1 addition & 0 deletions exporter/clickhousetracesexporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type Config struct {
exporterhelper.TimeoutConfig `mapstructure:",squash"`
configretry.BackOffConfig `mapstructure:"retry_on_failure"`
exporterhelper.QueueConfig `mapstructure:"sending_queue"`
ClusterName string `mapstructure:"cluster_name" default:"cluster"`
}

var _ component.Config = (*Config)(nil)
Expand Down
11 changes: 6 additions & 5 deletions exporter/clickhousetracesexporter/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ const (
DefaultDurationSortTable string = "durationSort"
DefaultDurationSortMVTable string = "durationSortMV"
defaultArchiveSpansTable string = "signoz_archive_spans"
defaultClusterName string = "cluster"
defaultDependencyGraphTable string = "dependency_graph_minutes"
defaultDependencyGraphServiceMV string = "dependency_graph_minutes_service_calls_mv"
defaultDependencyGraphDbMV string = "dependency_graph_minutes_db_calls_mv"
Expand Down Expand Up @@ -128,11 +127,13 @@ type Options struct {
}

// NewOptions creates a new Options struct.
func NewOptions(exporterId uuid.UUID, migrations string, datasource string, dockerMultiNodeCluster bool, numConsumers int, primaryNamespace string, otherNamespaces ...string) *Options {
func NewOptions(exporterId uuid.UUID, config Config, primaryNamespace string, otherNamespaces ...string) *Options {

datasource := config.Datasource
if datasource == "" {
datasource = defaultDatasource
}
migrations := config.Migrations
if migrations == "" {
migrations = defaultMigrations
}
Expand All @@ -153,13 +154,13 @@ func NewOptions(exporterId uuid.UUID, migrations string, datasource string, dock
AttributeKeyTable: defaultAttributeKeyTable,
DurationSortTable: DefaultDurationSortTable,
DurationSortMVTable: DefaultDurationSortMVTable,
Cluster: defaultClusterName,
Cluster: config.ClusterName,
DependencyGraphTable: defaultDependencyGraphTable,
DependencyGraphServiceMV: defaultDependencyGraphServiceMV,
DependencyGraphDbMV: defaultDependencyGraphDbMV,
DependencyGraphMessagingMV: DependencyGraphMessagingMV,
DockerMultiNodeCluster: dockerMultiNodeCluster,
NumConsumers: numConsumers,
DockerMultiNodeCluster: config.DockerMultiNodeCluster,
NumConsumers: config.QueueConfig.NumConsumers,
Encoding: defaultEncoding,
Connector: defaultConnector,
ExporterId: exporterId,
Expand Down

0 comments on commit 16cbf29

Please sign in to comment.