{"action":"created","issue":{"url":"https://api.github.com/repos/openzipkin/zipkin/issues/1252","repository_url":"https://api.github.com/repos/openzipkin/zipkin","labels_url":"https://api.github.com/repos/openzipkin/zipkin/issues/1252/labels{/name}","comments_url":"https://api.github.com/repos/openzipkin/zipkin/issues/1252/comments","events_url":"https://api.github.com/repos/openzipkin/zipkin/issues/1252/events","html_url":"https://github.com/openzipkin/zipkin/pull/1252","id":172839310,"number":1252,"title":"New datamodel using Cassandra-3.9","user":{"login":"michaelsembwever","id":559444,"avatar_url":"https://avatars.githubusercontent.com/u/559444?v=3","gravatar_id":"","url":"https://api.github.com/users/michaelsembwever","html_url":"https://github.com/michaelsembwever","followers_url":"https://api.github.com/users/michaelsembwever/followers","following_url":"https://api.github.com/users/michaelsembwever/following{/other_user}","gists_url":"https://api.github.com/users/michaelsembwever/gists{/gist_id}","starred_url":"https://api.github.com/users/michaelsembwever/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaelsembwever/subscriptions","organizations_url":"https://api.github.com/users/michaelsembwever/orgs","repos_url":"https://api.github.com/users/michaelsembwever/repos","events_url":"https://api.github.com/users/michaelsembwever/events{/privacy}","received_events_url":"https://api.github.com/users/michaelsembwever/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":48,"created_at":"2016-08-24T00:34:57Z","updated_at":"2016-09-07T08:47:19Z","closed_at":"2016-09-07T08:15:40Z","pull_request":{"url":"https://api.github.com/repos/openzipkin/zipkin/pulls/1252","html_url":"https://github.com/openzipkin/zipkin/pull/1252","diff_url":"https://github.com/openzipkin/zipkin/pull/1252.diff","patch_url":"https://github.com/openzipkin/zipkin/pull/1252.patch"},"body":"Discussions in https://github.com/openzipkin/zipkin/pull/1204 lead to an agreement that upgrading the C* datamodel and taking advantage of latest features may be the best path forward.\r\n\r\nZipkin Cassandra clusters are expected to be dedicated clusters, therefore should be relatively free to upgrade.\r\n\r\nThe new datamodel takes advantage of MATERIALIZED VIEWS and SASI (b-tree secondary indexes).\r\n\r\nIt reduces 7 tables down to 2 tables. (Excluding the dependencies table.)\r\n\r\nThe new schema is…\r\n```\r\n\r\nCREATE TYPE IF NOT EXISTS endpoint (\r\n    service_name text,\r\n    ipv4         inet,\r\n    ipv6         inet,\r\n    port         smallint,\r\n);\r\n\r\nCREATE TYPE IF NOT EXISTS annotation (\r\n    ts bigint,\r\n    v  text,\r\n    ep frozen<endpoint>\r\n);\r\n\r\nCREATE TYPE IF NOT EXISTS binary_annotation (\r\n    k  text,\r\n    v  blob,\r\n    t  text,\r\n    ep frozen<endpoint>\r\n);\r\n\r\nCREATE TABLE IF NOT EXISTS traces (\r\n    trace_id            varint,\r\n    ts_uuid             timeuuid,\r\n    id                  bigint,\r\n    ts                  bigint,\r\n    span_name           text,\r\n    parent_id           bigint,\r\n    duration            bigint,\r\n    annotations         list<frozen<annotation>>,\r\n    binary_annotations  list<frozen<binary_annotation>>,\r\n    all_annotations     text,\r\n    PRIMARY KEY (trace_id, ts_uuid, id)\r\n)\r\n    WITH CLUSTERING ORDER BY (ts_uuid DESC)\r\n    AND compaction = {'class': 'org.apache.cassandra.db.compaction.TimeWindowCompactionStrategy'}\r\n    AND default_time_to_live =  604800;\r\n\r\n\r\nCREATE TABLE trace_by_service_span (\r\n    service_name  text,      // service name\r\n    span_name     text,      // span name, or blank for queries without span name\r\n    bucket        int,       // time bucket, calculated as ts/interval (in microseconds), for some pre-configured interval like 1 day.\r\n    ts            timeuuid,  // start timestamp of the span, truncated to millisecond precision\r\n    trace_id      varint,    // trace ID\r\n    duration      bigint,    // span duration, in microseconds\r\n    PRIMARY KEY ((service_name, span_name, bucket), ts)\r\n)\r\n   WITH CLUSTERING ORDER BY (ts DESC)\r\n    AND compaction = {'class': 'org.apache.cassandra.db.compaction.TimeWindowCompactionStrategy'}\r\n    AND default_time_to_live =  259200;\r\n\r\n\r\nCREATE MATERIALIZED VIEW IF NOT EXISTS trace_by_service\r\n    AS SELECT service_name, span_name, bucket, ts, trace_id FROM trace_by_service_span\r\n            WHERE service_name is not null AND span_name is not null AND bucket is not null AND ts is not null\r\n            PRIMARY KEY (service_name, bucket, span_name, ts)\r\n        WITH CLUSTERING ORDER BY (bucket DESC, ts DESC)\r\n    AND compaction = {'class': 'org.apache.cassandra.db.compaction.LeveledCompactionStrategy', 'unchecked_tombstone_compaction': 'true', 'tombstone_threshold': '0.2'}\r\n        AND default_time_to_live =  259200;\r\n\r\nCREATE CUSTOM INDEX ON traces (all_annotations) USING 'org.apache.cassandra.index.sasi.SASIIndex'\r\n   WITH OPTIONS = {\r\n    'mode': 'CONTAINS',\r\n    'analyzed': 'true',\r\n    'analyzer_class':'org.apache.cassandra.index.sasi.analyzer.NonTokenizingAnalyzer',\r\n    'case_sensitive': 'false'\r\n   };\r\n\r\nCREATE CUSTOM INDEX ON trace_by_service_span (duration) USING 'org.apache.cassandra.index.sasi.SASIIndex'\r\n   WITH OPTIONS = {'mode': 'PREFIX'};\r\n```"},"comment":{"url":"https://api.github.com/repos/openzipkin/zipkin/issues/comments/245215956","html_url":"https://github.com/openzipkin/zipkin/pull/1252#issuecomment-245215956","issue_url":"https://api.github.com/repos/openzipkin/zipkin/issues/1252","id":245215956,"user":{"login":"adriancole","id":64215,"avatar_url":"https://avatars.githubusercontent.com/u/64215?v=3","gravatar_id":"","url":"https://api.github.com/users/adriancole","html_url":"https://github.com/adriancole","followers_url":"https://api.github.com/users/adriancole/followers","following_url":"https://api.github.com/users/adriancole/following{/other_user}","gists_url":"https://api.github.com/users/adriancole/gists{/gist_id}","starred_url":"https://api.github.com/users/adriancole/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adriancole/subscriptions","organizations_url":"https://api.github.com/users/adriancole/orgs","repos_url":"https://api.github.com/users/adriancole/repos","events_url":"https://api.github.com/users/adriancole/events{/privacy}","received_events_url":"https://api.github.com/users/adriancole/received_events","type":"User","site_admin":false},"created_at":"2016-09-07T08:47:19Z","updated_at":"2016-09-07T08:47:19Z","body":"@michaelsembwever thanks for the efforts here and good luck!"}}
{"actor":{"display_login":"adriancole"}}