Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions internal/storage/v2/clickhouse/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ func NewFactory(ctx context.Context, cfg Configuration, telset telemetry.Setting
{"services materialized view", sql.CreateServicesMaterializedView},
{"operations table", sql.CreateOperationsTable},
{"operations materialized view", sql.CreateOperationsMaterializedView},
{"trace id timestamps table", sql.CreateTraceIDTimestampsTable},
{"trace id timestamps materialized view", sql.CreateTraceIDTimestampsMaterializedView},
}

for _, schema := range schemas {
Expand Down
14 changes: 14 additions & 0 deletions internal/storage/v2/clickhouse/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,20 @@ func TestNewFactory_Errors(t *testing.T) {
},
expectedError: "failed to create operations materialized view",
},
{
name: "trace id timestamps table creation error",
failureConfig: clickhousetest.FailureConfig{
sql.CreateTraceIDTimestampsTable: errors.New("trace id timestamps table creation error"),
},
expectedError: "failed to create trace id timestamps table",
},
{
name: "trace id timestamps materialized view creation error",
failureConfig: clickhousetest.FailureConfig{
sql.CreateTraceIDTimestampsMaterializedView: errors.New("trace id timestamps materialized view creation error"),
},
expectedError: "failed to create trace id timestamps materialized view",
},
}

for _, tt := range tests {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ SELECT
FROM
spans
GROUP BY
service_name
service_name;
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CREATE MATERIALIZED VIEW IF NOT EXISTS trace_id_timestamps_mv
TO trace_id_timestamps
AS
SELECT
trace_id,
min(start_time) AS start,
max(start_time) AS end
FROM spans
GROUP BY trace_id;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CREATE TABLE IF NOT EXISTS trace_id_timestamps
(
trace_id String,
start DateTime64(9),
end DateTime64(9)
)
ENGINE = MergeTree()
ORDER BY (trace_id);
6 changes: 6 additions & 0 deletions internal/storage/v2/clickhouse/sql/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,9 @@ var CreateOperationsTable string

//go:embed create_operations_mv.sql
var CreateOperationsMaterializedView string

//go:embed create_trace_id_timestamps_table.sql
var CreateTraceIDTimestampsTable string

//go:embed create_trace_id_timestamps_mv.sql
var CreateTraceIDTimestampsMaterializedView string
Loading