Skip to content

Commit

Permalink
Resolve Yuri's review and fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
haanhvu committed Jun 13, 2024
1 parent 10776aa commit e498cdb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 18 deletions.
3 changes: 1 addition & 2 deletions cmd/jaeger/internal/exporters/storageexporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func newExporter(config *Config, otel component.TelemetrySettings) *storageExpor
}
}

func (exp *storageExporter) start(ctx context.Context, host component.Host) error {
func (exp *storageExporter) start(_ context.Context, host component.Host) error {
f, err := jaegerstorage.GetStorageFactory(exp.config.TraceStorage, host)
if err != nil {
return fmt.Errorf("cannot find storage factory: %w", err)
Expand All @@ -44,7 +44,6 @@ 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.chExportTraces = t.ExportSpans
default:
exp.clickhouse = false
Expand Down
19 changes: 8 additions & 11 deletions plugin/storage/clickhouse/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,15 @@ func NewFactory(ctx context.Context, cfg Config, logger *zap.Logger) *Factory {
f.client = client

Check warning on line 35 in plugin/storage/clickhouse/factory.go

View check run for this annotation

Codecov / codecov/patch

plugin/storage/clickhouse/factory.go#L31-L35

Added lines #L31 - L35 were not covered by tests
}

if err = chSpanStore.CreateSpansTable(ctx, f.client, f.spansTableName); err != nil {
f.logger.Error("failed to create spans table", zap.Error(err))

Check warning on line 39 in plugin/storage/clickhouse/factory.go

View check run for this annotation

Codecov / codecov/patch

plugin/storage/clickhouse/factory.go#L38-L39

Added lines #L38 - L39 were not covered by tests
}

return f

Check warning on line 42 in plugin/storage/clickhouse/factory.go

View check run for this annotation

Codecov / codecov/patch

plugin/storage/clickhouse/factory.go#L42

Added line #L42 was not covered by tests

// TODO: Move some steps to Initialize()
}

func (f *Factory) CreateSpansTable(ctx context.Context) error {
if err := chSpanStore.CreateSpansTable(ctx, f.client, f.spansTableName); err != nil {
f.logger.Error("failed to create spans table", zap.Error(err))
}
return nil
}

func (f *Factory) ExportSpans(ctx context.Context, td ptrace.Traces) error {
if err := chSpanStore.ExportSpans(ctx, f.client, f.spansTableName, td); err != nil {
return err

Check warning on line 49 in plugin/storage/clickhouse/factory.go

View check run for this annotation

Codecov / codecov/patch

plugin/storage/clickhouse/factory.go#L47-L49

Added lines #L47 - L49 were not covered by tests
Expand All @@ -55,18 +52,18 @@ func (f *Factory) ExportSpans(ctx context.Context, td ptrace.Traces) error {
return nil

Check warning on line 52 in plugin/storage/clickhouse/factory.go

View check run for this annotation

Codecov / codecov/patch

plugin/storage/clickhouse/factory.go#L52

Added line #L52 was not covered by tests
}

func (f *Factory) Initialize(metricsFactory metrics.Factory, logger *zap.Logger) error {
func (*Factory) Initialize(_ metrics.Factory, _ *zap.Logger) error {
return nil

Check warning on line 56 in plugin/storage/clickhouse/factory.go

View check run for this annotation

Codecov / codecov/patch

plugin/storage/clickhouse/factory.go#L55-L56

Added lines #L55 - L56 were not covered by tests
}

func (f *Factory) CreateSpanReader() (spanstore.Reader, error) {
func (*Factory) CreateSpanReader() (spanstore.Reader, error) {
return nil, nil

Check warning on line 60 in plugin/storage/clickhouse/factory.go

View check run for this annotation

Codecov / codecov/patch

plugin/storage/clickhouse/factory.go#L59-L60

Added lines #L59 - L60 were not covered by tests
}

func (f *Factory) CreateSpanWriter() (spanstore.Writer, error) {
func (*Factory) CreateSpanWriter() (spanstore.Writer, error) {
return nil, nil

Check warning on line 64 in plugin/storage/clickhouse/factory.go

View check run for this annotation

Codecov / codecov/patch

plugin/storage/clickhouse/factory.go#L63-L64

Added lines #L63 - L64 were not covered by tests
}

func (f *Factory) CreateDependencyReader() (dependencystore.Reader, error) {
func (*Factory) CreateDependencyReader() (dependencystore.Reader, error) {
return nil, nil

Check warning on line 68 in plugin/storage/clickhouse/factory.go

View check run for this annotation

Codecov / codecov/patch

plugin/storage/clickhouse/factory.go#L67-L68

Added lines #L67 - L68 were not covered by tests
}
7 changes: 2 additions & 5 deletions plugin/storage/clickhouse/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@ func TestExportSpans(t *testing.T) {
f := NewFactory(context.TODO(), c, zap.NewNop())
require.NotNil(t, f.client)

err := f.CreateSpansTable(context.TODO())
require.NoError(t, err)

err = f.ExportSpans(context.TODO(), createTraces(5))
err := f.ExportSpans(context.TODO(), createTraces(5))
require.NoError(t, err)

err = f.ExportSpans(context.TODO(), createTraces(10))
Expand Down Expand Up @@ -143,6 +140,6 @@ func (t *testClickhouseDriverStmt) NumInput() int {
return strings.Count(t.query, "?")
}

func (t *testClickhouseDriverStmt) Query(_ []driver.Value) (driver.Rows, error) {
func (*testClickhouseDriverStmt) Query(_ []driver.Value) (driver.Rows, error) {
return nil, nil
}

0 comments on commit e498cdb

Please sign in to comment.