Monitoring
Kitex has monitoring capability built in, but does not have any monitoring features itself, and can be extended by the interface.
The framework provides a Tracer
interface. Users can implement it and inject it by WithTracer
Option.
// Tracer is executed at the start and finish of an RPC.
type Tracer interface {
Start(ctx context.Context) context.Context
Finish(ctx context.Context)
}
The monitoring extension of prometheus is provided in kitex-contrib, usage example:
Client Side:
import (
"github.com/kitex-contrib/monitor-prometheus"
kClient "github.com/cloudwego/kitex/client"
)
...
client, _ := testClient.NewClient(
"DestServiceName",
kClient.WithTracer(prometheus.NewClientTracer(":9091", "/kitexclient")))
resp, _ := client.Send(ctx, req)
...
Server Side:
import (
"github.com/kitex-contrib/monitor-prometheus"
kServer "github.com/cloudwego/kitex/server"
)
func main() {...
svr := xxxservice.NewServer(
&myServiceImpl{},
kServer.WithTracer(prometheus.NewServerTracer(":9092", "/kitexserver")))
svr.Run()
...
}
Last modified
December 11, 2023
: Update _index.html (#884) (96f70fd)