[clickhouse] Add linter for ClickHouse #8641
Conversation
Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8641 +/- ##
==========================================
- Coverage 96.58% 96.54% -0.04%
==========================================
Files 334 334
Lines 17789 17825 +36
==========================================
+ Hits 17182 17210 +28
- Misses 456 460 +4
- Partials 151 155 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
CI Summary ReportMetrics Comparison✅ No significant metric changes Code Coverage✅ Coverage 97.3% (baseline 97.3%) ➡️ View CI run | View publish logs |
There was a problem hiding this comment.
Pull request overview
Adds the clickhouselint golangci-lint linter and updates ClickHouse readers/tests to satisfy the stricter resource/rows handling expectations when iterating query results.
Changes:
- Enable
clickhouselintin.golangci.yml. - Add
rows.Err()checks after row iteration in ClickHouse trace/dependency readers. - Add/adjust unit tests to cover
rows.Err()behavior and linter-driven cleanup in the ClickHouse test driver.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/storage/v2/clickhouse/tracestore/reader.go | Adds rows.Err() checks in multiple reader methods after iterating rows. |
| internal/storage/v2/clickhouse/tracestore/reader_test.go | Adds new test cases for rows.Err() propagation in trace/service/operation queries. |
| internal/storage/v2/clickhouse/depstore/reader.go | Adds rows.Err() check after iterating dependency snapshot rows. |
| internal/storage/v2/clickhouse/depstore/reader_test.go | Adds test coverage for dependencies rows.Err() propagation. |
| internal/storage/v2/clickhouse/clickhousetest/driver_test.go | Ensures prepared batches are closed; adds targeted //nolint:clickhouselint where results are nil. |
| .golangci.yml | Enables the clickhouselint linter. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
Move the per-iteration logic of GetTraces into a getTrace helper method so defer rows.Close() works in its natural scope, replacing the inline IIFE with named-return error joining. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Yuri Shkuro <github@ysh.us>
Inline the per-traceID body and use an []error slice with errors.Join to collect scan, rows.Err, and close errors uniformly. Drops the helper method, the named return, and the conditional join introduced earlier. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Yuri Shkuro <github@ysh.us>
Apply the same []error + errors.Join pattern as GetTraces so close, scan, and rows.Err errors all reach the consumer instead of being dropped by defer rows.Close(). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Yuri Shkuro <github@ysh.us>
Apply the same []error + errors.Join pattern so scan, rows.Err, and close errors are all reported instead of dropped by defer rows.Close(). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Yuri Shkuro <github@ysh.us>
| got, err := d.PrepareBatch(context.Background(), "INSERT INTO spans VALUES (?)") //nolint:clickhouselint // got is nil on error | ||
| require.ErrorIs(t, err, wantErr) | ||
| assert.Nil(t, got) |
| got, err := d.PrepareBatch(context.Background(), "INSERT INTO other VALUES (?)") //nolint:clickhouselint // got is nil when no match | ||
| require.NoError(t, err) | ||
| assert.Nil(t, got) | ||
| } |
## Description of the changes - Adds the [clickhouselint](https://golangci-lint.run/docs/linters/configuration/#clickhouselint) linter to catch any mistakes in our ClickHouse API usage. ## How was this change tested? - CI ## Checklist - [x] I have read https://github.com/jaegertracing/jaeger/blob/main/CONTRIBUTING_GUIDELINES.md - [x] I have signed all commits - [x] I have added unit tests for the new functionality - [x] I have run lint and test steps successfully: `make lint test` ## AI Usage in this PR (choose one) See [AI Usage Policy](https://github.com/jaegertracing/jaeger/blob/main/CONTRIBUTING_GUIDELINES.md#ai-usage-policy). - [ ] **None**: No AI tools were used in creating this PR - [x] **Light**: AI provided minor assistance (formatting, simple suggestions) - [ ] **Moderate**: AI helped with code generation or debugging specific parts - [ ] **Heavy**: AI generated most or all of the code changes --------- Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com> Signed-off-by: Yuri Shkuro <github@ysh.us> Co-authored-by: Yuri Shkuro <yurishkuro@users.noreply.github.com> Co-authored-by: Yuri Shkuro <github@ysh.us> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Victor Chidera Obiezue <obiezuechidera@gmail.com>
Description of the changes
How was this change tested?
Checklist
make lint testAI Usage in this PR (choose one)
See AI Usage Policy.