mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
committed by
Carl Bergquist
parent
1c3ad78672
commit
02975256d1
@@ -2,6 +2,7 @@ package tracing
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
@@ -11,6 +12,7 @@ import (
|
||||
|
||||
opentracing "github.com/opentracing/opentracing-go"
|
||||
jaegercfg "github.com/uber/jaeger-client-go/config"
|
||||
"github.com/uber/jaeger-client-go/zipkin"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -18,13 +20,15 @@ func init() {
|
||||
}
|
||||
|
||||
type TracingService struct {
|
||||
enabled bool
|
||||
address string
|
||||
customTags map[string]string
|
||||
samplerType string
|
||||
samplerParam float64
|
||||
log log.Logger
|
||||
closer io.Closer
|
||||
enabled bool
|
||||
address string
|
||||
customTags map[string]string
|
||||
samplerType string
|
||||
samplerParam float64
|
||||
log log.Logger
|
||||
closer io.Closer
|
||||
zipkinPropagation bool
|
||||
disableSharedZipkinSpans bool
|
||||
|
||||
Cfg *setting.Cfg `inject:""`
|
||||
}
|
||||
@@ -54,6 +58,8 @@ func (ts *TracingService) parseSettings() {
|
||||
ts.customTags = splitTagSettings(section.Key("always_included_tag").MustString(""))
|
||||
ts.samplerType = section.Key("sampler_type").MustString("")
|
||||
ts.samplerParam = section.Key("sampler_param").MustFloat64(1)
|
||||
ts.zipkinPropagation = section.Key("zipkin_propagation").MustBool(false)
|
||||
ts.disableSharedZipkinSpans = section.Key("disable_shared_zipkin_spans").MustBool(false)
|
||||
}
|
||||
|
||||
func (ts *TracingService) initGlobalTracer() error {
|
||||
@@ -79,6 +85,18 @@ func (ts *TracingService) initGlobalTracer() error {
|
||||
options = append(options, jaegercfg.Tag(tag, value))
|
||||
}
|
||||
|
||||
if ts.zipkinPropagation {
|
||||
zipkinPropagator := zipkin.NewZipkinB3HTTPHeaderPropagator()
|
||||
options = append(options,
|
||||
jaegercfg.Injector(opentracing.HTTPHeaders, zipkinPropagator),
|
||||
jaegercfg.Extractor(opentracing.HTTPHeaders, zipkinPropagator),
|
||||
)
|
||||
|
||||
if !ts.disableSharedZipkinSpans {
|
||||
options = append(options, jaegercfg.ZipkinSharedRPCSpan(true))
|
||||
}
|
||||
}
|
||||
|
||||
tracer, closer, err := cfg.NewTracer(options...)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -124,6 +142,7 @@ func (jlw *jaegerLogWrapper) Error(msg string) {
|
||||
jlw.logger.Error(msg)
|
||||
}
|
||||
|
||||
func (jlw *jaegerLogWrapper) Infof(msg string, args ...interface{}) {
|
||||
jlw.logger.Info(msg, args)
|
||||
func (jlw *jaegerLogWrapper) Infof(format string, args ...interface{}) {
|
||||
msg := fmt.Sprintf(format, args...)
|
||||
jlw.logger.Info(msg)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user