mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-24 18:00:24 +08:00
5b35fa17de
* add the opentelemetry tracing * fix the error sampler config * 添加stream的链路跟踪 * fix the error field name
37 lines
999 B
Go
37 lines
999 B
Go
package serverinterceptors
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/tal-tech/go-zero/core/opentelemetry"
|
|
"google.golang.org/grpc"
|
|
)
|
|
|
|
func TestUnaryOpenTracingInterceptor_Disable(t *testing.T) {
|
|
interceptor := UnaryOpenTracingInterceptor()
|
|
_, err := interceptor(context.Background(), nil, &grpc.UnaryServerInfo{
|
|
FullMethod: "/",
|
|
}, func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
return nil, nil
|
|
})
|
|
assert.Nil(t, err)
|
|
}
|
|
|
|
func TestUnaryOpenTracingInterceptor_Enabled(t *testing.T) {
|
|
opentelemetry.StartAgent(opentelemetry.Config{
|
|
Name: "go-zero-test",
|
|
Endpoint: "http://localhost:14268/api/traces",
|
|
Batcher: "jaeger",
|
|
Sampler: 1.0,
|
|
})
|
|
interceptor := UnaryOpenTracingInterceptor()
|
|
_, err := interceptor(context.Background(), nil, &grpc.UnaryServerInfo{
|
|
FullMethod: "/package.TestService.GetUser",
|
|
}, func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
return nil, nil
|
|
})
|
|
assert.Nil(t, err)
|
|
}
|