Since Opentracing is archived by the owner on May 24, 2023, we will not continue to maintain this project.
Please Use OpenTemeletry instead.
Opentracing tracer for Kitex
import (
...
"github.com/cloudwego/kitex/server"
internal_opentracing "github.com/kitex-contrib/tracer-opentracing"
...
)
func main() {
...
tracer := internal_opentracing.NewDefaultServerSuite()
svr := echo.NewServer(new(EchoImpl), server.WithSuite(tracer))
...
}
DefaultServerOption
will use opentracing global tracer as tracer, and {Service Name}::{Method Name}
as operation name. You can customize both by ServerOption
.
Make sure opentracing global tracer has been initialized (See Example below).
import (
...
"github.com/cloudwego/kitex/client"
internal_opentracing "github.com/kitex-contrib/tracer-opentracing"
...
)
func main() {
...
tracer := internal_opentracing.NewDefaultClientSuite()
client, err := echo.NewClient("echo", client.WithSuite(tracer))
if err != nil {
log.Fatal(err)
}
...
}
Just like server, DefaultClientOption
will use opentracing global tracer as tracer, and {Service Name}::{Method Name}
as operation name. You can customize both by ClientOption
.
Make sure opentracing global tracer has been initialized (See Example below).
You need to add the hook provided by tracer-opentracing to instrument Redis client:
import (
...
"github.com/go-redis/redis/v8"
internal_opentracing "github.com/kitex-contrib/tracer-opentracing"
...
)
func main() {
...
rdb := redis.NewClient(&redis.Options{...})
rdb.AddHook(internal_opentracing.NewTracingHook())
...
}