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

Better bundle config and error management #111

Merged

Conversation

james-bebbington
Copy link
Contributor

@james-bebbington james-bebbington commented Oct 28, 2020

Changes:

  • Allow BundleByteThreshold & BundleByteLimit to be configured
  • Set default BundleByteLimit to unlimited (was 50KB, or 1KB * bundle count threshold)
  • Log oversized item errors separately to buffer full errors

Tests:

  • Change the cloudtrace_test file so it runs in the trace package
  • Add a test for oversized errors

const defaultBundleDelayThreshold = 2 * time.Second
const defaultBundleCountThreshold = 50
const bundleByteThresholdMultiplier = 300
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you remember what was the reason for these multipliers?
At the very least threshold must always be less or equal to the limit, I suppose? Do we need to validate this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure. I believe Steven did some benchmarking to determine what values worked best, so I am keen to leave these defaults that are probably better tuned for our use case than the bundler library defaults.

I don't know why he used multipliers for bundleByteThreshold / bundleByteLimit though. I just changed these to be more explicit (and removed the bundle byte limit).

exporter/trace/trace.go Outdated Show resolved Hide resolved
b.BundleByteThreshold = b.BundleCountThreshold * bundleByteThresholdMultiplier
b.BundleByteLimit = b.BundleCountThreshold * bundleByteLimitMultiplier

if o.BundleByteThreshold > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't block this PR, but should we return errors for invalid configuration instead of silently using the default?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should chat about that. I think for something like it we should do our best to ignore config errors and limp along not making your app worse.

However, this would be an undiscoverable config error, which should be fixed in some fashion...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could just pass these parameters as is to bundler.NewBundler and let it handle zero values and other validation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't look the bundler library does any validation of its own. I think in all their use cases, negative values will behave the same as zero which is arguably an idiomatic way to handle things in Go, e.g. They use DelayThreshold in time.AfterFunc which ends up hitting this condition in the Go source: https://github.com/golang/go/blob/5f3354d1bf2e6a61e4b9e1e31ee04b99dfe7de35/src/time/sleep.go#L29

Still, I'd be happy to make this return errors instead, but would do so in a follow up PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe that makes more sense to be something that is done by the code that reads config, e.g. in the Collector

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for not responding sooner. I think the important part here is from a user perspective, there is a correctable notification of failures and values aren't silently converted in a way that's confusing.

Likely that means work in whatever reads the config and passes to this function.

b.BundleByteThreshold = b.BundleCountThreshold * bundleByteThresholdMultiplier
b.BundleByteLimit = b.BundleCountThreshold * bundleByteLimitMultiplier

if o.BundleByteThreshold > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should chat about that. I think for something like it we should do our best to ignore config errors and limp along not making your app worse.

However, this would be an undiscoverable config error, which should be fixed in some fashion...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants