Skip to content

Commit

Permalink
tracing: Support sampling on Elastic APM (#2049)
Browse files Browse the repository at this point in the history
* support sampling on Elastic APM tracing

fixes #2039

Signed-off-by: Igor Wiedler <iwiedler@gitlab.com>

* add CHANGELOG entry

Signed-off-by: Igor Wiedler <iwiedler@gitlab.com>

* set sample_rate to default value of 0 in docs

Signed-off-by: Igor Wiedler <iwiedler@gitlab.com>
  • Loading branch information
igorwwwwwwwwwwwwwwwwwwww authored and bwplotka committed Jan 27, 2020
1 parent 84b14c2 commit 4a23b36
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions docs/tracing.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ config:
service_name: ""
service_version: ""
service_environment: ""
sample_rate: 0
```

### Lightstep
Expand Down
8 changes: 5 additions & 3 deletions pkg/tracing/elasticapm/elastic_apm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
}

Expand Down

0 comments on commit 4a23b36

Please sign in to comment.