From 40eb3b85b24a8f421c7de2372f2d3358a75b5281 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Mon, 27 Jan 2020 16:57:01 +0100 Subject: [PATCH 1/3] support sampling on Elastic APM tracing fixes thanos-io/thanos#2039 Signed-off-by: Igor Wiedler --- docs/tracing.md | 1 + pkg/tracing/elasticapm/elastic_apm.go | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/tracing.md b/docs/tracing.md index 8ac38948ce..b24d8470be 100644 --- a/docs/tracing.md +++ b/docs/tracing.md @@ -100,6 +100,7 @@ config: service_name: "" service_version: "" service_environment: "" + sample_rate: 1.0 ``` ### Lightstep diff --git a/pkg/tracing/elasticapm/elastic_apm.go b/pkg/tracing/elasticapm/elastic_apm.go index ee618f81be..0452ca1e7b 100644 --- a/pkg/tracing/elasticapm/elastic_apm.go +++ b/pkg/tracing/elasticapm/elastic_apm.go @@ -10,9 +10,10 @@ import ( ) type Config struct { - ServiceName string `yaml:"service_name"` - ServiceVersion string `yaml:"service_version"` - ServiceEnvironment string `yaml:"service_environment"` + ServiceName string `yaml:"service_name"` + ServiceVersion string `yaml:"service_version"` + ServiceEnvironment string `yaml:"service_environment"` + SampleRate float64 `yaml:"sample_rate"` } func NewTracer(conf []byte) (opentracing.Tracer, io.Closer, error) { @@ -28,6 +29,7 @@ func NewTracer(conf []byte) (opentracing.Tracer, io.Closer, error) { if err != nil { return nil, nil, err } + tracer.SetSampler(apm.NewRatioSampler(config.SampleRate)) return apmot.New(apmot.WithTracer(tracer)), tracerCloser{tracer}, nil } From a5924ef93219b3fc9a177a4897bb654ccbec9d55 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Mon, 27 Jan 2020 17:12:51 +0100 Subject: [PATCH 2/3] add CHANGELOG entry Signed-off-by: Igor Wiedler --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dac014e34d..81388ef318 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ We use *breaking* word for marking changes that are not backward compatible (rel - [#1939](https://github.com/thanos-io/thanos/pull/1939) Ruler: Add TLS and authentication support for query endpoints with the `--query.config` and `--query.config-file` CLI flags. See [documentation](docs/components/rule.md/#configuration) for further information. - [#1982](https://github.com/thanos-io/thanos/pull/1982) Ruler: Add support for Alertmanager v2 API endpoints. - #2030 Query: Add `thanos_proxy_store_empty_stream_responses_total` metric for number of empty responses from stores. +- [#2049](https://github.com/thanos-io/thanos/pull/2049) Tracing: Support sampling on Elastic APM with new sample_rate setting. ### Changed From 0c9fa282cd8f06463e070d3c896131ee5adf874a Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Mon, 27 Jan 2020 17:24:08 +0100 Subject: [PATCH 3/3] set sample_rate to default value of 0 in docs Signed-off-by: Igor Wiedler --- docs/tracing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tracing.md b/docs/tracing.md index b24d8470be..84b2e19add 100644 --- a/docs/tracing.md +++ b/docs/tracing.md @@ -100,7 +100,7 @@ config: service_name: "" service_version: "" service_environment: "" - sample_rate: 1.0 + sample_rate: 0 ``` ### Lightstep