Skip to content

Commit

Permalink
feat: support insert trace through the distributed table
Browse files Browse the repository at this point in the history
  • Loading branch information
Cluas committed Oct 14, 2024
1 parent 4dcd757 commit 31c5f9c
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion lib/db/maintain/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,33 @@ module.exports.traces_dist = [
span_id FixedString(8),
timestamp_ns Int64,
duration Int64
) ENGINE = Distributed('{{CLUSTER}}','{{DB}}', 'tempo_traces_attrs_gin', sipHash64(oid, trace_id)) {{{DIST_CREATE_SETTINGS}}};`
) ENGINE = Distributed('{{CLUSTER}}','{{DB}}', 'tempo_traces_attrs_gin', sipHash64(oid, trace_id)) {{{DIST_CREATE_SETTINGS}}};`,

`CREATE TABLE IF NOT EXISTS {{DB}}.traces_input_dist {{{OnCluster}}} AS {{DB}}.traces_input;`,

`CREATE MATERIALIZED VIEW IF NOT EXISTS {{DB}}.traces_input_traces_dist_mv {{{OnCluster}}} TO tempo_traces_dist AS
SELECT oid,
unhex(trace_id)::FixedString(16) as trace_id,
unhex(span_id)::FixedString(8) as span_id,
unhex(parent_id) as parent_id,
name,
timestamp_ns,
duration_ns,
service_name,
payload_type,
payload
FROM traces_input_dist`,

`CREATE MATERIALIZED VIEW IF NOT EXISTS {{DB}}.traces_input_tags_dist_mv {{{OnCluster}}} TO tempo_traces_attrs_gin_dist AS
SELECT oid,
toDate(intDiv(timestamp_ns, 1000000000)) as date,
tags.1 as key,
tags.2 as val,
unhex(trace_id)::FixedString(16) as trace_id,
unhex(span_id)::FixedString(8) as span_id,
timestamp_ns,
duration_ns as duration
FROM traces_input_dist ARRAY JOIN tags`,
]

module.exports.profiles = [
Expand Down

0 comments on commit 31c5f9c

Please sign in to comment.