zipkin.sql 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. --
  2. -- Copyright 2015-2019 The OpenZipkin Authors
  3. --
  4. -- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
  5. -- in compliance with the License. You may obtain a copy of the License at
  6. --
  7. -- http://www.apache.org/licenses/LICENSE-2.0
  8. --
  9. -- Unless required by applicable law or agreed to in writing, software distributed under the License
  10. -- is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
  11. -- or implied. See the License for the specific language governing permissions and limitations under
  12. -- the License.
  13. --
  14. CREATE TABLE IF NOT EXISTS zipkin_spans (
  15. `trace_id_high` BIGINT NOT NULL DEFAULT 0 COMMENT 'If non zero, this means the trace uses 128 bit traceIds instead of 64 bit',
  16. `trace_id` BIGINT NOT NULL,
  17. `id` BIGINT NOT NULL,
  18. `name` VARCHAR(255) NOT NULL,
  19. `remote_service_name` VARCHAR(255),
  20. `parent_id` BIGINT,
  21. `debug` BIT(1),
  22. `start_ts` BIGINT COMMENT 'Span.timestamp(): epoch micros used for endTs query and to implement TTL',
  23. `duration` BIGINT COMMENT 'Span.duration(): micros used for minDuration and maxDuration query',
  24. PRIMARY KEY (`trace_id_high`, `trace_id`, `id`)
  25. ) ENGINE=InnoDB ROW_FORMAT=COMPRESSED CHARACTER SET=utf8 COLLATE utf8_general_ci;
  26. ALTER TABLE zipkin_spans ADD INDEX(`trace_id_high`, `trace_id`) COMMENT 'for getTracesByIds';
  27. ALTER TABLE zipkin_spans ADD INDEX(`name`) COMMENT 'for getTraces and getSpanNames';
  28. ALTER TABLE zipkin_spans ADD INDEX(`remote_service_name`) COMMENT 'for getTraces and getRemoteServiceNames';
  29. ALTER TABLE zipkin_spans ADD INDEX(`start_ts`) COMMENT 'for getTraces ordering and range';
  30. CREATE TABLE IF NOT EXISTS zipkin_annotations (
  31. `trace_id_high` BIGINT NOT NULL DEFAULT 0 COMMENT 'If non zero, this means the trace uses 128 bit traceIds instead of 64 bit',
  32. `trace_id` BIGINT NOT NULL COMMENT 'coincides with zipkin_spans.trace_id',
  33. `span_id` BIGINT NOT NULL COMMENT 'coincides with zipkin_spans.id',
  34. `a_key` VARCHAR(255) NOT NULL COMMENT 'BinaryAnnotation.key or Annotation.value if type == -1',
  35. `a_value` BLOB COMMENT 'BinaryAnnotation.value(), which must be smaller than 64KB',
  36. `a_type` INT NOT NULL COMMENT 'BinaryAnnotation.type() or -1 if Annotation',
  37. `a_timestamp` BIGINT COMMENT 'Used to implement TTL; Annotation.timestamp or zipkin_spans.timestamp',
  38. `endpoint_ipv4` INT COMMENT 'Null when Binary/Annotation.endpoint is null',
  39. `endpoint_ipv6` BINARY(16) COMMENT 'Null when Binary/Annotation.endpoint is null, or no IPv6 address',
  40. `endpoint_port` SMALLINT COMMENT 'Null when Binary/Annotation.endpoint is null',
  41. `endpoint_service_name` VARCHAR(255) COMMENT 'Null when Binary/Annotation.endpoint is null'
  42. ) ENGINE=InnoDB ROW_FORMAT=COMPRESSED CHARACTER SET=utf8 COLLATE utf8_general_ci;
  43. ALTER TABLE zipkin_annotations ADD UNIQUE KEY(`trace_id_high`, `trace_id`, `span_id`, `a_key`, `a_timestamp`) COMMENT 'Ignore insert on duplicate';
  44. ALTER TABLE zipkin_annotations ADD INDEX(`trace_id_high`, `trace_id`, `span_id`) COMMENT 'for joining with zipkin_spans';
  45. ALTER TABLE zipkin_annotations ADD INDEX(`trace_id_high`, `trace_id`) COMMENT 'for getTraces/ByIds';
  46. ALTER TABLE zipkin_annotations ADD INDEX(`endpoint_service_name`) COMMENT 'for getTraces and getServiceNames';
  47. ALTER TABLE zipkin_annotations ADD INDEX(`a_type`) COMMENT 'for getTraces and autocomplete values';
  48. ALTER TABLE zipkin_annotations ADD INDEX(`a_key`) COMMENT 'for getTraces and autocomplete values';
  49. ALTER TABLE zipkin_annotations ADD INDEX(`trace_id`, `span_id`, `a_key`) COMMENT 'for dependencies job';
  50. CREATE TABLE IF NOT EXISTS zipkin_dependencies (
  51. `day` DATE NOT NULL,
  52. `parent` VARCHAR(255) NOT NULL,
  53. `child` VARCHAR(255) NOT NULL,
  54. `call_count` BIGINT,
  55. `error_count` BIGINT,
  56. PRIMARY KEY (`day`, `parent`, `child`)
  57. ) ENGINE=InnoDB ROW_FORMAT=COMPRESSED CHARACTER SET=utf8 COLLATE utf8_general_ci;