feat: support multiple trace agents (#1183)
* feat: support multiple trace agents * feat: support multiple trace agents, let later calls run if error happens * test: add more testsmaster
parent
a71a210704
commit
3c1cfd4c1e
@ -0,0 +1,54 @@
|
|||||||
|
package trace
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/tal-tech/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestStartAgent(t *testing.T) {
|
||||||
|
logx.Disable()
|
||||||
|
|
||||||
|
const (
|
||||||
|
endpoint1 = "localhost:1234"
|
||||||
|
endpoint2 = "remotehost:1234"
|
||||||
|
endpoint3 = "localhost:1235"
|
||||||
|
)
|
||||||
|
c1 := Config{
|
||||||
|
Name: "foo",
|
||||||
|
}
|
||||||
|
c2 := Config{
|
||||||
|
Name: "bar",
|
||||||
|
Endpoint: endpoint1,
|
||||||
|
Batcher: kindJaeger,
|
||||||
|
}
|
||||||
|
c3 := Config{
|
||||||
|
Name: "any",
|
||||||
|
Endpoint: endpoint2,
|
||||||
|
Batcher: kindZipkin,
|
||||||
|
}
|
||||||
|
c4 := Config{
|
||||||
|
Name: "bla",
|
||||||
|
Endpoint: endpoint3,
|
||||||
|
Batcher: "otlp",
|
||||||
|
}
|
||||||
|
|
||||||
|
StartAgent(c1)
|
||||||
|
StartAgent(c1)
|
||||||
|
StartAgent(c2)
|
||||||
|
StartAgent(c3)
|
||||||
|
StartAgent(c4)
|
||||||
|
|
||||||
|
lock.Lock()
|
||||||
|
defer lock.Unlock()
|
||||||
|
|
||||||
|
// because remotehost cannot be resolved
|
||||||
|
assert.Equal(t, 2, len(agents))
|
||||||
|
_, ok := agents[""]
|
||||||
|
assert.True(t, ok)
|
||||||
|
_, ok = agents[endpoint1]
|
||||||
|
assert.True(t, ok)
|
||||||
|
_, ok = agents[endpoint2]
|
||||||
|
assert.False(t, ok)
|
||||||
|
}
|
Loading…
Reference in New Issue