Blame SOURCES/002-remove-jaeger-tracing.patch

50fcc5
diff --git a/pkg/cmd/grafana-server/server.go b/pkg/cmd/grafana-server/server.go
0d3998
index 85d6db43e..6de99b58b 100644
50fcc5
--- a/pkg/cmd/grafana-server/server.go
50fcc5
+++ b/pkg/cmd/grafana-server/server.go
0d3998
@@ -23,7 +23,6 @@ import (
50fcc5
 	_ "github.com/grafana/grafana/pkg/infra/metrics"
50fcc5
 	_ "github.com/grafana/grafana/pkg/infra/remotecache"
50fcc5
 	_ "github.com/grafana/grafana/pkg/infra/serverlock"
50fcc5
-	_ "github.com/grafana/grafana/pkg/infra/tracing"
50fcc5
 	_ "github.com/grafana/grafana/pkg/infra/usagestats"
50fcc5
 	"github.com/grafana/grafana/pkg/login"
0d3998
 	"github.com/grafana/grafana/pkg/login/social"
50fcc5
diff --git a/pkg/infra/tracing/tracing.go b/pkg/infra/tracing/tracing.go
50fcc5
deleted file mode 100644
0d3998
index d1511a533..000000000
50fcc5
--- a/pkg/infra/tracing/tracing.go
50fcc5
+++ /dev/null
0d3998
@@ -1,148 +0,0 @@
50fcc5
-package tracing
50fcc5
-
50fcc5
-import (
50fcc5
-	"context"
0d3998
-	"fmt"
50fcc5
-	"io"
50fcc5
-	"strings"
50fcc5
-
0d3998
-	"github.com/grafana/grafana/pkg/infra/log"
50fcc5
-	"github.com/grafana/grafana/pkg/registry"
50fcc5
-	"github.com/grafana/grafana/pkg/setting"
50fcc5
-
50fcc5
-	opentracing "github.com/opentracing/opentracing-go"
50fcc5
-	jaegercfg "github.com/uber/jaeger-client-go/config"
0d3998
-	"github.com/uber/jaeger-client-go/zipkin"
50fcc5
-)
50fcc5
-
50fcc5
-func init() {
50fcc5
-	registry.RegisterService(&TracingService{})
50fcc5
-}
50fcc5
-
50fcc5
-type TracingService struct {
0d3998
-	enabled                  bool
0d3998
-	address                  string
0d3998
-	customTags               map[string]string
0d3998
-	samplerType              string
0d3998
-	samplerParam             float64
0d3998
-	log                      log.Logger
0d3998
-	closer                   io.Closer
0d3998
-	zipkinPropagation        bool
0d3998
-	disableSharedZipkinSpans bool
50fcc5
-
50fcc5
-	Cfg *setting.Cfg `inject:""`
50fcc5
-}
50fcc5
-
50fcc5
-func (ts *TracingService) Init() error {
50fcc5
-	ts.log = log.New("tracing")
50fcc5
-	ts.parseSettings()
50fcc5
-
50fcc5
-	if ts.enabled {
50fcc5
-		ts.initGlobalTracer()
50fcc5
-	}
50fcc5
-
50fcc5
-	return nil
50fcc5
-}
50fcc5
-
50fcc5
-func (ts *TracingService) parseSettings() {
50fcc5
-	var section, err = ts.Cfg.Raw.GetSection("tracing.jaeger")
50fcc5
-	if err != nil {
50fcc5
-		return
50fcc5
-	}
50fcc5
-
50fcc5
-	ts.address = section.Key("address").MustString("")
50fcc5
-	if ts.address != "" {
50fcc5
-		ts.enabled = true
50fcc5
-	}
50fcc5
-
50fcc5
-	ts.customTags = splitTagSettings(section.Key("always_included_tag").MustString(""))
50fcc5
-	ts.samplerType = section.Key("sampler_type").MustString("")
50fcc5
-	ts.samplerParam = section.Key("sampler_param").MustFloat64(1)
0d3998
-	ts.zipkinPropagation = section.Key("zipkin_propagation").MustBool(false)
0d3998
-	ts.disableSharedZipkinSpans = section.Key("disable_shared_zipkin_spans").MustBool(false)
50fcc5
-}
50fcc5
-
50fcc5
-func (ts *TracingService) initGlobalTracer() error {
50fcc5
-	cfg := jaegercfg.Configuration{
50fcc5
-		ServiceName: "grafana",
50fcc5
-		Disabled:    !ts.enabled,
50fcc5
-		Sampler: &jaegercfg.SamplerConfig{
50fcc5
-			Type:  ts.samplerType,
50fcc5
-			Param: ts.samplerParam,
50fcc5
-		},
50fcc5
-		Reporter: &jaegercfg.ReporterConfig{
50fcc5
-			LogSpans:           false,
50fcc5
-			LocalAgentHostPort: ts.address,
50fcc5
-		},
50fcc5
-	}
50fcc5
-
50fcc5
-	jLogger := &jaegerLogWrapper{logger: log.New("jaeger")}
50fcc5
-
50fcc5
-	options := []jaegercfg.Option{}
50fcc5
-	options = append(options, jaegercfg.Logger(jLogger))
50fcc5
-
50fcc5
-	for tag, value := range ts.customTags {
50fcc5
-		options = append(options, jaegercfg.Tag(tag, value))
50fcc5
-	}
50fcc5
-
0d3998
-	if ts.zipkinPropagation {
0d3998
-		zipkinPropagator := zipkin.NewZipkinB3HTTPHeaderPropagator()
0d3998
-		options = append(options,
0d3998
-			jaegercfg.Injector(opentracing.HTTPHeaders, zipkinPropagator),
0d3998
-			jaegercfg.Extractor(opentracing.HTTPHeaders, zipkinPropagator),
0d3998
-		)
0d3998
-
0d3998
-		if !ts.disableSharedZipkinSpans {
0d3998
-			options = append(options, jaegercfg.ZipkinSharedRPCSpan(true))
0d3998
-		}
0d3998
-	}
0d3998
-
50fcc5
-	tracer, closer, err := cfg.NewTracer(options...)
50fcc5
-	if err != nil {
50fcc5
-		return err
50fcc5
-	}
50fcc5
-
50fcc5
-	opentracing.InitGlobalTracer(tracer)
50fcc5
-
50fcc5
-	ts.closer = closer
50fcc5
-
50fcc5
-	return nil
50fcc5
-}
50fcc5
-
50fcc5
-func (ts *TracingService) Run(ctx context.Context) error {
50fcc5
-	<-ctx.Done()
50fcc5
-
50fcc5
-	if ts.closer != nil {
50fcc5
-		ts.log.Info("Closing tracing")
50fcc5
-		ts.closer.Close()
50fcc5
-	}
50fcc5
-
50fcc5
-	return nil
50fcc5
-}
50fcc5
-
50fcc5
-func splitTagSettings(input string) map[string]string {
50fcc5
-	res := map[string]string{}
50fcc5
-
50fcc5
-	tags := strings.Split(input, ",")
50fcc5
-	for _, v := range tags {
50fcc5
-		kv := strings.Split(v, ":")
50fcc5
-		if len(kv) > 1 {
50fcc5
-			res[kv[0]] = kv[1]
50fcc5
-		}
50fcc5
-	}
50fcc5
-
50fcc5
-	return res
50fcc5
-}
50fcc5
-
50fcc5
-type jaegerLogWrapper struct {
50fcc5
-	logger log.Logger
50fcc5
-}
50fcc5
-
50fcc5
-func (jlw *jaegerLogWrapper) Error(msg string) {
50fcc5
-	jlw.logger.Error(msg)
50fcc5
-}
50fcc5
-
0d3998
-func (jlw *jaegerLogWrapper) Infof(format string, args ...interface{}) {
0d3998
-	msg := fmt.Sprintf(format, args...)
0d3998
-	jlw.logger.Info(msg)
50fcc5
-}
50fcc5
diff --git a/pkg/infra/tracing/tracing_test.go b/pkg/infra/tracing/tracing_test.go
50fcc5
deleted file mode 100644
50fcc5
index 27e4de777..000000000
50fcc5
--- a/pkg/infra/tracing/tracing_test.go
50fcc5
+++ /dev/null
50fcc5
@@ -1,36 +0,0 @@
50fcc5
-package tracing
50fcc5
-
50fcc5
-import "testing"
50fcc5
-
50fcc5
-func TestGroupSplit(t *testing.T) {
50fcc5
-	tests := []struct {
50fcc5
-		input    string
50fcc5
-		expected map[string]string
50fcc5
-	}{
50fcc5
-		{
50fcc5
-			input: "tag1:value1,tag2:value2",
50fcc5
-			expected: map[string]string{
50fcc5
-				"tag1": "value1",
50fcc5
-				"tag2": "value2",
50fcc5
-			},
50fcc5
-		},
50fcc5
-		{
50fcc5
-			input:    "",
50fcc5
-			expected: map[string]string{},
50fcc5
-		},
50fcc5
-		{
50fcc5
-			input:    "tag1",
50fcc5
-			expected: map[string]string{},
50fcc5
-		},
50fcc5
-	}
50fcc5
-
50fcc5
-	for _, test := range tests {
50fcc5
-		tags := splitTagSettings(test.input)
50fcc5
-		for k, v := range test.expected {
50fcc5
-			value, exists := tags[k]
50fcc5
-			if !exists || value != v {
50fcc5
-				t.Errorf("tags does not match %v ", test)
50fcc5
-			}
50fcc5
-		}
50fcc5
-	}
50fcc5
-}