http://zipkin.io/
Zipkin
Zipkin is a distributed tracing system. It helps gather timing data needed to troubleshoot latency problems in microservice architectures. It manages both the collection and lookup of this data. Zipkin’s design is based on the paper.
Applications are instrumented to report timing data to Zipkin. The Zipkin UI also presents a Dependency diagram showing how many traced requests went through each application. If you are troubleshooting latency problems or errors, you can filter or sort all traces based on the application, length of trace, annotation, or timestamp. Once you select a trace, you can see the percentage of the total trace time each span takes which allows you to identify the problem application.
Where to go next?
- To try out Zipkin, check out our
- See if your platform has an
- Join the
- The source code is on GitHub as
- Issues are also tracked on
package api.gateway;import okhttp3.OkHttpClient;public class ZipkinTest { public static void main(String[] args) throws Exception { OkHttpClient client = new OkHttpClient(); // 1)处理gateway span { String data = "[{\"traceId\":\"daaed0921874ebc3\",\"id\":\"daaed0921874ebc3\",\"name\":\"get\",\"timestamp\":1476197067420000,\"duration\":4694000,\"annotations\":[{\"timestamp\":1476197067420000,\"value\": \"cs\",\"endpoint\": {\"serviceName\": \"gateway\",\"ipv4\":\"1.2.3.4\"}},{\"timestamp\":1476197072114000,\"value\":\"cr\",\"endpoint\":{\"serviceName\":\"gateway\",\"ipv4\": \"1.2.3.4\"}}],\"binaryAnnotations\": [{\"key\": \"http.url\",\"value\": \"http://localhost:8080/service1\",\"endpoint\": {\"serviceName\": \"gateway\",\"ipv4\": \"1.2.3.4\"}}]}]"; String resp = HttpUtils.post(client, "http://1.2.3.4:9411/api/v1/spans", data); System.out.println(resp); } // 2)处理service1 { String data = "[{\"traceId\": \"daaed0921874ebc3\", \"id\": \"411d4c32c102a974\",\"name\": \"get\",\"parentId\": \"daaed0921874ebc3\",\"timestamp\": 1476197069680000,\"duration\": 1168000,\"annotations\": [{\"timestamp\": 1476197069680000, \"value\": \"cs\",\"endpoint\": {\"serviceName\": \"service1\",\"ipv4\": \"1.2.3.111\"}},{\"timestamp\":1476197070848000,\"value\": \"cr\", \"endpoint\": { \"serviceName\": \"service1\", \"ipv4\": \"1.2.3.111\"}}], \"binaryAnnotations\": [{\"key\": \"http.url\",\"value\":\"http://localhost:8089/service2\",\"endpoint\": {\"serviceName\": \"service1\",\"ipv4\": \"1.2.3.111\" }}]},{\"traceId\": \"daaed0921874ebc3\",\"id\": \"7c0d7d897a858217\",\"name\": \"get\",\"parentId\": \"daaed0921874ebc3\",\"timestamp\": 1476197070850000,\"duration\": 1216000,\"annotations\": [{\"timestamp\": 1476197070850000, \"value\": \"cs\",\"endpoint\": {\"serviceName\": \"service1\",\"ipv4\": \"1.2.3.111\"}},{\"timestamp\": 1476197072066000,\"value\": \"cr\",\"endpoint\": {\"serviceName\": \"service1\",\"ipv4\": \"1.2.3.111\"}}],\"binaryAnnotations\": [{\"key\": \"http.url\", \"value\": \"http://localhost:8090/service3\",\"endpoint\": {\"serviceName\":\"service1\",\"ipv4\":\"1.2.3.111\"}}]},{\"traceId\":\"daaed0921874ebc3\",\"id\":\"daaed0921874ebc3\",\"name\":\"get___\",\"timestamp\":1476197067623000,\"duration\":4479000,\"annotations\":[{\"timestamp\":1476197067623000,\"value\":\"sr\",\"endpoint\":{\"serviceName\":\"service1\",\"ipv4\":\"1.2.3.111\"}},{\"timestamp\":1476197072102000,\"value\":\"ss\",\"endpoint\":{\"serviceName\":\"service1\",\"ipv4\":\"1.2.3.111\"}}],\"binaryAnnotations\":[{\"key\":\"http.status_code\",\"value\":\"2000\",\"endpoint\":{\"serviceName\":\"service1\",\"ipv4\":\"1.2.3.111\"}},{\"key\": \"http.url\",\"value\": \"/service1\",\"endpoint\": {\"serviceName\": \"service1\",\"ipv4\": \"1.2.3.111\"}}]}]"; String resp = HttpUtils.post(client, "http://1.2.3.4:9411/api/v1/spans", data); System.out.println(resp); } // 3)处理service2 { String data = "[{\"traceId\": \"daaed0921874ebc3\", \"id\": \"411d4c32c102a974\", \"name\":\"get\",\"parentId\":\"daaed0921874ebc3\",\"timestamp\":1476197069806000,\"duration\":1040000, \"annotations\": [{ \"timestamp\": 1476197069806000,\"value\": \"sr\",\"endpoint\": {\"serviceName\": \"service2\",\"ipv4\": \"1.2.3.112\"}},{\"timestamp\":1476197070846000, \"value\": \"ss\",\"endpoint\": {\"serviceName\": \"service2\", \"ipv4\": \"1.2.3.112\"}}],\"binaryAnnotations\": [ {\"key\": \"error\",\"value\": \"hello,world!my baby\",\"endpoint\": {\"serviceName\": \"service2\",\"ipv4\": \"1.2.3.112\"}},{\"key\": \"http.status_code\",\"value\": \"2000\",\"endpoint\": {\"serviceName\": \"service2\",\"ipv4\": \"1.2.3.112\"}},{ \"key\": \"http.url\",\"value\": \"/service2\",\"endpoint\": {\"serviceName\": \"service2\",\"ipv4\": \"1.2.3.112\"}}]}]"; String resp = HttpUtils.post(client, "http://1.2.3.4:9411/api/v1/spans", data); System.out.println(resp); } // 4)处理service3 { String data = "[{\"traceId\": \"daaed0921874ebc3\",\"id\": \"7c0d7d897a858217\",\"name\": \"get\",\"parentId\": \"daaed0921874ebc3\",\"timestamp\": 1476197071011000,\"duration\": 1059000,\"annotations\": [{\"timestamp\": 1476197071011000,\"value\": \"sr\",\"endpoint\": {\"serviceName\": \"service3\",\"ipv4\": \"1.2.3.113\"}},{\"timestamp\": 1476197072070000,\"value\": \"ss\",\"endpoint\": {\"serviceName\": \"service3\",\"ipv4\": \"1.2.3.113\"}}],\"binaryAnnotations\": [{\"key\": \"http.status_code\",\"value\": \"200\",\"endpoint\": {\"serviceName\": \"service3\",\"ipv4\": \"1.2.3.113\"}},{\"key\": \"http.url\", \"value\": \"/service3\", \"endpoint\": { \"serviceName\": \"service3\",\"ipv4\": \"1.2.3.113\"} }]}]"; String resp = HttpUtils.post(client, "http://1.2.3.4:9411/api/v1/spans", data); System.out.println(resp); } }}