-
Notifications
You must be signed in to change notification settings - Fork 0
/
jaeger.go
48 lines (39 loc) · 888 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
36
37
38
39
40
41
42
43
44
45
46
47
48
package jaeger
import (
"io"
opentracing "github.com/opentracing/opentracing-go"
"github.com/uber/jaeger-client-go/config"
)
// Name is the name of this tracer.
const Name = "jaeger"
type Trace struct {
opentracing.Tracer
io.Closer
}
func (Trace) Name() string {
return Name
}
type Logger interface {
Errorf(msg string, args ...interface{})
Infof(msg string, args ...interface{})
}
type wrapLogger struct {
Logger
}
func (w wrapLogger) Error(msg string) {
w.Errorf("%s", msg)
}
// Init returns a implementation of tyk.Tracer using jaeger client.
func Init(service string, opts map[string]interface{}, log Logger) (*Trace, error) {
cfg, err := Load(opts)
if service != "" {
cfg.ServiceName = service
}
tr, cls, err := cfg.NewTracer(
config.Logger(&wrapLogger{Logger: log}),
)
if err != nil {
return nil, err
}
return &Trace{Tracer: tr, Closer: cls}, nil
}