-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feat][storage]: add write path for ClickHouse based on Jaeger V2
Signed-off-by: zzzk1 <madzhou1@gmail.com>
- Loading branch information
Showing
42 changed files
with
2,288 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: CIT ClickHouse | ||
|
||
on: | ||
workflow_call: | ||
|
||
concurrency: | ||
group: cit-clickhouse-${{ github.workflow }}-${{ (github.event.pull_request && github.event.pull_request.number) || github.ref || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
# See https://github.com/ossf/scorecard/blob/main/docs/checks.md#token-permissions | ||
permissions: # added using https://github.com/step-security/secure-workflows | ||
contents: read | ||
|
||
jobs: | ||
clickhouse: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
clickhouse-version: ["25.x"] | ||
create-schema: [manual, auto] | ||
name: clickhouse | ||
steps: | ||
- name: Harden Runner | ||
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 | ||
with: | ||
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs | ||
|
||
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 | ||
|
||
- uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0 | ||
with: | ||
go-version: 1.24.x | ||
|
||
- name: Run clickhouse integration tests | ||
id: test-execution | ||
run: bash scripts/e2e/clickhouse.sh ${{ matrix.clickhouse-version }}-${{ matrix.create-schema }} | ||
env: | ||
SKIP_APPLY_SCHEMA: ${{ matrix.create-schema == 'auto' && true || false }} | ||
- uses: ./.github/actions/verify-metrics-snapshot | ||
with: | ||
snapshot: metrics_snapshot_clickhouse | ||
artifact_key: metrics_snapshot_clickhouse | ||
|
||
- name: Upload coverage to codecov | ||
uses: ./.github/actions/upload-codecov | ||
with: | ||
files: cover.out | ||
flags: clickhouse-${{ matrix.clickhouse-version }}-${{ matrix.create-schema }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
services: | ||
clickhouse: | ||
container_name: clickhouse | ||
image: bitnami/clickhouse:25.1.3 | ||
environment: | ||
CLICKHOUSE_USER: "default" | ||
CLICKHOUSE_PASSWORD: "default" | ||
ports: | ||
- 9000:9000 | ||
- 8123:8123 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright (c) 2025 The Jaeger Authors. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package integration | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
"go.uber.org/zap" | ||
"go.uber.org/zap/zaptest" | ||
|
||
"github.com/jaegertracing/jaeger/internal/storage/v2/clickhouse" | ||
"github.com/jaegertracing/jaeger/internal/storage/v2/clickhouse/config" | ||
"github.com/jaegertracing/jaeger/pkg/testutils" | ||
) | ||
|
||
type ClickhouseIntegrationTestSuite struct { | ||
StorageIntegration | ||
factory *clickhouse.Factory | ||
} | ||
|
||
func (s *ClickhouseIntegrationTestSuite) cleanUp(t *testing.T) { | ||
require.NoError(t, s.factory.Purge(context.Background())) | ||
} | ||
|
||
func (s *ClickhouseIntegrationTestSuite) initialize(t *testing.T) { | ||
logger := zaptest.NewLogger(t, zaptest.WrapOptions(zap.AddCaller())) | ||
|
||
cfg := config.DefaultConfiguration() | ||
cfg.ConnConfig.Database = "jaeger" | ||
cfg.PoolConfig.ClientConfig.Database = "jaeger" | ||
f, err := clickhouse.NewFactory(&cfg, logger) | ||
require.NoError(t, err) | ||
|
||
t.Cleanup(func() { | ||
assert.NoError(t, f.Close()) | ||
}) | ||
|
||
traceWriter, err := f.CreateTraceWriter() | ||
require.NoError(t, err) | ||
traceReader, err := f.CreateTracReader() | ||
require.NoError(t, err) | ||
|
||
s.TraceWriter = traceWriter | ||
s.TraceReader = traceReader | ||
s.factory = f | ||
s.CleanUp = s.cleanUp | ||
} | ||
|
||
func TestClickHouseStorage(t *testing.T) { | ||
SkipUnlessEnv(t, "clickhouse") | ||
t.Cleanup(func() { | ||
testutils.VerifyGoLeaksOnceForClickhouse(t) | ||
}) | ||
s := &ClickhouseIntegrationTestSuite{} | ||
s.initialize(t) | ||
s.testGetTrace(t) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Copyright (c) 2025 The Jaeger Authors. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
FROM docker.io/bitnami/clickhouse:25 | ||
|
||
COPY schema/* /clickhouse-schema/ | ||
|
||
ENTRYPOINT ["sh","/clickhouse-schema/docker.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (c) 2025 The Jaeger Authors. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package client | ||
|
||
import ( | ||
"context" | ||
|
||
"go.opentelemetry.io/collector/pdata/ptrace" | ||
) | ||
|
||
type Pool interface { | ||
Do(ctx context.Context, query string, td ...ptrace.Traces) error | ||
Close() error | ||
} | ||
|
||
type Conn interface { | ||
QueryRow(ctx context.Context, query string, arg string) Row | ||
Query(ctx context.Context, query string, arg string) (Rows, error) | ||
Exec(ctx context.Context, query string) error | ||
Close() error | ||
} | ||
|
||
type Rows interface { | ||
Next() bool | ||
Scan(dest ...any) error | ||
ScanStruct(dest any) error | ||
Err() error | ||
} | ||
|
||
type Row interface { | ||
Err() error | ||
Scan(dest ...any) error | ||
ScanStruct(dest any) error | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright (c) 2025 The Jaeger Authors. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package conn | ||
|
||
import ( | ||
client "github.com/ClickHouse/clickhouse-go/v2" | ||
"github.com/ClickHouse/clickhouse-go/v2/lib/driver" | ||
) | ||
|
||
type Configuration struct { | ||
Address []string `mapstructure:"address"` | ||
Database string `mapstructure:"database"` | ||
Username string `mapstructure:"username"` | ||
Password string `mapstructure:"password"` | ||
} | ||
|
||
func DefaultConfig() Configuration { | ||
return Configuration{ | ||
Address: []string{"127.0.0.1:9000"}, | ||
Database: "default", | ||
Username: "default", | ||
Password: "default", | ||
} | ||
} | ||
|
||
func NewConn(config Configuration) (driver.Conn, error) { | ||
option := client.Options{ | ||
Addr: config.Address, | ||
Auth: client.Auth{ | ||
Database: config.Database, | ||
Username: config.Username, | ||
Password: config.Password, | ||
}, | ||
} | ||
|
||
conn, err := client.Open(&option) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return conn, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) 2025 The Jaeger Authors. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package conn | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/jaegertracing/jaeger/pkg/testutils" | ||
) | ||
|
||
func TestDefaultConfig(t *testing.T) { | ||
excepted := Configuration{ | ||
Address: []string{"127.0.0.1:9000"}, | ||
Database: "default", | ||
Username: "default", | ||
Password: "default", | ||
} | ||
actual := DefaultConfig() | ||
assert.NotNil(t, actual) | ||
assert.Equal(t, excepted, actual) | ||
} | ||
|
||
func TestMain(m *testing.M) { | ||
testutils.VerifyGoLeaks(m) | ||
} |
Oops, something went wrong.