Kitex 字节跳动开源的 Go 微服务 RPC 框架,具有高性能、强可扩展的特点,在字节内部已广泛使用。
Kitex 以中间件的方式,集成 opentelemetry sdk,可以生成、上报链路、指标、日志数据。
import ( ... "github.com/kitex-contrib/obs-opentelemetry/provider" "github.com/kitex-contrib/obs-opentelemetry/tracing" ) func main() { serviceName := "echo" p := provider.NewOpenTelemetryProvider( provider.WithServiceName(serviceName), provider.WithInsecure(), ) defer p.Shutdown(context.Background()) svr := echo.NewServer( new(EchoImpl), server.WithSuite(tracing.NewServerSuite()), // Please keep the same as provider.WithServiceName server.WithServerBasicInfo(&rpcinfo.EndpointBasicInfo{ServiceName: serviceName}), ) if err := svr.Run(); err != nil { klog.Fatalf("server stopped with error:", err) } }
import ( ... "github.com/kitex-contrib/obs-opentelemetry/provider" "github.com/kitex-contrib/obs-opentelemetry/tracing" ) func main(){ serviceName := "echo-client" p := provider.NewOpenTelemetryProvider( provider.WithServiceName(serviceName), provider.WithInsecure(), ) defer p.Shutdown(context.Background()) c, err := echo.NewClient( "echo", client.WithSuite(tracing.NewClientSuite()), // Please keep the same as provider.WithServiceName client.WithClientBasicInfo(&rpcinfo.EndpointBasicInfo{ServiceName: serviceName}), ) if err != nil { klog.Fatal(err) } }
变量名 | 描述 |
---|---|
OTEL_EXPORTER_OTLP_ENDPOINT | otel 链路、指标数据上报地址 |
OTEL_EXPORTER_OTLP_HEADERS | 鉴权信息,格式如下: |
APMPlusOpenTelemetryCollector是APMPlus基于OpenTelemetryCollector二次开发的数据采集器。您可以在集群中安装 Opentelemetry Collector 做数据转发
变量名 | 描述 |
---|---|
OTEL_EXPORTER_OTLP_ENDPOINT | otel 链路、指标数据上报地址 |