-
Notifications
You must be signed in to change notification settings - Fork 0
/
jagger.go
35 lines (30 loc) · 970 Bytes
/
jagger.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 main
import (
"fmt"
"io"
opentracing "github.com/opentracing/opentracing-go"
"github.com/uber/jaeger-client-go"
jaegercfg "github.com/uber/jaeger-client-go/config"
)
func getTracer(name string) (*opentracing.Tracer, io.Closer, error) {
defaultSamplingServerURL := "http://localhost:5778/sampling"
// Change config to dofferent sampler rate lile default
// in a production setting since not all requests need tracing
// only a N % is needed to take decisions about performense
cfg := jaegercfg.Configuration{
Sampler: &jaegercfg.SamplerConfig{
SamplingServerURL: defaultSamplingServerURL,
Type: jaeger.SamplerTypeConst,
Param: 1,
},
Reporter: &jaegercfg.ReporterConfig{
LogSpans: true,
},
}
// Initialize tracer with a logger and a metrics factory
tracer, closer, err := cfg.New(name)
if err != nil {
return nil, nil, fmt.Errorf("getTracer err: %v", err.Error())
}
return &tracer, closer, nil
}