-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(backend): add user defined attrs to spans
closes #1740
- Loading branch information
1 parent
0721674
commit d29f5cb
Showing
13 changed files
with
268 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
-- migrate:up | ||
alter table spans | ||
add column if not exists user_defined_attribute Map(LowCardinality(String), Tuple(Enum('string' = 1, 'int64', 'float64', 'bool'), String)) codec(ZSTD(3)) after `attribute.device_thermal_throttling_enabled`, | ||
comment column if exists user_defined_attribute 'user defined attributes', | ||
add index if not exists user_defined_attribute_key_bloom_idx mapKeys(user_defined_attribute) type bloom_filter(0.01) granularity 16, | ||
add index if not exists user_defined_attribute_key_minmax_idx mapKeys(user_defined_attribute) type minmax granularity 16, | ||
materialize index if exists user_defined_attribute_key_bloom_idx, | ||
materialize index if exists user_defined_attribute_key_minmax_idx; | ||
|
||
|
||
-- migrate:down | ||
alter table spans | ||
drop column if exists user_defined_attribute, | ||
drop index if exists user_defined_attribute_key_bloom_idx, | ||
drop index if exists user_defined_attribute_key_minmax_idx; |
27 changes: 27 additions & 0 deletions
27
self-host/clickhouse/20250204070357_create_span_user_def_attrs.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
-- migrate:up | ||
create table if not exists span_user_def_attrs | ||
( | ||
`app_id` UUID not null comment 'associated app id' codec(LZ4), | ||
`span_id` FixedString(16) not null comment 'id of the span' codec(ZSTD(3)), | ||
`session_id` UUID not null comment 'id of the session' codec(LZ4), | ||
`end_of_month` DateTime not null comment 'last day of the month' codec(DoubleDelta, ZSTD(3)), | ||
`app_version` Tuple(LowCardinality(String), LowCardinality(String)) not null comment 'composite app version' codec(ZSTD(3)), | ||
`os_version` Tuple(LowCardinality(String), LowCardinality(String)) comment 'composite os version' codec (ZSTD(3)), | ||
`key` LowCardinality(String) comment 'key of the user defined attribute' codec (ZSTD(3)), | ||
`type` Enum('string' = 1, 'int64', 'float64', 'bool') comment 'type of the user defined attribute' codec (ZSTD(3)), | ||
`value` String comment 'value of the user defined attribute' codec (ZSTD(3)), | ||
index end_of_month_minmax_idx end_of_month type minmax granularity 2, | ||
index key_bloom_idx key type bloom_filter(0.05) granularity 1, | ||
index key_set_idx key type set(1000) granularity 2, | ||
index session_bloom_idx session_id type bloom_filter granularity 2 | ||
) | ||
engine = ReplacingMergeTree | ||
partition by toYYYYMM(end_of_month) | ||
order by (app_id, end_of_month, app_version, os_version, key, type, value, span_id, session_id) | ||
settings index_granularity = 8192 | ||
comment 'derived span user defined attributes'; | ||
|
||
|
||
-- migrate:down | ||
drop table if exists span_user_def_attrs; | ||
|
23 changes: 23 additions & 0 deletions
23
self-host/clickhouse/20250204070548_create_span_user_def_attrs_mv.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
-- migrate:up | ||
create materialized view span_user_def_attrs_mv to span_user_def_attrs as | ||
select distinct app_id, | ||
span_id, | ||
session_id, | ||
toLastDayOfMonth(start_time) as end_of_month, | ||
attribute.app_version as app_version, | ||
attribute.os_version as os_version, | ||
arr_key as key, | ||
tupleElement(arr_val, 1) as type, | ||
tupleElement(arr_val, 2) as value | ||
from spans | ||
array join | ||
mapKeys(user_defined_attribute) as arr_key, | ||
mapValues(user_defined_attribute) as arr_val | ||
where length(user_defined_attribute) > 0 | ||
group by app_id, end_of_month, app_version, os_version, | ||
key, type, value, span_id, session_id | ||
order by app_id; | ||
|
||
|
||
-- migrate:down | ||
drop view if exists span_user_def_attrs_mv; |
Oops, something went wrong.