Skip to content

Commit

Permalink
Fix failed CI checks
Browse files Browse the repository at this point in the history
Signed-off-by: haanhvu <[email protected]>
  • Loading branch information
haanhvu committed Jan 1, 2024
1 parent f0318be commit a7616e6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 36 deletions.
25 changes: 14 additions & 11 deletions cmd/jaeger/internal/exporters/storageexporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,18 @@ import (
)

type storageExporter struct {
config *Config
logger *zap.Logger
spanWriter spanstore.Writer
exportTraces func(ctx context.Context, td ptrace.Traces) error
requireBatchInsert bool
config *Config
logger *zap.Logger
spanWriter spanstore.Writer
clickhouse bool
chExportTraces func(ctx context.Context, td ptrace.Traces) error
}

func newExporter(config *Config, otel component.TelemetrySettings) *storageExporter {
return &storageExporter{
config: config,
logger: otel.Logger,
config: config,
logger: otel.Logger,
clickhouse: false,
}
}

Expand All @@ -41,15 +42,13 @@ func (exp *storageExporter) start(ctx context.Context, host component.Host) erro

switch t := f.(type) {
case *ch.Factory:
exp.clickhouse = true
t.CreateSpansTable(ctx)
exp.requireBatchInsert = true
exp.exportTraces = t.ExportSpans
exp.chExportTraces = t.ExportSpans
default:
if exp.spanWriter, err = f.CreateSpanWriter(); err != nil {
return fmt.Errorf("cannot create span writer: %w", err)
}
exp.requireBatchInsert = false
exp.exportTraces = exp.pushTraces
}

return nil
Expand All @@ -61,6 +60,10 @@ func (exp *storageExporter) close(_ context.Context) error {
}

func (exp *storageExporter) pushTraces(ctx context.Context, td ptrace.Traces) error {
if exp.clickhouse {
return exp.chExportTraces(ctx, td)
}

batches, err := otlp2jaeger.ProtoFromTraces(td)
if err != nil {
return fmt.Errorf("cannot transform OTLP traces to Jaeger format: %w", err)
Expand Down
18 changes: 3 additions & 15 deletions cmd/jaeger/internal/exporters/storageexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,14 @@ func createDefaultConfig() component.Config {
func createTracesExporter(ctx context.Context, set exporter.CreateSettings, config component.Config) (exporter.Traces, error) {
cfg := config.(*Config)
ex := newExporter(cfg, set.TelemetrySettings)

if ex.requireBatchInsert {
return exporterhelper.NewTracesExporter(ctx, set, cfg,
ex.exportTraces,
exporterhelper.WithCapabilities(consumer.Capabilities{MutatesData: false}),
exporterhelper.WithTimeout(exporterhelper.TimeoutSettings{Timeout: 0}),
exporterhelper.WithRetry(exporterhelper.RetrySettings{Enabled: false}),
// Enable queue settings for batch inserts
exporterhelper.WithQueue(exporterhelper.QueueSettings{Enabled: true}),
exporterhelper.WithStart(ex.start),
exporterhelper.WithShutdown(ex.close),
)
}
return exporterhelper.NewTracesExporter(ctx, set, cfg,
ex.exportTraces,
ex.pushTraces,
exporterhelper.WithCapabilities(consumer.Capabilities{MutatesData: false}),
// Disable Timeout/RetryOnFailure and SendingQueue
exporterhelper.WithTimeout(exporterhelper.TimeoutSettings{Timeout: 0}),
exporterhelper.WithRetry(exporterhelper.RetrySettings{Enabled: false}),
exporterhelper.WithQueue(exporterhelper.QueueSettings{Enabled: false}),
// Enable queue settings for Clickhouse only
exporterhelper.WithQueue(exporterhelper.QueueSettings{Enabled: ex.clickhouse}),
exporterhelper.WithStart(ex.start),
exporterhelper.WithShutdown(ex.close),
)
Expand Down
10 changes: 0 additions & 10 deletions cmd/jaeger/internal/extension/jaegerstorage/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,3 @@ type Config struct {

ClickHouse map[string]ch.Config `mapstructure:"clickhouse"`
}

type MemoryStorage struct {
Name string `mapstructure:"name"`
memoryCfg.Configuration
}

type ClickHouseStorage struct {
Name string `mapstructure:"name"`
ch.Config
}

0 comments on commit a7616e6

Please sign in to comment.