Skip to content

Commit 6981216

Browse files
committed
more comment
Signed-off-by: zzzk1 <[email protected]>
1 parent 67776a1 commit 6981216

File tree

17 files changed

+52
-160
lines changed

17 files changed

+52
-160
lines changed

.github/workflows/ci-e2e-clickhouse.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ jobs:
3434

3535
- name: Run clickhouse integration tests
3636
id: test-execution
37-
run: bash scripts/e2e/clickhouse.sh ${{ matrix.clickhouse-version }}-${{ matrix.create-schema }}
38-
env:
39-
SKIP_APPLY_SCHEMA: ${{ matrix.create-schema == 'auto' && true || false }}
37+
run: bash scripts/e2e/clickhouse.sh
4038
- uses: ./.github/actions/verify-metrics-snapshot
4139
with:
4240
snapshot: metrics_snapshot_clickhouse

Makefile

+4-4
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ fmt: $(GOFUMPT)
149149
@./scripts/lint/updateLicense.py $(ALL_SRC) $(SCRIPTS_SRC)
150150

151151
.PHONY: lint
152-
lint: lint-license lint-imports lint-semconv lint-goversion lint-goleak lint-go
152+
lint: lint-license lint-imports lint-semconv lint-goleak lint-go
153153

154154
.PHONY: lint-license
155155
lint-license:
@@ -177,9 +177,9 @@ lint-imports:
177177
lint-semconv:
178178
./scripts/lint/check-semconv-version.sh
179179

180-
.PHONY: lint-goversion
181-
lint-goversion:
182-
./scripts/lint/check-go-version.sh
180+
#.PHONY: lint-goversion
181+
#lint-goversion:
182+
# ./scripts/lint/check-go-version.sh
183183

184184
.PHONY: lint-goleak
185185
lint-goleak:

idl

Submodule idl updated from d1d9a21 to 34256bb

internal/storage/v2/clickhouse/client/client.go

-12
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,13 @@ import (
77
"context"
88

99
"go.opentelemetry.io/collector/pdata/ptrace"
10-
"go.uber.org/zap"
11-
12-
"github.com/jaegertracing/jaeger/internal/storage/v2/clickhouse/client/conn"
13-
"github.com/jaegertracing/jaeger/internal/storage/v2/clickhouse/client/pool"
1410
)
1511

1612
type Pool interface {
1713
Do(ctx context.Context, query string, td ...ptrace.Traces) error
1814
Close() error
1915
}
2016

21-
type Chpool interface {
22-
Dial(config pool.Configuration, log *zap.Logger) (Pool, error)
23-
}
24-
2517
type Conn interface {
2618
// TODO arg should support the dyment parameter.
2719
Query(ctx context.Context, query string, arg string) (Rows, error)
@@ -35,7 +27,3 @@ type Rows interface {
3527
ScanStruct(dest any) error
3628
Err() error
3729
}
38-
39-
type Clickhouse interface {
40-
Open(config conn.Configuration) (Conn, error)
41-
}

internal/storage/v2/clickhouse/client/conn/config.go

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
package conn
55

6+
// Configuration clickhouse-go client connection configuration for read trace.
7+
// more detail see:https://clickhouse.com/docs/integrations/go#connection-settings
68
type Configuration struct {
79
Address []string `mapstructure:"address"`
810
Database string `mapstructure:"database"`

internal/storage/v2/clickhouse/client/mocks/Chpool.go

-66
This file was deleted.

internal/storage/v2/clickhouse/client/mocks/Clickhouse.go

-64
This file was deleted.

internal/storage/v2/clickhouse/client/pool/config.go

+3
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,21 @@ const (
1414
DefaultHealthCheckPeriod = time.Minute
1515
)
1616

17+
// Configuration chpool configuration for write trace.
1718
type Configuration struct {
1819
ClientConfig ClientConfig `mapstructure:"client"`
1920
PoolConfig Config `mapstructure:"pool"`
2021
}
2122

23+
// ClientConfig client configuration be used to connect to server.
2224
type ClientConfig struct {
2325
Address string `mapstructure:"address"`
2426
Database string `mapstructure:"database"`
2527
Username string `mapstructure:"username"`
2628
Password string `mapstructure:"password"`
2729
}
2830

31+
// Config connection pool configuration be used to define every connection lifecycle.
2932
type Config struct {
3033
MaxConnLifetime time.Duration `mapstructure:"max_connection_lifetime"`
3134
MaxConnIdleTime time.Duration `mapstructure:"max_connection_idle_time"`

internal/storage/v2/clickhouse/config/config.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ import (
88
"github.com/jaegertracing/jaeger/internal/storage/v2/clickhouse/client/pool"
99
)
1010

11+
// Configuration all configuration of how to use clickhouse as storage.
12+
// ConnConfig clickhouse-go client configuration
13+
// PoolConfig chpool configuration
14+
// CreateSchema create requre table auto if not exist.
1115
type Configuration struct {
1216
ConnConfig conn.Configuration
1317
PoolConfig pool.Configuration
@@ -18,6 +22,6 @@ func DefaultConfiguration() Configuration {
1822
return Configuration{
1923
conn.DefaultConfig(),
2024
pool.DefaultConfig(),
21-
false,
25+
true,
2226
}
2327
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright (c) 2025 The Jaeger Authors.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package config
5+
6+
import (
7+
"testing"
8+
9+
"github.com/stretchr/testify/assert"
10+
11+
"github.com/jaegertracing/jaeger/internal/storage/v2/clickhouse/client/conn"
12+
"github.com/jaegertracing/jaeger/internal/storage/v2/clickhouse/client/pool"
13+
)
14+
15+
func TestDefaultConfig(t *testing.T) {
16+
excepted := Configuration{
17+
ConnConfig: conn.DefaultConfig(),
18+
PoolConfig: pool.DefaultConfig(),
19+
CreateSchema: true,
20+
}
21+
22+
actual := DefaultConfiguration()
23+
assert.Equal(t, excepted, actual)
24+
}

internal/storage/v2/clickhouse/schema/schema.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/jaegertracing/jaeger/internal/storage/v2/clickhouse/client"
1414
)
1515

16-
//go:embed init.tmpl
16+
//go:embed schema.tmpl
1717
var schemaFile embed.FS
1818

1919
func getQueryFileAsBytes(fileName string) ([]byte, error) {
@@ -59,7 +59,7 @@ func getQueriesFromBytes(queryFile []byte) ([]string, error) {
5959
}
6060

6161
func constructSchemaQueries() ([]string, error) {
62-
queryFile, err := getQueryFileAsBytes("init.tmpl")
62+
queryFile, err := getQueryFileAsBytes("schema.tmpl")
6363
if err != nil {
6464
return nil, err
6565
}

internal/storage/v2/clickhouse/trace/reader.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
"github.com/jaegertracing/jaeger/internal/storage/v2/clickhouse/trace/dbmodel"
1616
)
1717

18-
const querySQL = `
18+
const getTraces = `
1919
SELECT
2020
Timestamp,
2121
TraceId,
@@ -71,7 +71,7 @@ func (tr Reader) GetTraces(
7171
) iter.Seq2[[]ptrace.Traces, error] {
7272
return func(yield func([]ptrace.Traces, error) bool) {
7373
for _, id := range traceIDs {
74-
tds, err := tr.getTraces(ctx, querySQL, id)
74+
tds, err := tr.getTraces(ctx, getTraces, id)
7575
if err != nil {
7676
if errors.Is(err, errors.New("trace not found")) {
7777
continue

internal/storage/v2/clickhouse/trace/writer.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/jaegertracing/jaeger/internal/storage/v2/clickhouse/client"
1414
)
1515

16-
const INSERT_SQL = `INSERT INTO otel_traces (
16+
const write_traces = `INSERT INTO otel_traces (
1717
Timestamp,
1818
TraceId,
1919
SpanId,
@@ -61,7 +61,7 @@ func (t *Writer) WriteTraces(ctx context.Context, td ptrace.Traces) error {
6161
}
6262

6363
func (t *Writer) writeTraces(ctx context.Context, td ptrace.Traces) error {
64-
err := t.Client.Do(ctx, INSERT_SQL, td)
64+
err := t.Client.Do(ctx, write_traces, td)
6565
if err != nil {
6666
return err
6767
}

internal/storage/v2/clickhouse/wrapper/wrapper.go

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"github.com/jaegertracing/jaeger/internal/storage/v2/clickhouse/internal"
1919
)
2020

21+
// WrapDial wrap chpool.Dial return an abstraction connection pool.
2122
func WrapDial(config pool.Configuration, log *zap.Logger) (client.Pool, error) {
2223
option := chpool.Options{
2324
ClientOptions: ch.Options{
@@ -70,6 +71,7 @@ func (c PoolWrapper) WrapDo(ctx context.Context, query ch.Query) error {
7071
return c.Pool.Do(ctx, query)
7172
}
7273

74+
// WrapOpen wrap clickhouse.Open return an abstraction connection.
7375
func WrapOpen(config conn.Configuration) (client.Conn, error) {
7476
option := v2Client.Options{
7577
Addr: config.Address,
@@ -101,6 +103,7 @@ func (c ConnWrapper) Query(ctx context.Context, query string, args string) (clie
101103
return c.WrapQuery(ctx, query, args)
102104
}
103105

106+
// Exec execute given query
104107
func (c ConnWrapper) Exec(ctx context.Context, query string) error {
105108
return c.WrapExec(ctx, query)
106109
}

jaeger-ui

Submodule jaeger-ui updated 29 files

scripts/e2e/clickhouse.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
export CLICKHOUSE_USERNAME="default"
77
export CLICKHOUSE_PASSWORD="default"
8+
export QUERY_FILE="/clickhouse-schema/schema.tmpl"
89
compose_file="docker-compose/clickhouse/docker-compose.yml"
910
SKIP_APPLY_SCHEMA=${SKIP_APPLY_SCHEMA:-"false"}
10-
export CLICKHOUSE_CREATE_SCHEMA=${SKIP_APPLY_SCHEMA}
1111

1212
setup_clickhouse() {
1313
docker compose -f "$compose_file" up -d
@@ -31,7 +31,7 @@ apply_schema() {
3131
local params=(
3232
--rm
3333
--env "CLICKHOUSE_HOST=localhost"
34-
--env "QUERY_FILE=/clickhouse-schema/init.tmpl"
34+
--env "QUERY_FILE=${QUERY_FILE}"
3535
--env "CLICKHOUSE_USERNAME=${CLICKHOUSE_USERNAME}"
3636
--env "CLICKHOUSE_PASSWORD=${CLICKHOUSE_PASSWORD}"
3737
--network host

0 commit comments

Comments
 (0)