* 🐛 debug grpc export (#2379) #2379 Fixed the issue that the GRPC exporter did not establish an RPC link 原文使用的 otlptracegrpc.NewUnstarted创建的是一个未建立rpc连接的导出器,无法正常使用;改为otlptracegrpc.New才妥 * Update agent_test.go 修复单元测试失败
This commit is contained in:
@@ -60,11 +60,12 @@ func createExporter(c Config) (sdktrace.SpanExporter, error) {
|
|||||||
case kindZipkin:
|
case kindZipkin:
|
||||||
return zipkin.New(c.Endpoint)
|
return zipkin.New(c.Endpoint)
|
||||||
case kindGrpc:
|
case kindGrpc:
|
||||||
return otlptracegrpc.NewUnstarted(
|
return otlptracegrpc.New(
|
||||||
|
context.Background(),
|
||||||
otlptracegrpc.WithInsecure(),
|
otlptracegrpc.WithInsecure(),
|
||||||
otlptracegrpc.WithEndpoint(c.Endpoint),
|
otlptracegrpc.WithEndpoint(c.Endpoint),
|
||||||
otlptracegrpc.WithDialOption(grpc.WithBlock()),
|
otlptracegrpc.WithDialOption(grpc.WithBlock()),
|
||||||
), nil
|
)
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("unknown exporter: %s", c.Batcher)
|
return nil, fmt.Errorf("unknown exporter: %s", c.Batcher)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ func TestStartAgent(t *testing.T) {
|
|||||||
const (
|
const (
|
||||||
endpoint1 = "localhost:1234"
|
endpoint1 = "localhost:1234"
|
||||||
endpoint2 = "remotehost:1234"
|
endpoint2 = "remotehost:1234"
|
||||||
endpoint3 = "localhost:1235"
|
|
||||||
)
|
)
|
||||||
c1 := Config{
|
c1 := Config{
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
@@ -30,12 +29,12 @@ func TestStartAgent(t *testing.T) {
|
|||||||
}
|
}
|
||||||
c4 := Config{
|
c4 := Config{
|
||||||
Name: "bla",
|
Name: "bla",
|
||||||
Endpoint: endpoint3,
|
Endpoint: endpoint1,
|
||||||
Batcher: "otlp",
|
Batcher: "otlp",
|
||||||
}
|
}
|
||||||
c5 := Config{
|
c5 := Config{
|
||||||
Name: "grpc",
|
Name: "grpc",
|
||||||
Endpoint: endpoint3,
|
Endpoint: endpoint1,
|
||||||
Batcher: "grpc",
|
Batcher: "grpc",
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +49,7 @@ func TestStartAgent(t *testing.T) {
|
|||||||
defer lock.Unlock()
|
defer lock.Unlock()
|
||||||
|
|
||||||
// because remotehost cannot be resolved
|
// because remotehost cannot be resolved
|
||||||
assert.Equal(t, 3, len(agents))
|
assert.Equal(t, 2, len(agents))
|
||||||
_, ok := agents[""]
|
_, ok := agents[""]
|
||||||
assert.True(t, ok)
|
assert.True(t, ok)
|
||||||
_, ok = agents[endpoint1]
|
_, ok = agents[endpoint1]
|
||||||
|
|||||||
Reference in New Issue
Block a user