Skip to content
This repository has been archived by the owner on Aug 14, 2024. It is now read-only.

Latest commit

 

History

History
70 lines (61 loc) · 2.06 KB

README.md

File metadata and controls

70 lines (61 loc) · 2.06 KB

Archived

Since Opentracing is archived by the owner on May 24, 2023, we will not continue to maintain this project.

Please Use OpenTemeletry instead.

opentracing

Opentracing tracer for Kitex

Server usage

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).

Client usage

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).

Example

Executable Example

Supported Components

Redis

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())
    ...
}