· 8 years ago · Aug 06, 2018, 11:18 AM
1CREATE KEYSPACE IF NOT EXISTS ${keyspace} WITH replication = {'class': 'NetworkTopologyStrategy', '${datacenter}': '${replication_factor}' };
2
3CREATE TYPE IF NOT EXISTS ${keyspace}.keyvalue (
4 key text,
5 value_type text,
6 value_string text,
7 value_bool boolean,
8 value_long bigint,
9 value_double double,
10 value_binary blob
11);
12
13CREATE TYPE IF NOT EXISTS ${keyspace}.log (
14 ts bigint,
15 fields frozen<list<frozen<keyvalue>>>
16);
17
18CREATE TYPE IF NOT EXISTS ${keyspace}.span_ref (
19 ref_type text,
20 trace_id blob,
21 span_id bigint
22);
23
24CREATE TYPE IF NOT EXISTS ${keyspace}.process (
25 service_name text,
26 tags frozen<list<frozen<keyvalue>>>
27);
28
29CREATE TABLE IF NOT EXISTS ${keyspace}.traces (
30 trace_id blob,
31 span_id bigint,
32 span_hash bigint,
33 parent_id bigint,
34 operation_name text,
35 flags int,
36 start_time bigint,
37 "duration" bigint,
38 tags frozen<list<frozen<keyvalue>>>,
39 logs frozen<list<frozen<log>>>,
40 refs frozen<list<frozen<span_ref>>>,
41 process frozen<process>,
42 PRIMARY KEY (trace_id, span_id, span_hash))
43 WITH compaction = {
44 'compaction_window_size': '1',
45 'compaction_window_unit': 'HOURS',
46 'class': 'org.apache.cassandra.db.compaction.TimeWindowCompactionStrategy'
47 }
48 AND dclocal_read_repair_chance = 0.0
49 AND default_time_to_live = ${trace_ttl}
50 AND gc_grace_seconds = 0;
51
52CREATE TABLE IF NOT EXISTS ${keyspace}.service_names (
53 service_name text,
54 PRIMARY KEY (service_name)
55)
56WITH compaction = {
57 'min_threshold': '4',
58 'max_threshold': '32',
59 'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy'
60}
61AND dclocal_read_repair_chance = 0.0
62AND default_time_to_live = ${trace_ttl}
63AND speculative_retry = 'NONE'
64AND gc_grace_seconds = 0;
65
66CREATE TABLE IF NOT EXISTS ${keyspace}.operation_names (
67 service_name text,
68 operation_name text,
69 PRIMARY KEY ((service_name), operation_name)
70) WITH compaction = {
71 'min_threshold': '4',
72 'max_threshold': '32',
73 'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy'
74}
75AND dclocal_read_repair_chance = 0.0
76AND default_time_to_live = ${trace_ttl}
77AND speculative_retry = 'NONE'
78AND gc_grace_seconds = 0;
79
80CREATE TABLE IF NOT EXISTS ${keyspace}.service_operation_index (
81 service_name text,
82 operation_name text,
83 start_time bigint,
84 trace_id blob,
85 PRIMARY KEY ((service_name, operation_name), start_time)
86) WITH CLUSTERING ORDER BY (start_time DESC)
87 AND compaction = {
88 'compaction_window_size': '1',
89 'compaction_window_unit': 'HOURS',
90 'class': 'org.apache.cassandra.db.compaction.TimeWindowCompactionStrategy'
91 }
92 AND dclocal_read_repair_chance = 0.0
93 AND default_time_to_live = ${trace_ttl}
94 AND speculative_retry = 'NONE'
95 AND gc_grace_seconds = 0;
96
97CREATE TABLE IF NOT EXISTS ${keyspace}.service_name_index (
98 service_name text,
99 bucket int,
100 start_time bigint,
101 trace_id blob,
102 PRIMARY KEY ((service_name, bucket), start_time)
103) WITH CLUSTERING ORDER BY (start_time DESC)
104 AND compaction = {
105 'compaction_window_size': '1',
106 'compaction_window_unit': 'HOURS',
107 'class': 'org.apache.cassandra.db.compaction.TimeWindowCompactionStrategy'
108 }
109 AND dclocal_read_repair_chance = 0.0
110 AND default_time_to_live = ${trace_ttl}
111 AND speculative_retry = 'NONE'
112 AND gc_grace_seconds = 0;
113
114CREATE TABLE IF NOT EXISTS ${keyspace}.duration_index (
115 service_name text,
116 operation_name text,
117 bucket timestamp,
118 "duration" bigint,
119 start_time bigint,
120 trace_id blob,
121 PRIMARY KEY ((service_name, operation_name, bucket), "duration", start_time, trace_id)
122) WITH CLUSTERING ORDER BY ("duration" DESC, start_time DESC, trace_id DESC)
123 AND compaction = {
124 'compaction_window_size': '1',
125 'compaction_window_unit': 'HOURS',
126 'class': 'org.apache.cassandra.db.compaction.TimeWindowCompactionStrategy'
127 }
128 AND dclocal_read_repair_chance = 0.0
129 AND default_time_to_live = ${trace_ttl}
130 AND speculative_retry = 'NONE'
131AND gc_grace_seconds = 0;
132
133CREATE TABLE IF NOT EXISTS ${keyspace}.tag_index (
134 service_name text,
135 tag_key text,
136 tag_value text,
137 start_time bigint,
138 trace_id blob,
139 span_id bigint,
140 PRIMARY KEY ((service_name, tag_key, tag_value), start_time, trace_id, span_id)
141) WITH CLUSTERING ORDER BY (start_time DESC, trace_id DESC, span_id DESC)
142 AND compaction = {
143 'compaction_window_size': '1',
144 'compaction_window_unit': 'HOURS',
145 'class': 'org.apache.cassandra.db.compaction.TimeWindowCompactionStrategy'
146 }
147 AND dclocal_read_repair_chance = 0.0
148 AND default_time_to_live = ${trace_ttl}
149 AND speculative_retry = 'NONE'
150 AND gc_grace_seconds = 0;
151
152CREATE TYPE IF NOT EXISTS ${keyspace}.dependency (
153 parent text,
154 child text,
155 call_count bigint
156);
157
158CREATE TABLE IF NOT EXISTS ${keyspace}.dependencies (
159 ts timestamp,
160 ts_index timestamp,
161 dependencies list<frozen<dependency>>,
162 PRIMARY KEY (ts)
163) WITH compaction = {
164 'min_threshold': '4',
165 'max_threshold': '32',
166 'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy'
167 }
168 AND default_time_to_live = ${dependencies_ttl};