mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
make it possible to configure sampler type
This commit is contained in:
parent
861843f4ca
commit
bcf784375b
@ -458,6 +458,8 @@ url = https://grafana.com
|
|||||||
address =
|
address =
|
||||||
# tag that will always be included in when creating new spans. ex (tag1:value1,tag2:value2)
|
# tag that will always be included in when creating new spans. ex (tag1:value1,tag2:value2)
|
||||||
always_included_tag =
|
always_included_tag =
|
||||||
|
# Type specifies the type of the sampler: const, probabilistic, rateLimiting, or remote
|
||||||
|
sampler_type = const
|
||||||
# jaeger samplerconfig param
|
# jaeger samplerconfig param
|
||||||
# for "const" sampler, 0 or 1 for always false/true respectively
|
# for "const" sampler, 0 or 1 for always false/true respectively
|
||||||
# for "probabilistic" sampler, a probability between 0 and 1
|
# for "probabilistic" sampler, a probability between 0 and 1
|
||||||
|
@ -397,6 +397,8 @@
|
|||||||
;address = localhost:6831
|
;address = localhost:6831
|
||||||
# Tag that will always be included in when creating new spans. ex (tag1:value1,tag2:value2)
|
# Tag that will always be included in when creating new spans. ex (tag1:value1,tag2:value2)
|
||||||
;always_included_tag = tag1:value1
|
;always_included_tag = tag1:value1
|
||||||
|
# Type specifies the type of the sampler: const, probabilistic, rateLimiting, or remote
|
||||||
|
;sampler_type = const
|
||||||
# jaeger samplerconfig param
|
# jaeger samplerconfig param
|
||||||
# for "const" sampler, 0 or 1 for always false/true respectively
|
# for "const" sampler, 0 or 1 for always false/true respectively
|
||||||
# for "probabilistic" sampler, a probability between 0 and 1
|
# for "probabilistic" sampler, a probability between 0 and 1
|
||||||
|
@ -2,14 +2,12 @@ package tracing
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/log"
|
"github.com/grafana/grafana/pkg/log"
|
||||||
"github.com/grafana/grafana/pkg/setting"
|
"github.com/grafana/grafana/pkg/setting"
|
||||||
|
|
||||||
opentracing "github.com/opentracing/opentracing-go"
|
opentracing "github.com/opentracing/opentracing-go"
|
||||||
jaeger "github.com/uber/jaeger-client-go"
|
|
||||||
jaegercfg "github.com/uber/jaeger-client-go/config"
|
jaegercfg "github.com/uber/jaeger-client-go/config"
|
||||||
ini "gopkg.in/ini.v1"
|
ini "gopkg.in/ini.v1"
|
||||||
)
|
)
|
||||||
@ -22,6 +20,7 @@ type TracingSettings struct {
|
|||||||
Enabled bool
|
Enabled bool
|
||||||
Address string
|
Address string
|
||||||
CustomTags map[string]string
|
CustomTags map[string]string
|
||||||
|
SamplerType string
|
||||||
SamplerParam float64
|
SamplerParam float64
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,6 +43,7 @@ func parseSettings(file *ini.File) *TracingSettings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
settings.CustomTags = splitTagSettings(section.Key("always_included_tag").MustString(""))
|
settings.CustomTags = splitTagSettings(section.Key("always_included_tag").MustString(""))
|
||||||
|
settings.SamplerType = section.Key("sampler_type").MustString("")
|
||||||
settings.SamplerParam = section.Key("sampler_param").MustFloat64(1)
|
settings.SamplerParam = section.Key("sampler_param").MustFloat64(1)
|
||||||
|
|
||||||
return settings
|
return settings
|
||||||
@ -51,13 +51,13 @@ func parseSettings(file *ini.File) *TracingSettings {
|
|||||||
|
|
||||||
func internalInit(settings *TracingSettings) (io.Closer, error) {
|
func internalInit(settings *TracingSettings) (io.Closer, error) {
|
||||||
if !settings.Enabled {
|
if !settings.Enabled {
|
||||||
return ioutil.NopCloser(nil), nil
|
return &nullCloser{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg := jaegercfg.Configuration{
|
cfg := jaegercfg.Configuration{
|
||||||
Disabled: !settings.Enabled,
|
Disabled: !settings.Enabled,
|
||||||
Sampler: &jaegercfg.SamplerConfig{ //we currently only support SamplerConfig. Open an issue if you need another.
|
Sampler: &jaegercfg.SamplerConfig{
|
||||||
Type: jaeger.SamplerTypeConst,
|
Type: settings.SamplerType,
|
||||||
Param: settings.SamplerParam,
|
Param: settings.SamplerParam,
|
||||||
},
|
},
|
||||||
Reporter: &jaegercfg.ReporterConfig{
|
Reporter: &jaegercfg.ReporterConfig{
|
||||||
@ -110,3 +110,7 @@ func (jlw *jaegerLogWrapper) Error(msg string) {
|
|||||||
func (jlw *jaegerLogWrapper) Infof(msg string, args ...interface{}) {
|
func (jlw *jaegerLogWrapper) Infof(msg string, args ...interface{}) {
|
||||||
jlw.logger.Info(msg, args)
|
jlw.logger.Info(msg, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type nullCloser struct{}
|
||||||
|
|
||||||
|
func (*nullCloser) Close() error { return nil }
|
||||||
|
Loading…
Reference in New Issue
Block a user