Skip to content

Commit

Permalink
feat: MaxKeys fixes (#710)
Browse files Browse the repository at this point in the history
Depends on #709 

## Which problem is this PR solving?

- The MaxKeys value is supported in most samplers, but it wasn't always
included in the config
- It defaulted to 0 which means "no max" -- Honeycomb CAs agree this is
not a useful setting.

## Short description of the changes

- Support MaxKeys in all dynamic samplers
- 0 now means 500
  • Loading branch information
kentquirk authored Jun 9, 2023
1 parent e578209 commit 62f96ee
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 5 deletions.
7 changes: 6 additions & 1 deletion sample/dynamic.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type DynamicSampler struct {

sampleRate int64
clearFrequency config.Duration
maxKeys int

key *traceKey

Expand All @@ -34,12 +35,16 @@ func (d *DynamicSampler) Start() error {
}
d.clearFrequency = d.Config.ClearFrequency
d.key = newTraceKey(d.Config.FieldList, d.Config.UseTraceLength)
d.maxKeys = d.Config.MaxKeys
if d.maxKeys == 0 {
d.maxKeys = 500
}

// spin up the actual dynamic sampler
d.dynsampler = &dynsampler.AvgSampleRate{
GoalSampleRate: int(d.sampleRate),
ClearFrequencyDuration: time.Duration(d.clearFrequency),
MaxKeys: d.Config.MaxKeys,
MaxKeys: d.maxKeys,
}
d.dynsampler.Start()

Expand Down
5 changes: 4 additions & 1 deletion sample/dynamic_ema.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ func (d *EMADynamicSampler) Start() error {
d.ageOutValue = d.Config.AgeOutValue
d.burstMultiple = d.Config.BurstMultiple
d.burstDetectionDelay = d.Config.BurstDetectionDelay
d.maxKeys = d.Config.MaxKeys
d.key = newTraceKey(d.Config.FieldList, d.Config.UseTraceLength)
d.maxKeys = d.Config.MaxKeys
if d.maxKeys == 0 {
d.maxKeys = 500
}

// spin up the actual dynamic sampler
d.dynsampler = &dynsampler.EMASampleRate{
Expand Down
5 changes: 4 additions & 1 deletion sample/ema_throughput.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ func (d *EMAThroughputSampler) Start() error {
d.ageOutValue = d.Config.AgeOutValue
d.burstMultiple = d.Config.BurstMultiple
d.burstDetectionDelay = d.Config.BurstDetectionDelay
d.maxKeys = d.Config.MaxKeys
d.key = newTraceKey(d.Config.FieldList, d.Config.UseTraceLength)
d.maxKeys = d.Config.MaxKeys
if d.maxKeys == 0 {
d.maxKeys = 500
}

// spin up the actual dynamic sampler
d.dynsampler = &dynsampler.EMAThroughput{
Expand Down
6 changes: 6 additions & 0 deletions sample/totalthroughput.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type TotalThroughputSampler struct {

goalThroughputPerSec int64
clearFrequency config.Duration
maxKeys int

key *traceKey

Expand All @@ -38,11 +39,16 @@ func (d *TotalThroughputSampler) Start() error {
}
d.clearFrequency = d.Config.ClearFrequency
d.key = newTraceKey(d.Config.FieldList, d.Config.UseTraceLength)
d.maxKeys = d.Config.MaxKeys
if d.maxKeys == 0 {
d.maxKeys = 500
}

// spin up the actual dynamic sampler
d.dynsampler = &dynsampler.TotalThroughput{
GoalThroughputPerSec: int(d.goalThroughputPerSec),
ClearFrequencyDuration: time.Duration(d.clearFrequency),
MaxKeys: d.maxKeys,
}
d.dynsampler.Start()

Expand Down
5 changes: 4 additions & 1 deletion sample/windowed_throughput.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ func (d *WindowedThroughputSampler) Start() error {
d.goalthroughputpersec = d.Config.GoalThroughputPerSec
d.updatefrequency = d.Config.UpdateFrequency
d.lookbackfrequency = d.Config.LookbackFrequency
d.maxKeys = d.Config.MaxKeys
d.key = newTraceKey(d.Config.FieldList, d.Config.UseTraceLength)
d.maxKeys = d.Config.MaxKeys
if d.maxKeys == 0 {
d.maxKeys = 500
}

// spin up the actual dynamic sampler
d.dynsampler = &dynsampler.WindowedThroughput{
Expand Down
2 changes: 1 addition & 1 deletion tools/convert/rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ Type: `string`


---
## Samplers:
## Samplers:

Samplers is a mapping of targets to samplers. Each target is a
Honeycomb environment (or, for classic keys, a dataset). The value is
Expand Down

0 comments on commit 62f96ee

Please sign in to comment.