@@ -175,4 +175,82 @@ export const action: Action = async exec => {
175
175
empty("ParentSpanId")
176
176
)
177
177
` ) ;
178
+
179
+ // These can be used for dedicated subgraph views
180
+
181
+ // await exec(`
182
+ // CREATE TABLE IF NOT EXISTS "otel_subgraph_spans" (
183
+ // "target_id" LowCardinality(String) CODEC(ZSTD(1))
184
+ // , "subgraph_name" String CODEC(ZSTD(1))
185
+ // , "trace_id" String CODEC(ZSTD(1))
186
+ // , "span_id" String CODEC(ZSTD(1))
187
+ // , "timestamp" DateTime('UTC') CODEC(DoubleDelta, LZ4)
188
+ // , "duration" UInt64 CODEC(T64, ZSTD(1))
189
+ // , "http_status_code" String CODEC(ZSTD(1))
190
+ // , "http_method" String CODEC(ZSTD(1))
191
+ // , "http_host" String CODEC(ZSTD(1))
192
+ // , "http_route" String CODEC(ZSTD(1))
193
+ // , "http_url" String CODEC(ZSTD(1))
194
+ // , "graphql_operation_name" String CODEC(ZSTD(1))
195
+ // , "graphql_operation_type" LowCardinality(String) CODEC(ZSTD(1))
196
+ // , "graphql_operation_document" String CODEC(ZSTD(1))
197
+ // , "graphql_error_count" UInt32 CODEC(T64, ZSTD(1))
198
+ // , "graphql_error_codes" Array(LowCardinality(String)) CODEC(ZSTD(1))
199
+ // )
200
+ // ENGINE = MergeTree
201
+ // PARTITION BY toDate("timestamp")
202
+ // ORDER BY ("target_id", "subgraph_name", "timestamp")
203
+ // TTL toDateTime(timestamp) + toIntervalDay(365)
204
+ // SETTINGS
205
+ // index_granularity = 8192
206
+ // , ttl_only_drop_parts = 1
207
+ // `);
208
+
209
+ // await exec(`
210
+ // CREATE MATERIALIZED VIEW IF NOT EXISTS "otel_subgraph_spans_mv" TO "otel_subgraph_spans" (
211
+ // "target_id" LowCardinality(String)
212
+ // , "subgraph_name" Array(String)
213
+ // , "trace_id" String
214
+ // , "span_id" String
215
+ // , "timestamp" DateTime('UTC')
216
+ // , "duration" UInt64
217
+ // , "http_status_code" String
218
+ // , "http_host" String
219
+ // , "http_method" String
220
+ // , "http_route" String
221
+ // , "http_url" String
222
+ // , "client_name" String
223
+ // , "client_version" String
224
+ // , "graphql_operation_name" String
225
+ // , "graphql_operation_type" LowCardinality(String)
226
+ // , "graphql_operation_document" String
227
+ // , "graphql_error_count" UInt32
228
+ // , "graphql_error_codes" Array(LowCardinality(String))
229
+ // )
230
+ // AS (
231
+ // SELECT
232
+ // toLowCardinality("SpanAttributes"['hive.target_id']) AS "target_id"
233
+ // , "SpanAttributes"['hive.graphql.subgraph.name'] AS "subgraph_name"
234
+ // , "TraceId" as "trace_id"
235
+ // , "SpanId" AS "span_id"
236
+ // , toDateTime("Timestamp", 'UTC') AS "timestamp"
237
+ // , "Duration" AS "duration"
238
+ // , "SpanAttributes"['http.status_code'] AS "http_status_code"
239
+ // , "SpanAttributes"['http.host'] AS "http_host"
240
+ // , "SpanAttributes"['http.method'] AS "http_method"
241
+ // , "SpanAttributes"['http.route'] AS "http_route"
242
+ // , "SpanAttributes"['http.url'] AS "http_url"
243
+ // , "SpanAttributes"['hive.client.name'] AS "client_name"
244
+ // , "SpanAttributes"['hive.client.version'] AS "client_version"
245
+ // , "SpanAttributes"['hive.graphql.operation.name'] AS "graphql_operation_name"
246
+ // , toLowCardinality("SpanAttributes"['hive.graphql.operation.type']) AS "graphql_operation_type"
247
+ // , "SpanAttributes"['hive.graphql.operation.document'] AS "graphql_operation_document"
248
+ // , "SpanAttributes"['hive.graphql.error.count'] AS "graphql_error_count"
249
+ // , arrayMap(x -> toLowCardinality(x), splitByChar(',', "SpanAttributes"['hive.graphql.error.codes'])) AS "graphql_error_codes"
250
+ // FROM
251
+ // "otel_traces"
252
+ // WHERE
253
+ // startsWith("SpanName", 'subgraph.execute')
254
+ // )
255
+ // `);
178
256
} ;
0 commit comments