Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
-- migrate:up

CREATE TABLE IF NOT EXISTS cosmo.otel_spans_by_trace (
FederatedGraphID String CODEC (ZSTD(3)),
Comment thread
comatory marked this conversation as resolved.
OrganizationID LowCardinality(String) CODEC (ZSTD(3)),
Comment thread
comatory marked this conversation as resolved.
TraceId String CODEC (ZSTD(3)),
Timestamp DateTime64(9) CODEC (Delta(8), ZSTD(3)),
SpanId String CODEC (ZSTD(3)),
ParentSpanId String CODEC (ZSTD(3)),
SpanName LowCardinality(String) CODEC (ZSTD(3)),
SpanKind LowCardinality(String) CODEC (ZSTD(3)),
ServiceName LowCardinality(String) CODEC (ZSTD(3)),
Duration Int64 CODEC (ZSTD(3)),
StatusCode LowCardinality(String) CODEC (ZSTD(3)),
StatusMessage String CODEC (ZSTD(3)),
ScopeName String CODEC (ZSTD(3)),
SpanAttributes Map(LowCardinality(String), String) CODEC (ZSTD(3))
) ENGINE = MergeTree
PARTITION BY toDate(Timestamp)
ORDER BY (FederatedGraphID, OrganizationID, TraceId, Timestamp, SpanId)
TTL toDateTime(Timestamp) + toIntervalDay(30) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;

-- migrate:down

DROP TABLE IF EXISTS cosmo.otel_spans_by_trace
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
-- migrate:up

CREATE MATERIALIZED VIEW IF NOT EXISTS cosmo.otel_spans_by_trace_mv TO cosmo.otel_spans_by_trace AS
Comment thread
comatory marked this conversation as resolved.
SELECT
SpanAttributes ['wg.federated_graph.id'] as FederatedGraphID,
toLowCardinality(SpanAttributes ['wg.organization.id']) as OrganizationID,
TraceId,
Timestamp,
SpanId,
ParentSpanId,
SpanName,
SpanKind,
ServiceName,
Duration,
StatusCode,
StatusMessage,
ScopeName,
SpanAttributes
FROM
cosmo.otel_traces
WHERE
SpanAttributes ['wg.federated_graph.id'] != '';

-- migrate:down

DROP VIEW IF EXISTS cosmo.otel_spans_by_trace_mv
Loading