Skip to content

Commit

Permalink
[feat][storage]: add write path for ClickHouse based on Jaeger V2
Browse files Browse the repository at this point in the history
Signed-off-by: zzzk1 <[email protected]>
  • Loading branch information
zzzk1 committed Feb 14, 2025
1 parent 4b884bb commit 51b3f8f
Show file tree
Hide file tree
Showing 24 changed files with 1,214 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci-e2e-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ jobs:
opensearch:
uses: ./.github/workflows/ci-e2e-opensearch.yml

clickhouse:
uses: ./.github/workflows/ci-e2e-clickhouse.yml
49 changes: 49 additions & 0 deletions .github/workflows/ci-e2e-clickhouse.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: CIT ClickHouse

on:
workflow_call:

concurrency:
group: cit-kafka-${{ 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:
jaeger-version: [v2]
clickhouse-version: ["25.x"]
name: clickhouse ${{matrix.clickhouse-version }} ${{ matrix.jaeger-version }}
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

- uses: ./.github/actions/verify-metrics-snapshot
if: matrix.jaeger-version == 'v2'
with:
snapshot: metrics_snapshot_clickhouse
artifact_key: metrics_snapshot_clickhouse_${{ matrix.jaeger-version }}

- name: Upload coverage to codecov
uses: ./.github/actions/upload-codecov
with:
files: cover.out
flags: clickhouse-${{ matrix.clickhouse-version }}-${{ matrix.jaeger-version }}
5 changes: 5 additions & 0 deletions .mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ packages:
github.com/jaegertracing/jaeger/pkg/es/client:
config:
all: true
github.com/jaegertracing/jaeger/pkg/clickhouse:
config:
all: true
interfaces:
Client:
github.com/jaegertracing/jaeger/pkg/kafka/consumer:
interfaces:
Consumer:
Expand Down
11 changes: 11 additions & 0 deletions docker-compose/clickhouse/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
services:
clickhouse:
container_name: clickhouse
image: bitnami/clickhouse:25.1.3
environment:
CLICKHOUSE_USER: "default"
CLICKHOUSE_PASSWORD: "default"
ports:
- 9000:9000
volumes:
- ./init.sql:/docker-entrypoint-initdb.d/init.sql
48 changes: 48 additions & 0 deletions docker-compose/clickhouse/init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
CREATE DATABASE IF NOT EXISTS jaeger;

CREATE TABLE IF NOT EXISTS jaeger.otel_traces (
Timestamp DateTime64(9) CODEC(Delta, ZSTD(1)),
TraceId String CODEC(ZSTD(1)),
SpanId String CODEC(ZSTD(1)),
ParentSpanId String CODEC(ZSTD(1)),
TraceState String CODEC(ZSTD(1)),
SpanName LowCardinality(String) CODEC(ZSTD(1)),
SpanKind LowCardinality(String) CODEC(ZSTD(1)),
ServiceName LowCardinality(String) CODEC(ZSTD(1)),
ResourceAttributes Nested
(
keys LowCardinality(String),
values String
) CODEC (ZSTD(1)),
ScopeName String CODEC(ZSTD(1)),
ScopeVersion String CODEC(ZSTD(1)),
SpanAttributes Nested
(
keys LowCardinality(String),
values String
) CODEC (ZSTD(1)),
Duration UInt64 CODEC(ZSTD(1)),
StatusCode LowCardinality(String) CODEC(ZSTD(1)),
StatusMessage String CODEC(ZSTD(1)),
Events Nested (
Timestamp DateTime64(9),
Name LowCardinality(String),
Attributes Map(LowCardinality(String), String)
) CODEC(ZSTD(1)),
Links Nested (
TraceId String,
SpanId String,
TraceState String,
Attributes Map(LowCardinality(String), String)
) CODEC(ZSTD(1)),
INDEX idx_trace_id TraceId TYPE bloom_filter(0.001) GRANULARITY 1,
INDEX idx_res_attr_key ResourceAttributes.keys TYPE bloom_filter(0.01) GRANULARITY 1,
INDEX idx_res_attr_value ResourceAttributes.values TYPE bloom_filter(0.01) GRANULARITY 1,
INDEX idx_span_attr_key SpanAttributes.keys TYPE bloom_filter(0.01) GRANULARITY 1,
INDEX idx_span_attr_value SpanAttributes.values TYPE bloom_filter(0.01) GRANULARITY 1,
INDEX idx_duration Duration TYPE minmax GRANULARITY 1
) ENGINE MergeTree()

PARTITION BY toDate(Timestamp)
ORDER BY (ServiceName, SpanName, toUnixTimestamp(Timestamp), SpanAttributes.keys, SpanAttributes.values, Duration, TraceId)
SETTINGS index_granularity=8192, ttl_only_drop_parts = 1;
16 changes: 15 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ go 1.23.7
toolchain go1.24.0

require (
github.com/ClickHouse/ch-go v0.64.1
github.com/ClickHouse/clickhouse-go/v2 v2.31.0
github.com/HdrHistogram/hdrhistogram-go v1.1.2
github.com/Shopify/sarama v1.37.2
github.com/apache/thrift v0.21.0
Expand Down Expand Up @@ -105,10 +107,22 @@ require (
)

require (
github.com/andybalholm/brotli v1.1.1 // indirect
github.com/dmarkham/enumer v1.5.10 // indirect
github.com/go-faster/city v1.0.1 // indirect
github.com/go-faster/errors v0.7.1 // indirect
github.com/gogo/googleapis v1.4.1 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/core/xidutils v0.119.0 // indirect
github.com/pascaldekloe/name v1.0.1 // indirect
github.com/paulmach/orb v0.11.1 // indirect
github.com/segmentio/asm v1.2.0 // indirect
github.com/shopspring/decimal v1.4.0 // indirect
go.opentelemetry.io/collector/extension/xextension v0.119.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.10.0 // indirect
golang.org/x/mod v0.19.0 // indirect
golang.org/x/sync v0.11.0 // indirect
golang.org/x/tools v0.23.0 // indirect
)

require (
Expand Down Expand Up @@ -264,7 +278,7 @@ require (
go.opentelemetry.io/collector/processor/xprocessor v0.119.0 // indirect
go.opentelemetry.io/collector/receiver/receivertest v0.119.0 // indirect
go.opentelemetry.io/collector/receiver/xreceiver v0.119.0 // indirect
go.opentelemetry.io/collector/semconv v0.119.0 // indirect
go.opentelemetry.io/collector/semconv v0.119.0
go.opentelemetry.io/collector/service v0.119.0 // indirect
go.opentelemetry.io/contrib/bridges/otelzap v0.9.0 // indirect
go.opentelemetry.io/contrib/config v0.14.0 // indirect
Expand Down
Loading

0 comments on commit 51b3f8f

Please sign in to comment.