Skip to main content

Use OpenSergo with CloudWeGo Kitex

Kitex Overview

Kitex [kaɪt'eks] is a high-performance and strong-extensibility Golang RPC framework that helps developers build microservices. If the performance and extensibility are the main concerns when you develop microservices, Kitex can be a good choice. Kitex is a subproject of CloudWeGo, for more details please visit CloudWeGo website.

Access OpenSergo in Kitex

Kitex provides many interfaces with default implementation for users to customize. You can extend or inject them into Kitex to fulfill your needs. For example, you can inject a customized logger into Kitex.

To get metainfo available in OpenSergo Dashboard, what we need to do is also quite simple.

package main

import (
...
"github.com/cloudwego/kitex/server"
"github.com/kitex-contrib/opensergo/metainfo"
...
)

func main() {
...
r, err := metainfo.NewDefaultMetaReporter()
if err != nil {
panic(err)
}
svr := hello.NewServer(
new(HelloImpl),
)
server.RegisterStartHook(func() {
if err = r.ReportMetaInfo(svr.GetServiceInfo()); err != nil {
klog.Error(err)
}
})
...
}

References