Blob Blame History Raw
diff --git a/pkg/cmd/grafana-server/server.go b/pkg/cmd/grafana-server/server.go
index 0dace4ebab..f1a4bfde53 100644
--- a/pkg/cmd/grafana-server/server.go
+++ b/pkg/cmd/grafana-server/server.go
@@ -23,7 +23,6 @@ import (
 	_ "github.com/grafana/grafana/pkg/infra/metrics"
 	_ "github.com/grafana/grafana/pkg/infra/remotecache"
 	_ "github.com/grafana/grafana/pkg/infra/serverlock"
-	_ "github.com/grafana/grafana/pkg/infra/tracing"
 	_ "github.com/grafana/grafana/pkg/infra/usagestats"
 	"github.com/grafana/grafana/pkg/login"
 	"github.com/grafana/grafana/pkg/login/social"
diff --git a/pkg/infra/tracing/tracing.go b/pkg/infra/tracing/tracing.go
deleted file mode 100644
index 923459786b..0000000000
--- a/pkg/infra/tracing/tracing.go
+++ /dev/null
@@ -1,161 +0,0 @@
-package tracing
-
-import (
-	"context"
-	"fmt"
-	"io"
-	"strings"
-
-	"github.com/grafana/grafana/pkg/infra/log"
-	"github.com/grafana/grafana/pkg/registry"
-	"github.com/grafana/grafana/pkg/setting"
-
-	opentracing "github.com/opentracing/opentracing-go"
-	jaegercfg "github.com/uber/jaeger-client-go/config"
-	"github.com/uber/jaeger-client-go/zipkin"
-)
-
-func init() {
-	registry.RegisterService(&TracingService{})
-}
-
-type TracingService struct {
-	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:""`
-}
-
-func (ts *TracingService) Init() error {
-	ts.log = log.New("tracing")
-	ts.parseSettings()
-
-	if ts.enabled {
-		return ts.initGlobalTracer()
-	}
-
-	return nil
-}
-
-func (ts *TracingService) parseSettings() {
-	var section, err = ts.Cfg.Raw.GetSection("tracing.jaeger")
-	if err != nil {
-		return
-	}
-
-	ts.address = section.Key("address").MustString("")
-	if ts.address != "" {
-		ts.enabled = true
-	}
-
-	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) initJaegerCfg() (jaegercfg.Configuration, error) {
-	cfg := jaegercfg.Configuration{
-		ServiceName: "grafana",
-		Disabled:    !ts.enabled,
-		Sampler: &jaegercfg.SamplerConfig{
-			Type:  ts.samplerType,
-			Param: ts.samplerParam,
-		},
-		Reporter: &jaegercfg.ReporterConfig{
-			LogSpans:           false,
-			LocalAgentHostPort: ts.address,
-		},
-	}
-
-	_, err := cfg.FromEnv()
-	if err != nil {
-		return cfg, err
-	}
-	return cfg, nil
-}
-
-func (ts *TracingService) initGlobalTracer() error {
-	cfg, err := ts.initJaegerCfg()
-	if err != nil {
-		return err
-	}
-
-	jLogger := &jaegerLogWrapper{logger: log.New("jaeger")}
-
-	options := []jaegercfg.Option{}
-	options = append(options, jaegercfg.Logger(jLogger))
-
-	for tag, value := range ts.customTags {
-		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
-	}
-
-	opentracing.SetGlobalTracer(tracer)
-
-	ts.closer = closer
-
-	return nil
-}
-
-func (ts *TracingService) Run(ctx context.Context) error {
-	<-ctx.Done()
-
-	if ts.closer != nil {
-		ts.log.Info("Closing tracing")
-		ts.closer.Close()
-	}
-
-	return nil
-}
-
-func splitTagSettings(input string) map[string]string {
-	res := map[string]string{}
-
-	tags := strings.Split(input, ",")
-	for _, v := range tags {
-		kv := strings.Split(v, ":")
-		if len(kv) > 1 {
-			res[kv[0]] = kv[1]
-		}
-	}
-
-	return res
-}
-
-type jaegerLogWrapper struct {
-	logger log.Logger
-}
-
-func (jlw *jaegerLogWrapper) Error(msg string) {
-	jlw.logger.Error(msg)
-}
-
-func (jlw *jaegerLogWrapper) Infof(format string, args ...interface{}) {
-	msg := fmt.Sprintf(format, args...)
-	jlw.logger.Info(msg)
-}
diff --git a/pkg/infra/tracing/tracing_test.go b/pkg/infra/tracing/tracing_test.go
deleted file mode 100644
index a6d71cf165..0000000000
--- a/pkg/infra/tracing/tracing_test.go
+++ /dev/null
@@ -1,94 +0,0 @@
-package tracing
-
-import (
-	"github.com/stretchr/testify/assert"
-	"github.com/stretchr/testify/require"
-	"os"
-	"testing"
-)
-
-func TestGroupSplit(t *testing.T) {
-	tests := []struct {
-		input    string
-		expected map[string]string
-	}{
-		{
-			input: "tag1:value1,tag2:value2",
-			expected: map[string]string{
-				"tag1": "value1",
-				"tag2": "value2",
-			},
-		},
-		{
-			input:    "",
-			expected: map[string]string{},
-		},
-		{
-			input:    "tag1",
-			expected: map[string]string{},
-		},
-	}
-
-	for _, test := range tests {
-		tags := splitTagSettings(test.input)
-		for k, v := range test.expected {
-			value, exists := tags[k]
-			assert.Truef(t, exists, "Tag %q not found for input %q", k, test.input)
-			assert.Equalf(t, v, value, "Tag %q has wrong value for input %q", k, test.input)
-		}
-	}
-}
-
-func TestInitJaegerCfg_Default(t *testing.T) {
-	ts := &TracingService{}
-	cfg, err := ts.initJaegerCfg()
-	require.NoError(t, err)
-
-	assert.True(t, cfg.Disabled)
-}
-
-func TestInitJaegerCfg_Enabled(t *testing.T) {
-	ts := &TracingService{enabled: true}
-	cfg, err := ts.initJaegerCfg()
-	require.NoError(t, err)
-
-	assert.False(t, cfg.Disabled)
-	assert.Equal(t, "localhost:6831", cfg.Reporter.LocalAgentHostPort)
-}
-
-func TestInitJaegerCfg_DisabledViaEnv(t *testing.T) {
-	os.Setenv("JAEGER_DISABLED", "true")
-	defer func() {
-		os.Unsetenv("JAEGER_DISABLED")
-	}()
-
-	ts := &TracingService{enabled: true}
-	cfg, err := ts.initJaegerCfg()
-	require.NoError(t, err)
-
-	assert.True(t, cfg.Disabled)
-}
-
-func TestInitJaegerCfg_EnabledViaEnv(t *testing.T) {
-	os.Setenv("JAEGER_DISABLED", "false")
-	defer func() {
-		os.Unsetenv("JAEGER_DISABLED")
-	}()
-
-	ts := &TracingService{enabled: false}
-	cfg, err := ts.initJaegerCfg()
-	require.NoError(t, err)
-
-	assert.False(t, cfg.Disabled)
-}
-
-func TestInitJaegerCfg_InvalidEnvVar(t *testing.T) {
-	os.Setenv("JAEGER_DISABLED", "totallybogus")
-	defer func() {
-		os.Unsetenv("JAEGER_DISABLED")
-	}()
-
-	ts := &TracingService{}
-	_, err := ts.initJaegerCfg()
-	require.EqualError(t, err, "cannot parse env var JAEGER_DISABLED=totallybogus: strconv.ParseBool: parsing \"totallybogus\": invalid syntax")
-}