From fd7438b55322145c7abf376362c1e398c4b35531 Mon Sep 17 00:00:00 2001 From: Jared Harper Date: Fri, 3 May 2024 12:06:20 -0700 Subject: [PATCH] various cleanups --- internal/oboe/oboe.go | 211 +++------------------------------ internal/oboe/oboe_test.go | 34 +++--- internal/oboe/settings.go | 167 ++++++++++++++++++++++++++ internal/oboetestutils/oboe.go | 38 ------ internal/sampler/sampler.go | 2 +- 5 files changed, 199 insertions(+), 253 deletions(-) create mode 100644 internal/oboe/settings.go diff --git a/internal/oboe/oboe.go b/internal/oboe/oboe.go index a1c98ed4..2c8325bc 100644 --- a/internal/oboe/oboe.go +++ b/internal/oboe/oboe.go @@ -49,17 +49,17 @@ const ( type Oboe interface { UpdateSetting(sType int32, layer string, flags []byte, value int64, ttl int64, args map[string][]byte) CheckSettingsTimeout() - GetSetting() (*oboeSettings, bool) + GetSetting() (*settings, bool) RemoveSetting() HasDefaultSetting() bool - OboeSampleRequest(continued bool, url string, triggerTrace TriggerTraceMode, swState w3cfmt.SwTraceState) SampleDecision + SampleRequest(continued bool, url string, triggerTrace TriggerTraceMode, swState w3cfmt.SwTraceState) SampleDecision FlushRateCounts() map[string]*metrics.RateCounts } func NewOboe() Oboe { return &oboe{ cfg: &oboeSettingsCfg{ - settings: make(map[oboeSettingKey]*oboeSettings), + settings: make(map[settingKey]*settings), }, } } @@ -72,7 +72,7 @@ var _ Oboe = &oboe{} // Current settings configuration type oboeSettingsCfg struct { - settings map[oboeSettingKey]*oboeSettings + settings map[settingKey]*settings lock sync.RWMutex } @@ -90,37 +90,6 @@ func (o *oboe) FlushRateCounts() map[string]*metrics.RateCounts { return rcs } -type oboeSettings struct { - timestamp time.Time - // the flags which may be modified through merging local settings. - flags settingFlag - // the original flags retrieved from the remote collector. - originalFlags settingFlag - // The sample rate. It could be the original value got from remote server - // or a new value after negotiating with local config - value int - // The sample source after negotiating with local config - source SampleSource - ttl int64 - layer string - TriggerToken []byte - bucket *tokenBucket - triggerTraceRelaxedBucket *tokenBucket - triggerTraceStrictBucket *tokenBucket -} - -func (s *oboeSettings) hasOverrideFlag() bool { - return s.originalFlags&FLAG_OVERRIDE != 0 -} - -func newOboeSettings() *oboeSettings { - return &oboeSettings{ - bucket: &tokenBucket{}, - triggerTraceRelaxedBucket: &tokenBucket{}, - triggerTraceStrictBucket: &tokenBucket{}, - } -} - // token bucket type tokenBucket struct { ratePerSec float64 @@ -142,30 +111,6 @@ func (b *tokenBucket) setRateCap(rate, cap float64) { } } -// The identifying keys for a setting -type oboeSettingKey struct { - sType settingType - layer string -} - -// Global configuration settings -//var globalSettingsCfg = &oboeSettingsCfg{ -// settings: make(map[oboeSettingKey]*oboeSettings), -//} - -// The global token bucket. Trace decisions of all the requests are controlled -// by this single bucket. -// -// The rate and capacity will be initialized by the values fetched from the remote -// server, therefore it's initialized with only the default values. -//var globalTokenBucket = &tokenBucket{} - -// The token bucket exclusively for trigger trace from authenticated clients -//var triggerTraceRelaxedBucket = &tokenBucket{} - -// The token bucket exclusively for trigger trace from unauthenticated clients -//var triggerTraceStrictBucket = &tokenBucket{} - func (b *tokenBucket) count(sampled, hasMetadata, rateLimit bool) bool { b.RequestedInc() @@ -326,27 +271,17 @@ func (tm TriggerTraceMode) Requested() bool { } } -func (o *oboe) OboeSampleRequest(continued bool, url string, triggerTrace TriggerTraceMode, swState w3cfmt.SwTraceState) SampleDecision { - // TODO: ick! - //if usingTestReporter { - // if r, ok := globalReporter.(*TestReporter); ok { - // if !r.UseSettings { - // return SampleDecision{r.ShouldTrace, 0, SAMPLE_SOURCE_NONE, true, ttEmpty, 0, 0, false} // trace tests - // } - // } - //} - - var setting *oboeSettings - var ok bool +func (o *oboe) SampleRequest(continued bool, url string, triggerTrace TriggerTraceMode, swState w3cfmt.SwTraceState) SampleDecision { diceRolled := false - if setting, ok = o.GetSetting(); !ok { + setting, ok := o.GetSetting() + if !ok { return SampleDecision{false, 0, SAMPLE_SOURCE_NONE, false, ttSettingsNotAvailable, 0, 0, diceRolled} } retval := false doRateLimiting := false - sampleRate, flags, source := mergeURLSetting(setting, url) + sampleRate, flags, source := setting.mergeURLSetting(url) // Choose an appropriate bucket bucket := setting.bucket @@ -375,7 +310,7 @@ func (o *oboe) OboeSampleRequest(continued bool, url string, triggerTrace Trigge rsp = ttTriggerTracingDisabled } } - ttCap, ttRate := getTokenBucketSetting(setting, triggerTrace) + ttCap, ttRate := setting.getTokenBucketSetting(triggerTrace) return SampleDecision{ret, -1, SAMPLE_SOURCE_UNSET, flags.Enabled(), rsp, ttRate, ttCap, diceRolled} } @@ -418,7 +353,7 @@ func (o *oboe) OboeSampleRequest(continued bool, url string, triggerTrace Trigge if unsetBucketAndSampleKVs { bucketCap, bucketRate, sampleRate, source = -1, -1, -1, SAMPLE_SOURCE_UNSET } else { - bucketCap, bucketRate = getTokenBucketSetting(setting, ModeTriggerTraceNotPresent) + bucketCap, bucketRate = setting.getTokenBucketSetting(ModeTriggerTraceNotPresent) } return SampleDecision{ @@ -433,24 +368,6 @@ func (o *oboe) OboeSampleRequest(continued bool, url string, triggerTrace Trigge } } -func getTokenBucketSetting(setting *oboeSettings, ttMode TriggerTraceMode) (capacity float64, rate float64) { - var bucket *tokenBucket - - switch ttMode { - case ModeRelaxedTriggerTrace: - bucket = setting.triggerTraceRelaxedBucket - case ModeStrictTriggerTrace: - bucket = setting.triggerTraceStrictBucket - case ModeTriggerTraceNotPresent, ModeInvalidTriggerTrace: - bucket = setting.bucket - default: - log.Warningf("Could not determine token bucket setting for invalid TriggerTraceMode: %#v", ttMode) - return 0, 0 - } - - return bucket.capacity, bucket.ratePerSec -} - func bytesToFloat64(b []byte) (float64, error) { if len(b) != 8 { return -1, fmt.Errorf("invalid length: %d", len(b)) @@ -493,53 +410,6 @@ func ParseInt32(args map[string][]byte, key string, fb int32) int32 { return ret } -// mergeLocalSetting follow the predefined precedence to decide which one to -// pick from: either the local configs or the remote ones, or the combination. -// -// Note: This function modifies the argument in place. -func mergeLocalSetting(remote *oboeSettings) *oboeSettings { - if remote.hasOverrideFlag() && config.SamplingConfigured() { - // Choose the lower sample rate and merge the flags - if remote.value > config.GetSampleRate() { - remote.value = config.GetSampleRate() - remote.source = SAMPLE_SOURCE_FILE - } - remote.flags &= NewTracingMode(config.GetTracingMode()).toFlags() - } else if config.SamplingConfigured() { - // Use local sample rate and tracing mode config - remote.value = config.GetSampleRate() - remote.flags = NewTracingMode(config.GetTracingMode()).toFlags() - remote.source = SAMPLE_SOURCE_FILE - } - - if !config.GetTriggerTrace() { - remote.flags = remote.flags &^ (1 << FlagTriggerTraceOffset) - } - return remote -} - -// mergeURLSetting merges the service level setting (merged from remote and local -// settings) and the per-URL sampling flags, if any. -func mergeURLSetting(setting *oboeSettings, url string) (int, settingFlag, SampleSource) { - if url == "" { - return setting.value, setting.flags, setting.source - } - - urlTracingMode := urls.GetTracingMode(url) - if urlTracingMode.isUnknown() { - return setting.value, setting.flags, setting.source - } - - flags := urlTracingMode.toFlags() - source := SAMPLE_SOURCE_FILE - - if setting.hasOverrideFlag() { - flags &= setting.originalFlags - } - - return setting.value, flags, source -} - func adjustSampleRate(rate int64) int { if rate < 0 { log.Debugf("Invalid sample rate: %d", rate) @@ -580,7 +450,7 @@ func (o *oboe) UpdateSetting(sType int32, layer string, flags []byte, value int6 merged := mergeLocalSetting(ns) - key := oboeSettingKey{ + key := settingKey{ sType: settingType(sType), layer: layer, } @@ -608,12 +478,12 @@ func (sc *oboeSettingsCfg) checkSettingsTimeout() { } } -func (o *oboe) GetSetting() (*oboeSettings, bool) { +func (o *oboe) GetSetting() (*settings, bool) { o.cfg.lock.RLock() defer o.cfg.lock.RUnlock() // for now only look up the default settings - key := oboeSettingKey{ + key := settingKey{ sType: TYPE_DEFAULT, layer: "", } @@ -628,7 +498,7 @@ func (o *oboe) RemoveSetting() { o.cfg.lock.Lock() defer o.cfg.lock.Unlock() - key := oboeSettingKey{ + key := settingKey{ sType: TYPE_DEFAULT, layer: "", } @@ -714,56 +584,3 @@ func (tm TracingMode) ToString() string { return string(config.UnknownTracingMode) } } - -type settingType int -type settingFlag uint16 - -// setting types -const ( - TYPE_DEFAULT settingType = iota // default setting which serves as a fallback if no other settings found - TYPE_LAYER // layer specific settings -) - -// setting flags offset -const ( - FlagInvalidOffset = iota - FlagOverrideOffset - FlagSampleStartOffset - FlagSampleThroughOffset - FlagSampleThroughAlwaysOffset - FlagTriggerTraceOffset -) - -// setting flags -const ( - FLAG_OK settingFlag = 0x0 - FLAG_INVALID settingFlag = 1 << FlagInvalidOffset - FLAG_OVERRIDE settingFlag = 1 << FlagOverrideOffset - FLAG_SAMPLE_START settingFlag = 1 << FlagSampleStartOffset - FLAG_SAMPLE_THROUGH settingFlag = 1 << FlagSampleThroughOffset - FLAG_SAMPLE_THROUGH_ALWAYS settingFlag = 1 << FlagSampleThroughAlwaysOffset - FLAG_TRIGGER_TRACE settingFlag = 1 << FlagTriggerTraceOffset -) - -// Enabled returns if the trace is enabled or not. -func (f settingFlag) Enabled() bool { - return f&(FLAG_SAMPLE_START|FLAG_SAMPLE_THROUGH_ALWAYS) != 0 -} - -// TriggerTraceEnabled returns if the trigger trace is enabled -func (f settingFlag) TriggerTraceEnabled() bool { - return f&FLAG_TRIGGER_TRACE != 0 -} - -func (st settingType) toSampleSource() SampleSource { - var source SampleSource - switch st { - case TYPE_DEFAULT: - source = SAMPLE_SOURCE_DEFAULT - case TYPE_LAYER: - source = SAMPLE_SOURCE_LAYER - default: - source = SAMPLE_SOURCE_NONE - } - return source -} diff --git a/internal/oboe/oboe_test.go b/internal/oboe/oboe_test.go index a484b719..39608c99 100644 --- a/internal/oboe/oboe_test.go +++ b/internal/oboe/oboe_test.go @@ -58,7 +58,7 @@ var ( func TestOboeSampleRequestSettingsUnavailable(t *testing.T) { ttMode := ModeTriggerTraceNotPresent o := NewOboe() - dec := o.OboeSampleRequest(false, "url", ttMode, sampledSwState) + dec := o.SampleRequest(false, "url", ttMode, sampledSwState) expected := SampleDecision{ xTraceOptsRsp: "settings-not-available", } @@ -69,7 +69,7 @@ func TestOboeSampleRequestSettingsDisabled(t *testing.T) { ttMode := ModeRelaxedTriggerTrace o := NewOboe() oboetestutils.AddDisabled(o) - dec := o.OboeSampleRequest(false, "url", ttMode, sampledSwState) + dec := o.SampleRequest(false, "url", ttMode, sampledSwState) expected := SampleDecision{ trace: false, rate: -1, @@ -86,7 +86,7 @@ func TestOboeSampleRequest(t *testing.T) { ttMode := ModeTriggerTraceNotPresent o := NewOboe() oboetestutils.AddDefaultSetting(o) - dec := o.OboeSampleRequest(false, "url", ttMode, sampledSwState) + dec := o.SampleRequest(false, "url", ttMode, sampledSwState) expected := SampleDecision{ trace: true, rate: 1000000, @@ -104,7 +104,7 @@ func TestOboeSampleRequestContinuedUnsampledSwState(t *testing.T) { ttMode := ModeTriggerTraceNotPresent o := NewOboe() oboetestutils.AddDefaultSetting(o) - dec := o.OboeSampleRequest(true, "url", ttMode, unsampledSwState) + dec := o.SampleRequest(true, "url", ttMode, unsampledSwState) expected := SampleDecision{ trace: false, rate: 1000000, @@ -122,7 +122,7 @@ func TestOboeSampleRequestNoTTGivenButReporterIsTTOnly(t *testing.T) { ttMode := ModeTriggerTraceNotPresent o := NewOboe() oboetestutils.AddTriggerTraceOnly(o) - dec := o.OboeSampleRequest(false, "url", ttMode, sampledSwState) + dec := o.SampleRequest(false, "url", ttMode, sampledSwState) expected := SampleDecision{ trace: false, rate: 0, @@ -140,7 +140,7 @@ func TestOboeSampleRequestUnsampledSwState(t *testing.T) { ttMode := ModeTriggerTraceNotPresent o := NewOboe() oboetestutils.AddDefaultSetting(o) - dec := o.OboeSampleRequest(false, "url", ttMode, unsampledSwState) + dec := o.SampleRequest(false, "url", ttMode, unsampledSwState) expected := SampleDecision{ trace: true, rate: 1000000, @@ -158,7 +158,7 @@ func TestOboeSampleRequestThrough(t *testing.T) { ttMode := ModeTriggerTraceNotPresent o := NewOboe() oboetestutils.AddSampleThrough(o) - dec := o.OboeSampleRequest(true, "url", ttMode, sampledSwState) + dec := o.SampleRequest(true, "url", ttMode, sampledSwState) expected := SampleDecision{ trace: true, rate: 1000000, @@ -176,7 +176,7 @@ func TestOboeSampleRequestThroughUnsampled(t *testing.T) { ttMode := ModeTriggerTraceNotPresent o := NewOboe() oboetestutils.AddSampleThrough(o) - dec := o.OboeSampleRequest(true, "url", ttMode, unsampledSwState) + dec := o.SampleRequest(true, "url", ttMode, unsampledSwState) expected := SampleDecision{ trace: false, rate: 1000000, @@ -196,7 +196,7 @@ func TestOboeSampleRequestRelaxedTT(t *testing.T) { ttMode := ModeRelaxedTriggerTrace o := NewOboe() oboetestutils.AddDefaultSetting(o) - dec := o.OboeSampleRequest(false, "url", ttMode, sampledSwState) + dec := o.SampleRequest(false, "url", ttMode, sampledSwState) expected := SampleDecision{ trace: true, rate: -1, @@ -214,7 +214,7 @@ func TestOboeSampleRequestStrictTT(t *testing.T) { ttMode := ModeStrictTriggerTrace o := NewOboe() oboetestutils.AddDefaultSetting(o) - dec := o.OboeSampleRequest(false, "url", ttMode, sampledSwState) + dec := o.SampleRequest(false, "url", ttMode, sampledSwState) expected := SampleDecision{ trace: true, rate: -1, @@ -232,7 +232,7 @@ func TestOboeSampleRequestRelaxedTTDisabled(t *testing.T) { ttMode := ModeRelaxedTriggerTrace o := NewOboe() oboetestutils.AddNoTriggerTrace(o) - dec := o.OboeSampleRequest(false, "url", ttMode, sampledSwState) + dec := o.SampleRequest(false, "url", ttMode, sampledSwState) expected := SampleDecision{ trace: false, rate: -1, @@ -250,7 +250,7 @@ func TestOboeSampleRequestStrictTTDisabled(t *testing.T) { ttMode := ModeStrictTriggerTrace o := NewOboe() oboetestutils.AddNoTriggerTrace(o) - dec := o.OboeSampleRequest(false, "url", ttMode, sampledSwState) + dec := o.SampleRequest(false, "url", ttMode, sampledSwState) expected := SampleDecision{ trace: false, rate: -1, @@ -268,7 +268,7 @@ func TestOboeSampleRequestRelaxedTTLimited(t *testing.T) { ttMode := ModeRelaxedTriggerTrace o := NewOboe() oboetestutils.AddLimitedTriggerTrace(o) - dec := o.OboeSampleRequest(false, "url", ttMode, sampledSwState) + dec := o.SampleRequest(false, "url", ttMode, sampledSwState) // We expect the first TT to go through expected := SampleDecision{ trace: true, @@ -281,7 +281,7 @@ func TestOboeSampleRequestRelaxedTTLimited(t *testing.T) { diceRolled: false, } require.Equal(t, expected, dec) - dec = o.OboeSampleRequest(false, "url", ttMode, sampledSwState) + dec = o.SampleRequest(false, "url", ttMode, sampledSwState) expected = SampleDecision{ trace: false, rate: -1, @@ -299,7 +299,7 @@ func TestOboeSampleRequestInvalidTT(t *testing.T) { ttMode := ModeInvalidTriggerTrace o := NewOboe() oboetestutils.AddDefaultSetting(o) - dec := o.OboeSampleRequest(false, "url", ttMode, sampledSwState) + dec := o.SampleRequest(false, "url", ttMode, sampledSwState) expected := SampleDecision{ trace: false, rate: -1, @@ -317,7 +317,7 @@ func TestGetTokenBucketSetting(t *testing.T) { main := &tokenBucket{ratePerSec: 1, capacity: 2} relaxed := &tokenBucket{ratePerSec: 3, capacity: 4} strict := &tokenBucket{ratePerSec: 5, capacity: 6} - setting := &oboeSettings{ + setting := &settings{ bucket: main, triggerTraceRelaxedBucket: relaxed, triggerTraceStrictBucket: strict, @@ -334,7 +334,7 @@ func TestGetTokenBucketSetting(t *testing.T) { {99, nil}, } for _, scen := range scenarios { - capacity, rate := getTokenBucketSetting(setting, scen.mode) + capacity, rate := setting.getTokenBucketSetting(scen.mode) if scen.bucket == nil { require.Equal(t, float64(0), capacity) require.Equal(t, float64(0), rate) diff --git a/internal/oboe/settings.go b/internal/oboe/settings.go new file mode 100644 index 00000000..dafc9118 --- /dev/null +++ b/internal/oboe/settings.go @@ -0,0 +1,167 @@ +package oboe + +import ( + "github.com/solarwinds/apm-go/internal/config" + "github.com/solarwinds/apm-go/internal/log" + "time" +) + +type settings struct { + timestamp time.Time + // the flags which may be modified through merging local settings. + flags settingFlag + // the original flags retrieved from the remote collector. + originalFlags settingFlag + // The sample rate. It could be the original value got from remote server + // or a new value after negotiating with local config + value int + // The sample source after negotiating with local config + source SampleSource + ttl int64 + layer string + TriggerToken []byte + bucket *tokenBucket + triggerTraceRelaxedBucket *tokenBucket + triggerTraceStrictBucket *tokenBucket +} + +func (s *settings) hasOverrideFlag() bool { + return s.originalFlags&FLAG_OVERRIDE != 0 +} +func newOboeSettings() *settings { + return &settings{ + // The global token bucket. Trace decisions of all the requests are controlled + // by this single bucket. + // + // The rate and capacity will be initialized by the values fetched from the remote + // server, therefore it's initialized with only the default values. + bucket: &tokenBucket{}, + // The token bucket exclusively for trigger trace from authenticated clients + triggerTraceRelaxedBucket: &tokenBucket{}, + // The token bucket exclusively for trigger trace from unauthenticated clients + triggerTraceStrictBucket: &tokenBucket{}, + } +} + +// mergeLocalSetting follow the predefined precedence to decide which one to +// pick from: either the local configs or the remote ones, or the combination. +// +// Note: This function modifies the argument in place. +func mergeLocalSetting(remote *settings) *settings { + if remote.hasOverrideFlag() && config.SamplingConfigured() { + // Choose the lower sample rate and merge the flags + if remote.value > config.GetSampleRate() { + remote.value = config.GetSampleRate() + remote.source = SAMPLE_SOURCE_FILE + } + remote.flags &= NewTracingMode(config.GetTracingMode()).toFlags() + } else if config.SamplingConfigured() { + // Use local sample rate and tracing mode config + remote.value = config.GetSampleRate() + remote.flags = NewTracingMode(config.GetTracingMode()).toFlags() + remote.source = SAMPLE_SOURCE_FILE + } + + if !config.GetTriggerTrace() { + remote.flags = remote.flags &^ (1 << FlagTriggerTraceOffset) + } + return remote +} + +// mergeURLSetting merges the service level setting (merged from remote and local +// settings) and the per-URL sampling flags, if any. +func (s *settings) mergeURLSetting(url string) (int, settingFlag, SampleSource) { + if url == "" { + return s.value, s.flags, s.source + } + + urlTracingMode := urls.GetTracingMode(url) + if urlTracingMode.isUnknown() { + return s.value, s.flags, s.source + } + + flags := urlTracingMode.toFlags() + source := SAMPLE_SOURCE_FILE + + if s.hasOverrideFlag() { + flags &= s.originalFlags + } + + return s.value, flags, source +} + +func (s *settings) getTokenBucketSetting(ttMode TriggerTraceMode) (capacity float64, rate float64) { + var bucket *tokenBucket + + switch ttMode { + case ModeRelaxedTriggerTrace: + bucket = s.triggerTraceRelaxedBucket + case ModeStrictTriggerTrace: + bucket = s.triggerTraceStrictBucket + case ModeTriggerTraceNotPresent, ModeInvalidTriggerTrace: + bucket = s.bucket + default: + log.Warningf("Could not determine token bucket setting for invalid TriggerTraceMode: %#v", ttMode) + return 0, 0 + } + + return bucket.capacity, bucket.ratePerSec +} + +// The identifying keys for a setting +type settingKey struct { + sType settingType + layer string +} +type settingType int +type settingFlag uint16 + +// setting types +const ( + TYPE_DEFAULT settingType = iota // default setting which serves as a fallback if no other settings found + TYPE_LAYER // layer specific settings +) + +// setting flags offset +const ( + FlagInvalidOffset = iota + FlagOverrideOffset + FlagSampleStartOffset + FlagSampleThroughOffset + FlagSampleThroughAlwaysOffset + FlagTriggerTraceOffset +) + +// setting flags +const ( + FLAG_OK settingFlag = 0x0 + FLAG_INVALID settingFlag = 1 << FlagInvalidOffset + FLAG_OVERRIDE settingFlag = 1 << FlagOverrideOffset + FLAG_SAMPLE_START settingFlag = 1 << FlagSampleStartOffset + FLAG_SAMPLE_THROUGH settingFlag = 1 << FlagSampleThroughOffset + FLAG_SAMPLE_THROUGH_ALWAYS settingFlag = 1 << FlagSampleThroughAlwaysOffset + FLAG_TRIGGER_TRACE settingFlag = 1 << FlagTriggerTraceOffset +) + +// Enabled returns if the trace is enabled or not. +func (f settingFlag) Enabled() bool { + return f&(FLAG_SAMPLE_START|FLAG_SAMPLE_THROUGH_ALWAYS) != 0 +} + +// TriggerTraceEnabled returns if the trigger trace is enabled +func (f settingFlag) TriggerTraceEnabled() bool { + return f&FLAG_TRIGGER_TRACE != 0 +} + +func (st settingType) toSampleSource() SampleSource { + var source SampleSource + switch st { + case TYPE_DEFAULT: + source = SAMPLE_SOURCE_DEFAULT + case TYPE_LAYER: + source = SAMPLE_SOURCE_LAYER + default: + source = SAMPLE_SOURCE_NONE + } + return source +} diff --git a/internal/oboetestutils/oboe.go b/internal/oboetestutils/oboe.go index cd173063..3bd4a5cd 100644 --- a/internal/oboetestutils/oboe.go +++ b/internal/oboetestutils/oboe.go @@ -132,41 +132,3 @@ func AddDisabled(o SettingUpdater) { []byte(""), 0, 120, argsToMap(0, 0, 1, 1, 1, 1, -1, -1, []byte(TestToken))) } - -// Setting types -const ( - DefaultST = iota - NoTriggerTraceST - TriggerTraceOnlyST - RelaxedTriggerTraceOnlyST - StrictTriggerTraceOnlyST - LimitedTriggerTraceST - SampleThroughST - DisabledST - NoSettingST -) - -//func UpdateSetting(settingType int) { -// switch settingType { -// case DefaultST: -// addDefaultSetting() -// case NoTriggerTraceST: -// addNoTriggerTrace() -// case TriggerTraceOnlyST: -// addTriggerTraceOnly() -// case RelaxedTriggerTraceOnlyST: -// addRelaxedTriggerTraceOnly() -// case StrictTriggerTraceOnlyST: -// addStrictTriggerTraceOnly() -// case LimitedTriggerTraceST: -// addLimitedTriggerTrace() -// case SampleThroughST: -// addSampleThrough() -// case DisabledST: -// addDisabled() -// case NoSettingST: -// // Nothing to do -// default: -// panic("No such setting type.") -// } -//} diff --git a/internal/sampler/sampler.go b/internal/sampler/sampler.go index 65670767..b318988d 100644 --- a/internal/sampler/sampler.go +++ b/internal/sampler/sampler.go @@ -99,7 +99,7 @@ func (s sampler) ShouldSample(params sdktrace.SamplingParameters) sdktrace.Sampl ttMode := getTtMode(xto) // If parent context is not valid, swState will also not be valid swState := w3cfmt.GetSwTraceState(psc) - traceDecision := s.oboe.OboeSampleRequest(swState.IsValid(), url, ttMode, swState) + traceDecision := s.oboe.SampleRequest(swState.IsValid(), url, ttMode, swState) var decision sdktrace.SamplingDecision if !traceDecision.Enabled() { decision = sdktrace.Drop