Upgrade to Pro — share decks privately, control downloads, hide ads and more …

[SpringOne2016] Distributed Tracing using Sleu...

Shin Tanimoto
September 03, 2016

[SpringOne2016] Distributed Tracing using Sleuth and Zipkin

SpringOne Platform 2016報告会

Shin Tanimoto

September 03, 2016
Tweet

More Decks by Shin Tanimoto

Other Decks in Programming

Transcript

  1. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 8IPBN* • ୩ຊ ৺ (Shin Tanimoto) • Acroquest Technologyגࣜձࣾ • ೔ຊJavaϢʔβάϧʔϓ (JJUG) • JavaOneεϐʔΧʔ • Microservices, Elasticsearch • twitter: @cero_t • facebook: shin.tanimoto 2
  2. @cero_t #jsug sli.do #4923 Copyright © Acroquest Technology Co., Ltd.

    All rights reserved. ࣭໰ͳͲ ࣭໰͸ɺTwitter / slido Ͱ΋ड͚෇͚·͢ • Twitter : @cero_t or #jsug • http://sli.do/ : event code #4923 3
  3. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 5 ΨνʹϚΠΫϩαʔϏεͰ
 ։ൃɺӡ༻Λ͍ͯ͠Δਓʁ
  4. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 6 ϚΠΫϩαʔϏεͰͳ͘ͱ΋
 )551ɺ+.4ɺ".21ɺ,BGLB
 ͳͲͰෳ਺ͷαʔϏεΛ
 ௨৴ͤͯ͞γεςϜΛ૊ΜͰΔਓʁ
  5. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 7 গͳ͘ͱ΋͍͔ͭ͸ ͦ͏͍͏γεςϜΛ૊Ήඞཁ͕ ͋ΔͩΖ͏ͳͱࢥ͏ਓʁ
  6. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 8 ͍·खΛڍ͛ͳ͔ͬͨਓ͸
 Կ͠ʹདྷͨʂ
  7. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 10 ෼ࢄγεςϜΛ૊Ήͱ͖ʹ
 ඞͣ௚໘͢Δ໰୊ͷ࿩
  8. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 11 Ͳ͜Ͱ໰୊͕ى͖ͨͷ͔ʁ
 Ͳ͕͜ϘτϧωοΫͳͷ͔ʁ
  9. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 12 Service architecture isn’t this simple anymore Single-server scenarios aren’t realistic or don’t fully explain latency. David Vignoni Gnome-fs-server.svg
  10. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 13 Can we make troubleshooting wizard-free? We no longer need wizards to deploy complex architectures. We shouldn’t need wizards to troubleshoot them, either!
  11. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 14 © 2016 Pivotal !1 An introduction to Distributed Tracing and Zipkin Adrian Cole, Pivotal @adrianfcole How to Properly Blame Things for Causing Latency
  12. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 15 Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Implementing Microservices Tracing with Spring Cloud and Zipkin By Reshmi Krishna @reshmi9k By Marcin Grzejszczak @mgrzejszczak
  13. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 5BCMFPGDPOUFOUT 1. ໰୊ൃੜՕॴΛϩά͔Βௐ΂Δ 2. αʔϏεͷߏ଄ΛՄࢹԽ͢Δ 3. SleuthͱZipkinͷ࢝Ίํ 16
  14. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 ໰୊ൃੜՕॴΛϩά͔Βௐ΂Δ #1 17
  15. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 18 Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ It doesn’t look like this
  16. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 19 Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ More like this
  17. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 20 Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ More like this
  18. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 21 ϩά͸શ෦&MBTUJDTFBSDIʹ
 Ϳͬ͜ΜͰ͍ͨͱͯ͠
 Ͳ͏΍ͬͯ໰୊ՕॴΛ୳͢ʁ ໰୊ൃੜՕॴΛϩά͔Βௐ΂Δ
  19. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 22 ʮ͜ͷ͔࣌ؒΒ͜ͷ࣌ؒͷϩάʯ Λβʔοͱݕࡧ͢Δʁ ໰୊ൃੜՕॴΛϩά͔Βௐ΂Δ
  20. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 23 ͨ͘͞ΜΤϥʔ͕ى͖ͯͨΒ
 Ͳ͏͢Μͷʁ ໰୊ൃੜՕॴΛϩά͔Βௐ΂Δ
  21. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 24 ϦΫΤετʹରͯ͠*%Λൃߦ͠
 ͦΕΛڞ༗͢Ε͹ྑ͘Ͷʁ ໰୊ൃੜՕॴΛϩά͔Βௐ΂Δ
  22. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 25 4QSJOH$MPVE4MFVUI ໰୊ൃੜՕॴΛϩά͔Βௐ΂Δ
  23. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 26 Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Brixton.SR4</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-sleuth</artifactId> </dependency> Spring Cloud Sleuth with Maven
  24. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 27 ϦΫΤετશମ5SBDF ݸผϦΫΤετ4QBO ໰୊ൃੜՕॴΛϩά͔Βௐ΂Δ
  25. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 28 )551".21ϔομʹ*%ΛຒΊΔ
 ड͚औͬͯ5ISFBE-PDBMʹೖΕΔ
 ࣍ʹ౉͢ɾɾɾͷ܁Γฦ͠ ໰୊ൃੜՕॴΛϩά͔Βௐ΂Δ
  26. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 29 Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
  27. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 30 Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
  28. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 31 ϦΫΤετͷ*%ΛΩʔʹͯ͠
 ෳ਺αʔόͷϩάΛݕࡧͰ͖Δ ໰୊ൃੜՕॴΛϩά͔Βௐ΂Δ
  29. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 33 ͦΕΛ࢖ͬͯ
 ՄࢹԽͰ͖ΔͷͰ͸ʁ
  30. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 αʔϏεͷߏ଄ΛՄࢹԽ͢Δ #2 34
  31. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 35 4MFVUIͰूΊͨ৘ใΛ࢖ͬͯ
 ஗͍ͱ͜ΖΛ୳ͨ͠Γ
 αʔϏεͷؔ࿈Λݟ͍ͨ αʔϏεͷߏ଄ΛՄࢹԽ͢Δ
  32. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 36 Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ The answer is: ZIPKIN
  33. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 37 Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ SPANS SENT TO COLLECTORS SPANS SENT TO COLLECTORS STORE IN DB APP APP UI QUERIES FOR TRACE INFO VIA API How does Zipkin work?
  34. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 38 Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Cloud Sleuth Zipkin with Maven <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Brixton.SR4</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-zipkin</artifactId> </dependency>
  35. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 39 %FNP αʔϏεͷߏ଄ΛՄࢹԽ͢Δ
  36. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 SleuthͱZipkinͷ࢝Ίํ #3 40
  37. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 42 4MFVUIͱ;JQLJOͷ࢝Ίํ • JavaOneʹ͸Α͘ࢀՃ͢ΔΜ͚ͩͲ
 ΞδΣϯμΛݟͯΔͱ໌Β͔ʹ
 SpringOneͷ΄͏ָ͕ͦ͠͏ɻ
 • ͦ͏ͩCfPΛग़ͦ͏ɻ • ͋ɺड͔ͬͨɻ΍͹͍ɻ
  38. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 4MFVUIͱ;JQLJOͷ࢝Ίํ • How to do? (1) Spring InitializrͰ “sleuth” and “zipkin” Λ୳͢
 https://start.spring.io/
 (2) ϚΠΫϩαʔϏεʹsleuthͷdependenciesΛ௥Ճ
 (3) zipkinͷdependenciesΛ࢖ͬͯZipkinαʔόΛ࡞Δ 43
  39. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 4MFVUIͱ;JQLJOͷ࢝Ίํ 44
  40. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 4MFVUIͱ;JQLJOͷ࢝Ίํ 45
  41. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 4MFVUIͱ;JQLJOͷ࢝Ίํ Sleuth and Zipkin dependencies 46 Name on Initializr artifactId Sleuth spring-cloud-starter-sleuth Sleuth Stream spring-cloud-sleuth-stream Zipkin Client spring-cloud-starter-zipkin Zipkin Stream spring-cloud-sleuth-zipkin-stream Zipkin UI spring-boot-starter
 zipkin-autoconfigure-ui Zipkin Server spring-boot-starter
 zipkin-server
  42. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 4MFVUIͱ;JQLJOͷ࢝Ίํ 47 Microservice Microservice Zipkin Server HTTP Zipkin UI Server To start simply:
  43. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 4MFVUIͱ;JQLJOͷ࢝Ίํ To start simply: 48 Microservice Microservice Zipkin Server HTTP Zipkin UI Server Zipkin Client 
 (spring-cloud-starter-zipkin) Zipkin UI (zipkin-autoconfigure-ui)
 Zipkin Server (zipkin-server)
  44. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 4MFVUIͱ;JQLJOͷ࢝Ίํ 49 Microservice AMQP Zipkin UI Server
 Zipkin Server RabbitMQ AMQP To use RabbitMQ as a middle buffer:
  45. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 4MFVUIͱ;JQLJOͷ࢝Ίํ 50 Microservice AMQP Zipkin UI Server
 Zipkin Server RabbitMQ AMQP Zipkin UI
 (zipkin-autoconfigure-ui)
 Zipkin Stream
 (spring-cloud-sleuth-zipkin-stream)
 Stream Rabbit
 (spring-cloud-starter-stream-rabbit) Sleuth Stream
 (spring-cloud-sleuth-stream)
 Stream Rabbit
 (spring-cloud-starter-stream-rabbit) To use RabbitMQ as a middle buffer:
  46. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 4MFVUIͱ;JQLJOͷ࢝Ίํ 51 Microservice AMQP Zipkin UI Server
 Zipkin Server RabbitMQ AMQP Zipkin UI
 (zipkin-autoconfigure-ui)
 Zipkin Stream
 (spring-cloud-sleuth-zipkin-stream)
 
 spring-cloud-stream-binder-rabbit Sleuth Stream
 (spring-cloud-sleuth-stream)
 
 spring-cloud-stream-binder-rabbit To use RabbitMQ as a middle buffer:
  47. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 4MFVUIͱ;JQLJOͷ࢝Ίํ 52 Microservice AMQP Zipkin UI Server
 Zipkin Server RabbitMQ AMQP The exchange and the queue are created and bound automatically. Exchange:
 sleuth Queue:
 sleuth.sleuth
  48. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 4MFVUIͱ;JQLJOͷ࢝Ίํ Sleuth and Zipkin dependencies 53 Name on Initializr artifactId Log HTTP AMQP Sleuth spring-cloud-starter-sleuth Service Sleuth Stream spring-cloud-sleuth-stream Service Zipkin Client spring-cloud-starter-zipkin Service Zipkin Stream spring-cloud-sleuth-zipkin-stream Zipkin Zipkin UI spring-boot-starter
 zipkin-autoconfigure-ui Zipkin Zipkin Zipkin Server spring-boot-starter
 zipkin-server Zipkin Stream Rabbit spring-cloud-starter-stream-rabbit Both
  49. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 4MFVUIͱ;JQLJOͷ࢝Ίํ 54 Zipkin server application (HTTP): @SpringBootApplication @EnableZipkinServer public class ZipkinApplication { public static void main(String[] args) { SpringApplication.run(ZipkinApplication.class, args); } }
  50. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 4MFVUIͱ;JQLJOͷ࢝Ίํ 55 Zipkin server application (Stream): @SpringBootApplication @EnableZipkinStreamServer public class ZipkinApplication { public static void main(String[] args) { SpringApplication.run(ZipkinApplication.class, args); } }
  51. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 4MFVUIͱ;JQLJOͷ࢝Ίํ 56 No source code modification in microservices!
  52. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 4MFVUIͱ;JQLJOͷ࢝Ίํ • Note (1) Spring Cloud Sleuth͸
 RabbitTemplateΛαϙʔτ͍ͯ͠ͳ͍
 (spring-boot-starter-amqp).
 (2) Stream Rabbit͸αϙʔτ͞Ε͍ͯΔ
 (spring-cloud-starter-stream-rabbit). 57
  53. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 58 ͳΜ͍ͯ͏εϥΠυΛ४උͯͨ͠લ೔ #ZUIFXBZ
  54. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 59 5IF/FUqJY5FDI#MPH7J[DFSBM0QFO4PVSDF IUUQUFDICMPHOFUqJYDPNWJ[DFSBM PQFOTPVSDFIUNM #ZUIFXBZ
  55. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 60 Infrastructures Evolution -FUTIBWFGVOWJTVBMJ[BUJPOZPVSNJDSPTFSWJDFT
  56. Copyright © Acroquest Technology Co., Ltd. All rights reserved. @cero_t

    #jsug sli.do #4923 8SBQVQ • Sample code: https://github.com/cero-t/e-commerce-example • Clip arts: http://www.irasutoya.com/ 61