Skip to content

Commit

Permalink
Tracing: added missing sampler types (#7231)
Browse files Browse the repository at this point in the history
* added missing sampler types

Signed-off-by: Neeraj Nagure <[email protected]>

* added changelog entry

Signed-off-by: Neeraj Nagure <[email protected]>

* fixed changelog entry

Signed-off-by: Neeraj Nagure <[email protected]>

* Fixed changelog entry conflict

Signed-off-by: Neeraj Nagure <[email protected]>

---------

Signed-off-by: Neeraj Nagure <[email protected]>
  • Loading branch information
NeerajNagure authored Apr 5, 2024
1 parent f80fd94 commit 3048d99
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re

### Added

- [#7231](https://github.com/thanos-io/thanos/pull/7231) Tracing: added missing sampler types
- [#7194](https://github.com/thanos-io/thanos/pull/7194) Downsample: retry objstore related errors
- [#7105](https://github.com/thanos-io/thanos/pull/7105) Rule: add flag `--query.enable-x-functions` to allow usage of extended promql functions (xrate, xincrease, xdelta) in loaded rules
- [#6867](https://github.com/thanos-io/thanos/pull/6867) Query UI: Tenant input box added to the Query UI, in order to be able to specify which tenant the query should use.
Expand Down
27 changes: 20 additions & 7 deletions pkg/tracing/otlp/otlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ import (
)

const (
TracingClientGRPC string = "grpc"
TracingClientHTTP string = "http"
AlwaysSample string = "alwayssample"
NeverSample string = "neversample"
RatioBasedSample string = "traceidratiobased"
TracingClientGRPC string = "grpc"
TracingClientHTTP string = "http"
AlwaysSample string = "alwayssample"
NeverSample string = "neversample"
TraceIDRatioBasedSample string = "traceidratiobased"
ParentBasedAlwaysSample string = "parentbasedalwayssample"
ParentBasedNeverSample string = "parentbasedneversample"
ParentBasedTraceIDRatioBasedSample string = "parentbasedtraceidratiobased"
)

// NewOTELTracer returns an OTLP exporter based tracer.
Expand Down Expand Up @@ -106,10 +109,20 @@ func newTraceProvider(ctx context.Context, processor tracesdk.SpanProcessor, log
func getSampler(config Config) (tracesdk.Sampler, error) {
switch strings.ToLower(config.SamplerType) {
case AlwaysSample:
return tracesdk.ParentBased(tracesdk.AlwaysSample()), nil
return tracesdk.AlwaysSample(), nil
case NeverSample:
return tracesdk.NeverSample(), nil
case TraceIDRatioBasedSample:
arg, err := strconv.ParseFloat(config.SamplerParam, 64)
if err != nil {
return tracesdk.TraceIDRatioBased(1.0), err
}
return tracesdk.TraceIDRatioBased(arg), nil
case ParentBasedAlwaysSample:
return tracesdk.ParentBased(tracesdk.AlwaysSample()), nil
case ParentBasedNeverSample:
return tracesdk.ParentBased(tracesdk.NeverSample()), nil
case RatioBasedSample:
case ParentBasedTraceIDRatioBasedSample:
arg, err := strconv.ParseFloat(config.SamplerParam, 64)
if err != nil {
return tracesdk.ParentBased(tracesdk.TraceIDRatioBased(1.0)), err
Expand Down

0 comments on commit 3048d99

Please sign in to comment.