-
Notifications
You must be signed in to change notification settings - Fork 0
/
jaeger.go
35 lines (29 loc) · 910 Bytes
/
jaeger.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package tracing
import (
"github.com/opentracing/opentracing-go"
"github.com/uber/jaeger-client-go"
"github.com/uber/jaeger-client-go/config"
"io"
)
type Config struct {
ServiceName string `mapstructure:"serviceName"`
HostPort string `mapstructure:"hostPort"`
Enable bool `mapstructure:"enable"`
LogSpans bool `mapstructure:"logSpans"`
}
func NewJaegerTracer(jaegerConfig *Config) (opentracing.Tracer, io.Closer, error) {
cfg := &config.Configuration{
ServiceName: jaegerConfig.ServiceName,
// "const" sampler is a binary sampling strategy: 0=never sample, 1=always sample.
Sampler: &config.SamplerConfig{
Type: "const",
Param: 1,
},
// Log the emitted spans to stdout.
Reporter: &config.ReporterConfig{
LogSpans: jaegerConfig.LogSpans,
LocalAgentHostPort: jaegerConfig.HostPort,
},
}
return cfg.NewTracer(config.Logger(jaeger.StdLogger))
}