From f37a595f684cc9bcd5530eff3b04e5f496438055 Mon Sep 17 00:00:00 2001 From: bergquist Date: Fri, 15 Sep 2017 09:27:47 +0200 Subject: [PATCH] make samplerconfig.param configurable --- conf/defaults.ini | 10 +++++++++- conf/sample.ini | 8 ++++++++ pkg/tracing/tracing.go | 18 ++++++++++-------- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/conf/defaults.ini b/conf/defaults.ini index f2b177079d8..5eb3c358f44 100644 --- a/conf/defaults.ini +++ b/conf/defaults.ini @@ -457,7 +457,15 @@ url = https://grafana.com # jaeger destination (ex localhost:6831) address = # tag that will always be included in when creating new spans. ex (tag1:value1,tag2:value2) -always_included_tag = +always_included_tag = +# jaeger samplerconfig param +# for "const" sampler, 0 or 1 for always false/true respectively +# for "probabilistic" sampler, a probability between 0 and 1 +# for "rateLimiting" sampler, the number of spans per second +# for "remote" sampler, param is the same as for "probabilistic" +# and indicates the initial sampling rate before the actual one +# is received from the mothership +sampler_param = 1 #################################### External Image Storage ############## [external_image_storage] diff --git a/conf/sample.ini b/conf/sample.ini index 582eaad55b4..e8394631a5c 100644 --- a/conf/sample.ini +++ b/conf/sample.ini @@ -397,6 +397,14 @@ ;address = localhost:6831 # Tag that will always be included in when creating new spans. ex (tag1:value1,tag2:value2) ;always_included_tag = tag1:value1 +# jaeger samplerconfig param +# for "const" sampler, 0 or 1 for always false/true respectively +# for "probabilistic" sampler, a probability between 0 and 1 +# for "rateLimiting" sampler, the number of spans per second +# for "remote" sampler, param is the same as for "probabilistic" +# and indicates the initial sampling rate before the actual one +# is received from the mothership +;sampler_param = 1 #################################### Grafana.com integration ########################## # Url used to to import dashboards directly from Grafana.com diff --git a/pkg/tracing/tracing.go b/pkg/tracing/tracing.go index b73cbc15b24..cd92a08ebdf 100644 --- a/pkg/tracing/tracing.go +++ b/pkg/tracing/tracing.go @@ -16,13 +16,14 @@ import ( ) var ( - logger log.Logger = log.New("tracing") - customTags map[string]string = map[string]string{} + logger log.Logger = log.New("tracing") ) type TracingSettings struct { - Enabled bool - Address string + Enabled bool + Address string + CustomTags map[string]string + SamplerParam float64 } func Init(file *ini.File) (io.Closer, error) { @@ -43,7 +44,8 @@ func parseSettings(file *ini.File) *TracingSettings { settings.Enabled = true } - customTags = splitTagSettings(section.Key("always_included_tag").MustString("")) + settings.CustomTags = splitTagSettings(section.Key("always_included_tag").MustString("")) + settings.SamplerParam = section.Key("sampler_param").MustFloat64(1) return settings } @@ -55,9 +57,9 @@ func internalInit(settings *TracingSettings) (io.Closer, error) { cfg := jaegercfg.Configuration{ Disabled: !settings.Enabled, - Sampler: &jaegercfg.SamplerConfig{ + Sampler: &jaegercfg.SamplerConfig{ //we currently only support SamplerConfig. Open an issue if you need another. Type: jaeger.SamplerTypeConst, - Param: 1, + Param: settings.SamplerParam, }, Reporter: &jaegercfg.ReporterConfig{ LogSpans: false, @@ -70,7 +72,7 @@ func internalInit(settings *TracingSettings) (io.Closer, error) { options := []jaegercfg.Option{} options = append(options, jaegercfg.Logger(jLogger)) - for tag, value := range customTags { + for tag, value := range settings.CustomTags { options = append(options, jaegercfg.Tag(tag, value)) }