Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracing: added missing sampler types #7231

Merged
merged 5 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading