ipld-eth-server/vendor/gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer/option_test.go

41 lines
950 B
Go
Raw Normal View History

2018-09-04 16:35:38 +00:00
package tracer
import (
"testing"
"github.com/stretchr/testify/assert"
)
func withTransport(t transport) StartOption {
return func(c *config) {
c.transport = t
}
}
func TestTracerOptionsDefaults(t *testing.T) {
assert := assert.New(t)
var c config
defaults(&c)
assert.Equal(float64(1), c.sampler.(RateSampler).Rate())
assert.Equal("tracer.test", c.serviceName)
assert.Equal("localhost:8126", c.agentAddr)
}
func TestTracerOptions(t *testing.T) {
assert := assert.New(t)
tracer := newTracer(
WithSampler(NewRateSampler(0.5)),
WithServiceName("api-intake"),
WithAgentAddr("ddagent.consul.local:58126"),
WithGlobalTag("k", "v"),
WithDebugMode(true),
)
c := tracer.config
assert.Equal(float64(0.5), c.sampler.(RateSampler).Rate())
assert.Equal("api-intake", c.serviceName)
assert.Equal("ddagent.consul.local:58126", c.agentAddr)
assert.NotNil(c.globalTags)
assert.Equal("v", c.globalTags["k"])
assert.True(c.debug)
}