更新時(shí)間:2023-09-25 來(lái)源:黑馬程序員 瀏覽量:
自SpringCloud問(wèn)世以來(lái),微服務(wù)以席卷之勢(shì)風(fēng)靡全球,企業(yè)架構(gòu)都在從傳統(tǒng)SOA向微服務(wù)轉(zhuǎn)型。然而微服務(wù)這把雙刃劍在帶來(lái)各種優(yōu)勢(shì)的同時(shí),也給運(yùn)維、性能監(jiān)控、錯(cuò)誤的排查帶來(lái)的極大的困難。
在大型項(xiàng)目中,服務(wù)架構(gòu)會(huì)包含數(shù)十乃至上百個(gè)服務(wù)節(jié)點(diǎn)。往往一次請(qǐng)求會(huì)設(shè)計(jì)到多個(gè)微服務(wù),想要排查一次請(qǐng)求鏈路中經(jīng)過(guò)了哪些節(jié)點(diǎn),每個(gè)節(jié)點(diǎn)的執(zhí)行情況如何,就稱為了亟待解決的問(wèn)題。于是分布式系統(tǒng)的APM管理系統(tǒng)應(yīng)運(yùn)而生。
什么是APM系統(tǒng)?
APM系統(tǒng)可以幫助理解系統(tǒng)行為、用于分析性能問(wèn)題的工具,以便發(fā)生故障的時(shí)候,能夠快速定位和解決問(wèn)題,這就是APM系統(tǒng),全稱是(Application Performance Monitor)。
谷歌公開的論文提到的 [Google Dapper](http://bigbully.github.io/Dapper-translation)可以說(shuō)是最早的APM系統(tǒng)了,給google的開發(fā)者和運(yùn)維團(tuán)隊(duì)幫了大忙,所以谷歌公開論文分享了Dapper。
而后,很多的技術(shù)公司基于這篇論文的原理,設(shè)計(jì)開發(fā)了很多出色的APM框架,例如`Pinpoint`、`SkyWalking`等。
而SpringCloud官網(wǎng)也集成了一套這樣的系統(tǒng):`Spring Cloud Sleuth`,結(jié)合`Zipkin`。
APM的基本原理
目前大部分的APM系統(tǒng)都是基于Google的Dapper原理實(shí)現(xiàn),我們簡(jiǎn)單來(lái)看看Dapper中的概念和實(shí)現(xiàn)原理。
先來(lái)看一次請(qǐng)求調(diào)用示例:
1. 服務(wù)集群中包括:前端(A),兩個(gè)中間層(B和C),以及兩個(gè)后端(D和E)
2. 當(dāng)用戶發(fā)起一個(gè)請(qǐng)求時(shí),首先到達(dá)前端A服務(wù),然后A分別對(duì)B服務(wù)和C服務(wù)進(jìn)行RPC調(diào)用;
3. B服務(wù)處理完給A做出響應(yīng),但是C服務(wù)還需要和后端的D服務(wù)和E服務(wù)交互之后再返還給A服務(wù),最后由A服務(wù)來(lái)響應(yīng)用戶的請(qǐng)求;
如何才能實(shí)現(xiàn)跟蹤呢?
Google的Dapper設(shè)計(jì)了下面的幾個(gè)概念用來(lái)記錄請(qǐng)求鏈路:
- Span:請(qǐng)求中的基本工作單元,每一次鏈路調(diào)用(RPC、Rest、數(shù)據(jù)庫(kù)調(diào)用)都會(huì)創(chuàng)建一個(gè)Span。大概結(jié)構(gòu)如下:
type Span struct { TraceID int64 // 用于標(biāo)示一次完整的請(qǐng)求id Name string // 單元名稱 ID int64 // 當(dāng)前這次調(diào)用span_id ParentID int64 // 上層服務(wù)的span_id,最上層服務(wù)parent_id為null,代表根服務(wù) Annotation []Annotation // 注釋,用于記錄調(diào)用中的詳細(xì)信息,例如時(shí)間 }
- Trace:一次完整的調(diào)用鏈路,包含多個(gè)Span的樹狀結(jié)構(gòu),具有唯一的TraceID
一次請(qǐng)求的每個(gè)鏈路,通過(guò)spanId、parentId就能串聯(lián)起來(lái):
當(dāng)然,從請(qǐng)求到服務(wù)器開始,服務(wù)器返回response結(jié)束,每個(gè)span存在相同的唯一標(biāo)識(shí)trace_id。
APM的篩選標(biāo)準(zhǔn)
目前主流的APM框架都會(huì)包含下列幾個(gè)組件來(lái)完成鏈路信息的收集和展示:
- 探針(Agent):負(fù)責(zé)在客戶端程序運(yùn)行時(shí)搜索服務(wù)調(diào)用鏈路信息,發(fā)送給收集器
- 收集器(Collector):負(fù)責(zé)將數(shù)據(jù)格式化,保存到存儲(chǔ)器
- 存儲(chǔ)器(Storage):保存數(shù)據(jù)
- UI界面(WebUI):統(tǒng)計(jì)并展示收集到的信息
因此,要篩選一款合格的APM框架,就是對(duì)比各個(gè)組件的使用差異,主要對(duì)比項(xiàng):
- 探針的性能
主要是agent對(duì)服務(wù)的吞吐量、CPU和內(nèi)存的影響。如果探針在收集微服務(wù)運(yùn)行數(shù)據(jù)時(shí),對(duì)微服務(wù)的運(yùn)行產(chǎn)生了比較大的性能影響,相信沒什么人愿意使用。
- collector的可擴(kuò)展性
能夠水平擴(kuò)展以便支持大規(guī)模服務(wù)器集群,保證收集器的高可用特性。
- 全面的調(diào)用鏈路數(shù)據(jù)分析
數(shù)據(jù)的分析要快 ,分析的維度盡可能多。跟蹤系統(tǒng)能提供足夠快的信息反饋,就可以對(duì)生產(chǎn)環(huán)境下的異常狀況做出快速反應(yīng),最好提供代碼級(jí)別的可見性以便輕松定位失敗點(diǎn)和瓶頸。
- 對(duì)于開發(fā)透明,容易開關(guān)
即也作為業(yè)務(wù)組件,應(yīng)當(dāng)盡可能少入侵或者無(wú)入侵其他業(yè)務(wù)系統(tǒng),對(duì)于使用方透明,減少開發(fā)人員的負(fù)擔(dān)。
- 完整的調(diào)用鏈應(yīng)用拓?fù)?/p>
自動(dòng)檢測(cè)應(yīng)用拓?fù)?,幫助你搞清楚?yīng)用的架構(gòu)
接下來(lái),我們就對(duì)比下目前比較常見的三種APM框架的各項(xiàng)指標(biāo),分別是:
- [Zipkin](https://link.juejin.im/?target=http%3A%2F%2Fzipkin.io%2F):由Twitter公司開源,開放源代碼分布式的跟蹤系統(tǒng),用于收集服務(wù)的定時(shí)數(shù)據(jù),以解決微服務(wù)架構(gòu)中的延遲問(wèn)題,包括:數(shù)據(jù)的收集、存儲(chǔ)、查找和展現(xiàn)。
- [Pinpoint](https://pinpoint.com/):一款對(duì)Java編寫的大規(guī)模分布式系統(tǒng)的APM工具,由韓國(guó)人開源的分布式跟蹤組件。
- [Skywalking](https://skywalking.apache.org/zh/):國(guó)產(chǎn)的優(yōu)秀APM組件,是一個(gè)對(duì)JAVA分布式應(yīng)用程序集群的業(yè)務(wù)運(yùn)行情況進(jìn)行追蹤、告警和分析的系統(tǒng)?,F(xiàn)在是Apache的頂級(jí)項(xiàng)目之一。
三者對(duì)比如下:
| 對(duì)比項(xiàng) | zipkin | pinpoint | skywalking |
| ---------------- | ------ | -------- | ---------- |
| 探針性能 | 中 | 低 | **高** |
| collector擴(kuò)展性 | **高** | 中 | **高** |
| 調(diào)用鏈路數(shù)據(jù)分析 | 低 | **高** | 中 |
| 對(duì)開發(fā)透明性 | 中 | **高** | **高** |
| 調(diào)用鏈應(yīng)用拓?fù)?| 中 | **高** | 中 |
| 社區(qū)支持 | **高** | 中 | **高** |
可見,zipkin的探針性能、開發(fā)透明性、數(shù)據(jù)分析能力都不占優(yōu),實(shí)在是下下之選。
而pinpoint在數(shù)據(jù)分析能力、開發(fā)透明性上有較大的優(yōu)勢(shì),不過(guò)Pinpoint的部署相對(duì)比較復(fù)雜,需要的硬件資源較高。
Skywalking的探針性能和開發(fā)透明性上具有較大優(yōu)勢(shì),數(shù)據(jù)分析能力上也還不錯(cuò),重要的是其部署比較方便靈活,比起Pinpoint更適合中小型企業(yè)使用。
因此,本文會(huì)帶著大家學(xué)習(xí)Skywalking的使用。
Skywalking介紹
SkyWalking創(chuàng)建與2015年,提供分布式追蹤功能。從5.x開始,項(xiàng)目進(jìn)化為一個(gè)完成功能的Application Performance Management系統(tǒng)。
他被用于追蹤、監(jiān)控和診斷分布式系統(tǒng),特別是使用微服務(wù)架構(gòu),云原生或容積技術(shù)。提供以下主要功能:
- 分布式追蹤和上下文傳輸
- 應(yīng)用、實(shí)例、服務(wù)性能指標(biāo)分析
- 根源分析
- 應(yīng)用拓?fù)浞治?/p>
- 應(yīng)用和服務(wù)依賴分析
- 慢服務(wù)檢測(cè)
- 性能優(yōu)化
官網(wǎng)地址:http://skywalking.apache.org/
主要的特征:
- 多語(yǔ)言探針或類庫(kù)
- Java自動(dòng)探針,追蹤和監(jiān)控程序時(shí),不需要修改源碼。
- 社區(qū)提供的其他多語(yǔ)言探針
- [.NET Core](https://github.com/OpenSkywalking/skywalking-netcore)
- [Node.js](https://github.com/OpenSkywalking/skywalking-nodejs)
- 多種后端存儲(chǔ): ElasticSearch, H2
- 支持
OpenTracing
- Java自動(dòng)探針支持和OpenTracing API協(xié)同工作
- 輕量級(jí)、完善功能的后端聚合和分析
- 現(xiàn)代化Web UI
- 日志集成
- 應(yīng)用、實(shí)例和服務(wù)的告警
Skywalking的安裝
先來(lái)看下Skywalking的官方給出的結(jié)構(gòu)圖:
大致分四個(gè)部分:
- skywalking-oap-server:就是Observability Analysis Platformd的服務(wù),用來(lái)收集和處理探針發(fā)來(lái)的數(shù)據(jù)
- skywalking-UI:就是skywalking提供的Web UI 服務(wù),圖形化方式展示服務(wù)鏈路、拓?fù)鋱D、trace、性能監(jiān)控等
- agent:探針,獲取服務(wù)調(diào)用的鏈路信息、性能信息,發(fā)送到skywalking的OAP服務(wù)
- Storage:存儲(chǔ),一般選擇elasticsearch
Skywalking支持windows或者Linux環(huán)境部署。這里我們選擇在Linux下安裝Skywalking,大家要**先確保自己的Linux環(huán)境中有elasticsearch在啟動(dòng)中**。
接下來(lái)的安裝分為三步:
- 下載安裝包
- 安裝Skywalking的OAP服務(wù)和WebUI
- 在服務(wù)中部署探針
下載安裝包
安裝包可以再Skywalking的官網(wǎng)下載,http://skywalking.apache.org/downloads/
目前最新版本是8.0.1版本:
下載好的安裝包:
安裝OAP服務(wù)和WebUI
安裝
將下載好的安裝包解壓到Linux的某個(gè)目錄下:
tar xvf apache-skywalking-apm-es7-8.0.1.tar.gz
然后對(duì)解壓好的文件夾重命名:
mv apache-skywalking-apm-es7 skywalking
進(jìn)入解壓好的目錄:
cd skywalking
查看目錄結(jié)構(gòu):
幾個(gè)關(guān)鍵的目錄:
- agent:探針
- bin:?jiǎn)?dòng)腳本
- config:配置文件
- logs:日志
- oap-libs:依賴
- webapp:WebUI
這里要修改config目錄中的application.yml文件,詳細(xì)配置見官網(wǎng):https://github.com/apache/skywalking/blob/v8.0.1/docs/en/setup/backend/backend-setup.md
配置
進(jìn)入`config`目錄,修改`application.yml`,主要是把存儲(chǔ)方案從h2改為elasticsearch
可以直接使用下面的配置:
cluster: selector: ${SW_CLUSTER:standalone} standalone: core: selector: ${SW_CORE:default} default: role: ${SW_CORE_ROLE:Mixed} # Mixed/Receiver/Aggregator restHost: ${SW_CORE_REST_HOST:0.0.0.0} restPort: ${SW_CORE_REST_PORT:12800} restContextPath: ${SW_CORE_REST_CONTEXT_PATH:/} gRPCHost: ${SW_CORE_GRPC_HOST:0.0.0.0} gRPCPort: ${SW_CORE_GRPC_PORT:11800} gRPCSslEnabled: ${SW_CORE_GRPC_SSL_ENABLED:false} gRPCSslKeyPath: ${SW_CORE_GRPC_SSL_KEY_PATH:""} gRPCSslCertChainPath: ${SW_CORE_GRPC_SSL_CERT_CHAIN_PATH:""} gRPCSslTrustedCAPath: ${SW_CORE_GRPC_SSL_TRUSTED_CA_PATH:""} downsampling: - Hour - Day - Month # Set a timeout on metrics data. After the timeout has expired, the metrics data will automatically be deleted. enableDataKeeperExecutor: ${SW_CORE_ENABLE_DATA_KEEPER_EXECUTOR:true} # Turn it off then automatically metrics data delete will be close. dataKeeperExecutePeriod: ${SW_CORE_DATA_KEEPER_EXECUTE_PERIOD:5} # How often the data keeper executor runs periodically, unit is minute recordDataTTL: ${SW_CORE_RECORD_DATA_TTL:3} # Unit is day metricsDataTTL: ${SW_CORE_RECORD_DATA_TTL:7} # Unit is day # Cache metric data for 1 minute to reduce database queries, and if the OAP cluster changes within that minute, # the metrics may not be accurate within that minute. enableDatabaseSession: ${SW_CORE_ENABLE_DATABASE_SESSION:true} topNReportPeriod: ${SW_CORE_TOPN_REPORT_PERIOD:10} # top_n record worker report cycle, unit is minute # Extra model column are the column defined by in the codes, These columns of model are not required logically in aggregation or further query, # and it will cause more load for memory, network of OAP and storage. # But, being activated, user could see the name in the storage entities, which make users easier to use 3rd party tool, such as Kibana->ES, to query the data by themselves. activeExtraModelColumns: ${SW_CORE_ACTIVE_EXTRA_MODEL_COLUMNS:false} # The max length of service + instance names should be less than 200 serviceNameMaxLength: ${SW_SERVICE_NAME_MAX_LENGTH:70} instanceNameMaxLength: ${SW_INSTANCE_NAME_MAX_LENGTH:70} # The max length of service + endpoint names should be less than 240 endpointNameMaxLength: ${SW_ENDPOINT_NAME_MAX_LENGTH:150} storage: selector: ${SW_STORAGE:elasticsearch7} elasticsearch7: nameSpace: ${SW_NAMESPACE:""} clusterNodes: ${SW_STORAGE_ES_CLUSTER_NODES:localhost:9200} protocol: ${SW_STORAGE_ES_HTTP_PROTOCOL:"http"} trustStorePath: ${SW_STORAGE_ES_SSL_JKS_PATH:""} trustStorePass: ${SW_STORAGE_ES_SSL_JKS_PASS:""} dayStep: ${SW_STORAGE_DAY_STEP:1} # Represent the number of days in the one minute/hour/day index. user: ${SW_ES_USER:""} password: ${SW_ES_PASSWORD:""} secretsManagementFile: ${SW_ES_SECRETS_MANAGEMENT_FILE:""} # Secrets management file in the properties format includes the username, password, which are managed by 3rd party tool. indexShardsNumber: ${SW_STORAGE_ES_INDEX_SHARDS_NUMBER:1} # The index shards number is for store metrics data rather than basic segment record superDatasetIndexShardsFactor: ${SW_STORAGE_ES_SUPER_DATASET_INDEX_SHARDS_FACTOR:5} # Super data set has been defined in the codes, such as trace segments. This factor provides more shards for the super data set, shards number = indexShardsNumber * superDatasetIndexShardsFactor. Also, this factor effects Zipkin and Jaeger traces. indexReplicasNumber: ${SW_STORAGE_ES_INDEX_REPLICAS_NUMBER:0} # Batch process setting, refer to https://www.elastic.co/guide/en/elasticsearch/client/java-api/5.5/java-docs-bulk-processor.html bulkActions: ${SW_STORAGE_ES_BULK_ACTIONS:1000} # Execute the bulk every 1000 requests flushInterval: ${SW_STORAGE_ES_FLUSH_INTERVAL:10} # flush the bulk every 10 seconds whatever the number of requests concurrentRequests: ${SW_STORAGE_ES_CONCURRENT_REQUESTS:2} # the number of concurrent requests resultWindowMaxSize: ${SW_STORAGE_ES_QUERY_MAX_WINDOW_SIZE:10000} metadataQueryMaxSize: ${SW_STORAGE_ES_QUERY_MAX_SIZE:5000} segmentQueryMaxSize: ${SW_STORAGE_ES_QUERY_SEGMENT_SIZE:200} profileTaskQueryMaxSize: ${SW_STORAGE_ES_QUERY_PROFILE_TASK_SIZE:200} advanced: ${SW_STORAGE_ES_ADVANCED:""} h2: driver: ${SW_STORAGE_H2_DRIVER:org.h2.jdbcx.JdbcDataSource} url: ${SW_STORAGE_H2_URL:jdbc:h2:mem:skywalking-oap-db} user: ${SW_STORAGE_H2_USER:sa} metadataQueryMaxSize: ${SW_STORAGE_H2_QUERY_MAX_SIZE:5000} receiver-sharing-server: selector: ${SW_RECEIVER_SHARING_SERVER:default} default: authentication: ${SW_AUTHENTICATION:""} receiver-register: selector: ${SW_RECEIVER_REGISTER:default} default: receiver-trace: selector: ${SW_RECEIVER_TRACE:default} default: sampleRate: ${SW_TRACE_SAMPLE_RATE:10000} # The sample rate precision is 1/10000. 10000 means 100% sample in default. slowDBAccessThreshold: ${SW_SLOW_DB_THRESHOLD:default:200,mongodb:100} # The slow database access thresholds. Unit ms. receiver-jvm: selector: ${SW_RECEIVER_JVM:default} default: receiver-clr: selector: ${SW_RECEIVER_CLR:default} default: receiver-profile: selector: ${SW_RECEIVER_PROFILE:default} default: service-mesh: selector: ${SW_SERVICE_MESH:default} default: istio-telemetry: selector: ${SW_ISTIO_TELEMETRY:default} default: envoy-metric: selector: ${SW_ENVOY_METRIC:default} default: acceptMetricsService: ${SW_ENVOY_METRIC_SERVICE:true} alsHTTPAnalysis: ${SW_ENVOY_METRIC_ALS_HTTP_ANALYSIS:""} prometheus-fetcher: selector: ${SW_PROMETHEUS_FETCHER:default} default: active: ${SW_PROMETHEUS_FETCHER_ACTIVE:false} receiver_zipkin: selector: ${SW_RECEIVER_ZIPKIN:-} default: host: ${SW_RECEIVER_ZIPKIN_HOST:0.0.0.0} port: ${SW_RECEIVER_ZIPKIN_PORT:9411} contextPath: ${SW_RECEIVER_ZIPKIN_CONTEXT_PATH:/} receiver_jaeger: selector: ${SW_RECEIVER_JAEGER:-} default: gRPCHost: ${SW_RECEIVER_JAEGER_HOST:0.0.0.0} gRPCPort: ${SW_RECEIVER_JAEGER_PORT:14250} query: selector: ${SW_QUERY:graphql} graphql: path: ${SW_QUERY_GRAPHQL_PATH:/graphql} alarm: selector: ${SW_ALARM:default} default: telemetry: selector: ${SW_TELEMETRY:none} none: prometheus: host: ${SW_TELEMETRY_PROMETHEUS_HOST:0.0.0.0} port: ${SW_TELEMETRY_PROMETHEUS_PORT:1234} configuration: selector: ${SW_CONFIGURATION:none} none: grpc: host: ${SW_DCS_SERVER_HOST:""} port: ${SW_DCS_SERVER_PORT:80} clusterName: ${SW_DCS_CLUSTER_NAME:SkyWalking} period: ${SW_DCS_PERIOD:20} apollo: apolloMeta: ${SW_CONFIG_APOLLO:http://106.12.25.204:8080} apolloCluster: ${SW_CONFIG_APOLLO_CLUSTER:default} apolloEnv: ${SW_CONFIG_APOLLO_ENV:""} appId: ${SW_CONFIG_APOLLO_APP_ID:skywalking} period: ${SW_CONFIG_APOLLO_PERIOD:5} zookeeper: period: ${SW_CONFIG_ZK_PERIOD:60} # Unit seconds, sync period. Default fetch every 60 seconds. nameSpace: ${SW_CONFIG_ZK_NAMESPACE:/default} hostPort: ${SW_CONFIG_ZK_HOST_PORT:localhost:2181} # Retry Policy baseSleepTimeMs: ${SW_CONFIG_ZK_BASE_SLEEP_TIME_MS:1000} # initial amount of time to wait between retries maxRetries: ${SW_CONFIG_ZK_MAX_RETRIES:3} # max number of times to retry etcd: period: ${SW_CONFIG_ETCD_PERIOD:60} # Unit seconds, sync period. Default fetch every 60 seconds. group: ${SW_CONFIG_ETCD_GROUP:skywalking} serverAddr: ${SW_CONFIG_ETCD_SERVER_ADDR:localhost:2379} clusterName: ${SW_CONFIG_ETCD_CLUSTER_NAME:default} consul: # Consul host and ports, separated by comma, e.g. 1.2.3.4:8500,2.3.4.5:8500 hostAndPorts: ${SW_CONFIG_CONSUL_HOST_AND_PORTS:1.2.3.4:8500} # Sync period in seconds. Defaults to 60 seconds. period: ${SW_CONFIG_CONSUL_PERIOD:1} # Consul aclToken aclToken: ${SW_CONFIG_CONSUL_ACL_TOKEN:""} exporter: selector: ${SW_EXPORTER:-} grpc: targetHost: ${SW_EXPORTER_GRPC_HOST:127.0.0.1} targetPort: ${SW_EXPORTER_GRPC_PORT:9870}
啟動(dòng)
要確保已經(jīng)啟動(dòng)了elasticsearch,并且防火墻開放8080、11800、12800端口。
進(jìn)入`bin`目錄,執(zhí)行命令即可運(yùn)行:
./startup.sh
默認(rèn)的UI端口是8080,可以訪問(wèn):http://192.168.150.101:8080
部署微服務(wù)探針
現(xiàn)在,Skywalking的服務(wù)端已經(jīng)啟動(dòng)完成,我們還需要在微服務(wù)中加入服務(wù)探針,來(lái)收集數(shù)據(jù)。
解壓
首先,將課前資料給的壓縮包解壓:
將其中的`agent`解壓到某個(gè)目錄,不要出現(xiàn)中文,可以看到其結(jié)構(gòu)如下:
其中有一個(gè)`skywalking-agent.jar`就是一我們要用的探針。
配置
如果是運(yùn)行一個(gè)jar包,可以在運(yùn)行時(shí)輸入?yún)?shù)來(lái)指定探針:
java -jar xxx.jar -javaagent:C:/lesson/skywalking-agent/skywalking-agent.jar -Dskywalking.agent.service_name=ly-registry -Dskywalking.collector.backend_service=192.168.150.101:11800
本例中,我們用開發(fā)工具來(lái)運(yùn)行和配置。
使用IDEA開發(fā)工具打開一個(gè)你的項(xiàng)目,在IDEA工具中,選擇要修改的啟動(dòng)項(xiàng),點(diǎn)擊右鍵,選擇`Edit Configuration`:
然后在彈出的窗口中,點(diǎn)擊`Environment`,選擇`VM options`后面對(duì)應(yīng)的展開按鈕:
在展開的輸入框中,輸入下面的配置:
-javaagent:C:/lesson/skywalking-agent/skywalking-agent.jar -Dskywalking.agent.service_name=ly-registry -Dskywalking.collector.backend_service=192.168.150.101:11800
注意:
- `-javaagent:C:/lesson/skywalking-agent/skywalking-agent.jar`:配置的是skywalking-agent.jar這個(gè)包的位置,要修改成你自己存放的目錄
- `-Dskywalking.agent.service_name=ly-registry`:是當(dāng)前項(xiàng)目的名稱,需要分別修改為`ly-registry`、`ly-gateway`、`ly-item-service`
- `-Dskywalking.collector.backend_service=192.168.150.101:11800`:是Skywalking的OPA服務(wù)地址,采用的是GRPC通信,因此端口是11800,不是8080
啟動(dòng)
Skywalking的探針會(huì)在項(xiàng)目啟動(dòng)前對(duì)class文件進(jìn)行修改,完成探針植入,對(duì)業(yè)務(wù)代碼**零侵入**,所以我們只需要啟動(dòng)項(xiàng)目,即可生效了。
啟動(dòng)項(xiàng)目,然后對(duì)項(xiàng)目中的的業(yè)務(wù)接口訪問(wèn),探針就開始工作了。
WebUI界面
訪問(wèn):http://192.168.150.101:8080可以看到統(tǒng)計(jì)數(shù)據(jù)已經(jīng)出來(lái)了:
服務(wù)實(shí)例的性能監(jiān)控:
服務(wù)拓?fù)鋱D:
某次請(qǐng)求的鏈路追蹤信息:
表格視圖:
本文版權(quán)歸黑馬程序員Java培訓(xùn)學(xué)院所有,歡迎轉(zhuǎn)載,轉(zhuǎn)載請(qǐng)注明作者出處。謝謝!
作者:黑馬程序員Java培訓(xùn)學(xué)院
首發(fā):https://java.itheima.com