1. 程式人生 > >spring-cloud-sleuth+zipkin追蹤服務實現(三)

spring-cloud-sleuth+zipkin追蹤服務實現(三)

1.前言

在上一篇spring-cloud-sleuth+zipkin追蹤服務實現(二)中我們講述了利用mq的方式傳送資料,儲存在mysql,實際生產過程中呼叫資料量非常的大,mysql儲存並不是很好的選擇,這時我們可以採用elasticsearch進行儲存。
我們還是使用之前上一節中的三個程式做修改,方便大家看到對比不同點。這裡每個專案名都加了一個es,用來表示區別。

2.使用前提

這裡選用elasticsearch 2.x版本。
安裝elasticsearch的方法詳見本人的文章elk搭建實戰中elasticsearch部分。

3、microservice-zipkin-stream-server-es

要使用elasticsearch的話,必須在pom.xml中宣告相關的依賴。同時不使用mysql,那麼去掉mysql相關的依賴。

全部maven依賴如下:

```
   <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <!--zipkin依賴-->
    <!--此依賴會自動引入spring-cloud-sleuth-stream並且引入zipkin的依賴包-->
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-sleuth-zipkin-stream</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-stream-rabbit</artifactId>
    </dependency>

    <dependency>
        <groupId>io.zipkin.java</groupId>
        <artifactId>zipkin-autoconfigure-ui</artifactId>
        <scope>runtime</scope>
    </dependency>


    <dependency>
        <groupId>io.zipkin.java</groupId>
        <artifactId>zipkin</artifactId>
        <version>1.24.0</version>
    </dependency>

    <!--儲存到資料庫需要如下依賴-->
    <!-- 新增 spring-data-elasticsearch的依賴 -->
    <dependency>
        <groupId>io.zipkin.java</groupId>
        <artifactId>zipkin-autoconfigure-storage-elasticsearch-http</artifactId>
        <version>1.24.0</version>
        <optional>true</optional>
    </dependency>     
```

由於使用了訊息中介軟體rabbit mq以及elasticsearch,所以我們還需要在配置檔案application.properties加入相關的配置:

 server.port=11030
spring.application.name=microservice-zipkin-stream-server-es
#zipkin資料儲存到資料庫中需要進行如下配置
#表示當前程式不使用sleuth
spring.sleuth.enabled=false
#表示zipkin資料儲存方式是elasticsearch
zipkin.storage.StorageComponent = elasticsearch
zipkin.storage.type=elasticsearch


zipkin.storage.elasticsearch.cluster=elasticsearch-zipkin-cluster
zipkin.storage.elasticsearch.hosts=127.0.0.1:9300
# zipkin.storage.elasticsearch.pipeline=
zipkin.storage.elasticsearch.max-requests=64
zipkin.storage.elasticsearch.index=zipkin
zipkin.storage.elasticsearch.index-shards=5
zipkin.storage.elasticsearch.index-replicas=1



#rabbitmq配置
spring.rabbitmq.host=localhost
spring.rabbitmq.port=5672
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest

為了避免http通訊的干擾,我們將原來的監聽埠有11020更改為11030,啟動程式,未報錯且能夠看到rabbit連線日誌,說明程式啟動成功。

4.microservice-zipkin-stream-client-es、microservice-zipkin-client-stream-backend-es

與上一節中的程式碼保持一致,當然為了以示區別,埠也做了相應的調整

5.測試

6.專案原始碼:

6.參考文件:

相關推薦

spring-cloud-sleuth+zipkin追蹤服務實現()

1.前言 在上一篇spring-cloud-sleuth+zipkin追蹤服務實現(二)中我們講述了利用mq的方式傳送資料,儲存在mysql,實際生產過程中呼叫資料量非常的大,mysql儲存並不是很好的選擇,這時我們可以採用elasticsearch進行儲存。 我們還是使用之前上一節中的三個程式做修改,方便大

spring-cloud-sleuth+zipkin追蹤服務實現(二)

1. 簡述 在上一節《spring-cloud-sleuth+zipkin追蹤服務實現(一)》中,我們使用microservice-zipkin-server、microservice-zipkin-client、microservice-zipkin-client-backend 三個程式實現了使用http

spring-cloud-sleuth+zipkin追蹤服務實現(四)

1.前言 在上一篇spring-cloud-sleuth+zipkin追蹤服務實現(三)的處理實現後,很多朋友告訴我,在zipkin server的管理頁面無法看到專案依賴關係。 當時也沒有多想,以為是spring cloud zipkin的一個bug,後來發現是自己看文件的疏忽。 文中寫到對於Cassan

spring-cloud-sleuth+zipkin追蹤服務實現(一)

1.簡述 最近在學習spring cloud構建微服務,研究追蹤微服務rest服務呼叫鏈路的問題,接觸到zipkin,而spring cloud也提供了spring-cloud-sleuth來方便整合zipkin實現。 我們準備了三個必要的程式來做測試,分別是 1、microservice-zipkin-se

spring-cloud-sleuth+zipkin追蹤服務

本文簡單介紹瞭如何利用Zipkin對SpringCloud應用進行服務分析在實際的應用場景中,Zipkin可以結合壓力測試工具一起使用,分析系統在大壓力下的可用性和效能。設想這麼一種情況,如果你的微服務數量逐漸增大,服務間的依賴關係越來越複雜,怎麼分析它們之間的呼叫關係及相互

Spring Cloud Sleuth + zipkin 實現服務追蹤

工作 process image -o 唯一id dep 單元 圖片 zipkin 服務追蹤 Spring Cloud Sleuth實現了一種分布式的服務鏈路跟蹤解決方案,通過使用Sleuth可以讓我們快速定位某個服務的問題。 官方文檔地址如下: http://cloud

全鏈路追蹤spring-cloud-sleuth-zipkin

authorize 采樣 quest child 手機號 main rgs lin oot 微服務架構下 多個服務之間相互調用,在解決問題的時候,請求鏈路的追蹤是十分有必要的,鑒於項目中采用的spring cloud架構,所以為了方便使用,便於接入等 項目中采用了sprin

Spring Cloud 應用篇 之 Spring Cloud Sleuth + Zipkin)修改資料儲存方式

(一)簡介預設情況下,Zipkin Server 會將跟蹤資訊儲存在記憶體中,每次重啟 Zipkin Server 都會使之前收集的跟蹤資訊丟失,並且當有大量跟蹤資訊時,記憶體儲存也會造成效能瓶頸,所以通常我們都需要將跟蹤資訊儲存到外部元件中,如 Mysql。由於 Sprin

全鏈路spring cloud sleuth+zipkin

arc owa version public kafka 分享 cli self 兩個 http://blog.csdn.net/qq_15138455/article/details/72956232 版權聲明:@入江之鯨 一、About ZipKi

spring-cloud-sleuth+zipkin原始碼探究

1.1. 前言   粗略看了下spring cloud sleuth core原始碼,發現內容真的有點多,它支援了很多型別的鏈

Spring Cloud Alibaba學習筆記(23) - 呼叫鏈監控工具Spring Cloud Sleuth + Zipkin

隨著業務發展,系統拆分導致系統呼叫鏈路愈發複雜一個前端請求可能最終需要呼叫很多次後端服務才能完成,當整個請求陷入效能瓶頸或不可用時,我們是無法得知該請求是由某個或某些後端服務引起的,這時就需要解決如何快讀定位服務故障點,以對症下藥。於是就有了分散式系統呼叫跟蹤的誕生。 Spring Cloud Sleuth

springcloud服務追蹤Zipkinspring cloud Sleuth

參考文章一: 摘要: 本文簡單介紹瞭如何利用Zipkin對SpringCloud應用進行服務分析。在實際的應用場景中,Zipkin可以結合壓力測試工具一起使用,分析系統在大壓力下的可用性和效能。 設想這麼一種情況,如果你的微服務數量逐漸增大,服務間的依賴關係越來越複雜,怎麼分析它們

服務學習筆記--使用Spring Cloud Sleuth配合Zipkin實現服務的跟蹤

在微服務架構中可以使用Zipkin來追蹤服務呼叫鏈路,可以知道各個服務的呼叫依賴關係。在Spring Cloud中,也提供了Spring Cloud Sleuth來方便整合Zipkin實現。 本文使用一個Zipkin Server,使用者微服務,電影微服務來實現

spring cloud 入門系列八:使用spring cloud sleuth整合zipkin進行服務鏈路追蹤

好久沒有寫部落格了,主要是最近有些忙,今天忙裡偷閒來一篇。 =======我是華麗的分割線========== 微服務架構是一種分散式架構,微服務系統按照業務劃分服務單元,一個微服務往往會有很多個服務單元,一個請求往往會有很多個單元參與,一旦請求出現異常,想要去定位問題點真心不容易,因此需要有個東西去跟蹤

Spring Cloud應用進行服務追蹤分析(Zipkinspring cloud Sleuth)

參考文章二:(我參考的這個) 最近在學習spring cloud構建微服務,很多大牛都提供很多入門的例子幫助我們學習,對於我們這種英語不好的碼農來說,效率著實提高不少。這兩天學習到追蹤微服務rest服務呼叫鏈路的問題,接觸到zipkin,而spring cloud也提供了spring-cloud-sleu

業余草 SpringCloud教程 | 第九篇: 服務鏈路追蹤(Spring Cloud Sleuth)(Finchley版本)

描述 -s util ont packaging tdd res [] 新建 這篇文章主要講述服務追蹤組件zipkin,Spring Cloud Sleuth集成了zipkin組件。 一、簡介 Add sleuth to the classpath of a Spr

SpringCloud2.0版本入門 | 服務鏈路追蹤(Spring Cloud Sleuth)簡單入門

本文出自 [ 慌途L ] 最近開始寫部落格,一些問題可能瞭解也不夠透徹,寫一下快速入門並且踩過的坑,希望大家少踩坑。本文簡單介紹一下springcloud的服務鏈路追蹤,不足之處希望大家指出,我改正。不喜勿噴! 這篇文章主要講述服務追蹤元件zipkin,Spr

Spring Cloud Sleuth服務鏈路追蹤(mysql儲存鏈路資料)(Finchley版本)

在Spring Cloud Sleuth服務鏈路追蹤(Finchley版本)中,我們使用Spring Cloud Sleuth和zipkin的整合實現了服務鏈路的追蹤,但是遺憾的是鏈路資料儲存在記憶體中,無法持久化。zipkin的持久化可以結合Elasticsearch,MySQL實現。本節

SpringCloud微服務雲架構構建B2B2C電子商務平臺之-(九)服務鏈路追蹤(Spring Cloud Sleuth)

這篇文章主要講述服務追蹤元件zipkin,Spring Cloud Sleuth集成了zipkin元件。 一、簡介Add sleuth to the classpath of a Spring Boot application (see below for Maven and Gradle examples

史上最簡單的SpringCloud教程 | 第九篇: 服務鏈路追蹤(Spring Cloud Sleuth)(Finchley版本)

這篇文章主要講述服務追蹤元件zipkin,Spring Cloud Sleuth集成了zipkin元件。 一、簡介 Add sleuth to the classpath of a Spring Boot application (see below for Maven