---- Copyright 2015-2019 The OpenZipkin Authors---- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except-- in compliance with the License. You may obtain a copy of the License at---- http://www.apache.org/licenses/LICENSE-2.0---- Unless required by applicable law or agreed to in writing, software distributed under the License-- is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express-- or implied. See the License for the specific language governing permissions and limitations under-- the License.--CREATETABLEIFNOTEXISTS zipkin_spans ( `trace_id_high` BIGINT NOT NULL DEFAULT 0 COMMENT 'If non zero, this means the trace uses 128 bit traceIds instead of 64 bit',
`trace_id`BIGINTNOT NULL,`id`BIGINTNOT NULL,`name`VARCHAR(255) NOT NULL,`remote_service_name`VARCHAR(255),`parent_id`BIGINT,`debug`BIT(1),`start_ts`BIGINT COMMENT 'Span.timestamp(): epoch micros used for endTs query and to implement TTL',`duration`BIGINT COMMENT 'Span.duration(): micros used for minDuration and maxDuration query',PRIMARY KEY (`trace_id_high`, `trace_id`, `id`)) ENGINE=InnoDB ROW_FORMAT=COMPRESSED CHARACTERSET=utf8 COLLATE utf8_general_ci;ALTERTABLE zipkin_spans ADDINDEX(`trace_id_high`, `trace_id`) COMMENT 'for getTracesByIds';ALTERTABLE zipkin_spans ADDINDEX(`name`) COMMENT 'for getTraces and getSpanNames';ALTERTABLE zipkin_spans ADDINDEX(`remote_service_name`) COMMENT 'for getTraces and getRemoteServiceNames';ALTERTABLE zipkin_spans ADDINDEX(`start_ts`) COMMENT 'for getTraces ordering and range';CREATETABLEIFNOTEXISTS zipkin_annotations ( `trace_id_high` BIGINT NOT NULL DEFAULT 0 COMMENT 'If non zero, this means the trace uses 128 bit traceIds instead of 64 bit',
`trace_id`BIGINTNOT NULL COMMENT 'coincides with zipkin_spans.trace_id',`span_id`BIGINTNOT NULL COMMENT 'coincides with zipkin_spans.id',`a_key`VARCHAR(255) NOT NULL COMMENT 'BinaryAnnotation.key or Annotation.value if type == -1',`a_value` BLOB COMMENT 'BinaryAnnotation.value(), which must be smaller than 64KB',`a_type`INTNOT NULL COMMENT 'BinaryAnnotation.type() or -1 if Annotation',`a_timestamp`BIGINT COMMENT 'Used to implement TTL; Annotation.timestamp or zipkin_spans.timestamp',`endpoint_ipv4`INT COMMENT 'Null when Binary/Annotation.endpoint is null',`endpoint_ipv6`BINARY(16) COMMENT 'Null when Binary/Annotation.endpoint is null, or no IPv6 address',`endpoint_port`SMALLINT COMMENT 'Null when Binary/Annotation.endpoint is null',`endpoint_service_name`VARCHAR(255) COMMENT 'Null when Binary/Annotation.endpoint is null') ENGINE=InnoDB ROW_FORMAT=COMPRESSED CHARACTERSET=utf8 COLLATE utf8_general_ci;ALTER TABLE zipkin_annotations ADD UNIQUE KEY(`trace_id_high`, `trace_id`, `span_id`, `a_key`, `a_timestamp`) COMMENT 'Ignore insert on duplicate';
ALTER TABLE zipkin_annotations ADD INDEX(`trace_id_high`, `trace_id`, `span_id`) COMMENT 'for joining with zipkin_spans';
ALTERTABLE zipkin_annotations ADDINDEX(`trace_id_high`, `trace_id`) COMMENT 'for getTraces/ByIds';ALTERTABLE zipkin_annotations ADDINDEX(`endpoint_service_name`) COMMENT 'for getTraces and getServiceNames';ALTERTABLE zipkin_annotations ADDINDEX(`a_type`) COMMENT 'for getTraces and autocomplete values';ALTERTABLE zipkin_annotations ADDINDEX(`a_key`) COMMENT 'for getTraces and autocomplete values';ALTERTABLE zipkin_annotations ADDINDEX(`trace_id`, `span_id`, `a_key`) COMMENT 'for dependencies job';CREATETABLEIFNOTEXISTS zipkin_dependencies (`day`DATENOT NULL,`parent`VARCHAR(255) NOT NULL,`child`VARCHAR(255) NOT NULL,`call_count`BIGINT,`error_count`BIGINT,PRIMARY KEY (`day`, `parent`, `child`)) ENGINE=InnoDB ROW_FORMAT=COMPRESSED CHARACTERSET=utf8 COLLATE utf8_general_ci;
@RestController@RequestMapping("/serviceTwo")publicclassServiceTwoController { @GetMapping("callServiceTwo")publicStringcallServiceOne(){log.info("service two is called!");return"service two is called!"; }}
我们在service1中用restTemplet来调用它:
@RestController@RequestMapping("/serviceOne")publicclassServiceOneController { @GetMapping("callServiceOne")publicStringcallServiceOne(){log.info("service one is called!");restTemplate().getForObject("http://localhost:9000/serviceTwo/callServiceTwo",String.class);return"service one and two are called!"; } @BeanRestTemplaterestTemplate() {returnnewRestTemplate(); }}
这样,我们用get 去请求http://loalhost/serviceOne/callServiceOne 就会将调用信息发送到MQ,并被zipkin Server 处理。 我们就可以在zipkin web页面看到调用信息啦 。