W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
診斷模塊是用于將服務(wù)中的信息可視化出來,便于問題排查,確認(rèn)服務(wù)狀態(tài)。Kitex 定義了接口用來注冊診斷 func,擴展者可實現(xiàn)該接口來呈現(xiàn)診斷信息。呈現(xiàn)的方式如:輸出日志、debug 端口查詢展示。Kitex 開源版本暫未提供默認(rèn)擴展,但默認(rèn)注冊了部分可用于診斷的信息,擴展者也可以注冊更多的信息用于問題的排查。
// ProbeName is the name of probe.
type ProbeName string
// ProbeFunc is used to get probe data, it is usually a data dump func.
type ProbeFunc func() interface{}
// Service is the interface for debug service.
type Service interface {
// RegisterProbeFunc is used to register ProbeFunc with probe name
// ProbeFunc is usually a dump func that to dump info to do problem diagnosis,
// eg: CBSuite.Dump(), s.RegisterProbeFunc(CircuitInfoKey, cbs.Dump)
RegisterProbeFunc(ProbeName, ProbeFunc)
}
// new diagnosisi service
var ds diagnosis.service = NewYourService()
// eg: register dump func to get discovery instances.
ds.RegisterProbeFunc("instances", dr.Dump)
// eg: wrap the config data as probe func, register func to get config info.
ds.RegisterProbeFunc("config_info", diagnosis.WrapAsProbeFunc(config))
Kitex 默認(rèn)注冊了部分診斷信息用于問題排查,具體如下:
const (
// Common
ChangeEventsKey ProbeName = "events"
ServiceInfoKey ProbeName = "service_info"
OptionsKey ProbeName = "options"
// Client
DestServiceKey ProbeName = "dest_service"
ConnPoolKey ProbeName = "conn_pool"
RetryPolicyKey ProbeName = "retry_policy"
)
通過 option 指定自己的診斷服務(wù),option: ?WithDiagnosisService
?。
// server side
svr := stservice.NewServer(handler, server.WithDiagnosisService(yourDiagnosisService))
// client side
cli, err := xxxservice.NewClient(targetService, client.WithDiagnosisService(yourDiagnosisService))
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: