/
global.go
38 lines (31 loc) · 966 Bytes
/
global.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
package ctrace
import (
"github.com/Nordstrom/ctrace-go/core"
opentracing "github.com/opentracing/opentracing-go"
// godebug "github.com/tj/go-debug"
)
// TracerOptions allows creating a customized Tracer via NewWithOptions. The object
// must not be updated when there is an active tracer using it. This is an alias
// of core.TracerOptions.
type TracerOptions core.TracerOptions
// var (
// debug = godebug.Debug("ctrace")
// )
func init() {
// debug("Initializing ctrace...") // start with empty line for testing
Init(TracerOptions{})
}
// Init initializes the global Tracer returned by Global().
func Init(opts TracerOptions) core.Tracer {
opentracing.SetGlobalTracer(core.NewWithOptions(
core.TracerOptions{
MultiEvent: opts.MultiEvent,
Writer: opts.Writer,
ServiceName: opts.ServiceName,
}))
return Global()
}
// Global returns the global Tracer
func Global() core.Tracer {
return opentracing.GlobalTracer().(core.Tracer)
}