W3Cschool
恭喜您成為首批注冊(cè)用戶(hù)
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
診斷模塊是用于將服務(wù)中的信息可視化出來(lái),便于問(wèn)題排查,確認(rèn)服務(wù)狀態(tài)。Kitex 定義了接口用來(lái)注冊(cè)診斷 func,擴(kuò)展者可實(shí)現(xiàn)該接口來(lái)呈現(xiàn)診斷信息。呈現(xiàn)的方式如:輸出日志、debug 端口查詢(xún)展示。Kitex 開(kāi)源版本暫未提供默認(rèn)擴(kuò)展,但默認(rèn)注冊(cè)了部分可用于診斷的信息,擴(kuò)展者也可以注冊(cè)更多的信息用于問(wè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)注冊(cè)了部分診斷信息用于問(wè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"
)
通過(guò) 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號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話(huà):173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: