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

output/cloud: Set v2 as the default #3400

Merged
merged 2 commits into from
Oct 17, 2023
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
40 changes: 28 additions & 12 deletions cloudapi/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ type Config struct {

// NewConfig creates a new Config instance with default values for some fields.
func NewConfig() Config {
return Config{
c := Config{
Host: null.NewString("https://ingest.k6.io", false),
LogsTailURL: null.NewString("wss://cloudlogs.k6.io/api/v1/tail", false),
WebAppURL: null.NewString("https://app.k6.io", false),
Expand All @@ -176,26 +176,42 @@ func NewConfig() Config {

MaxMetricSamplesPerPackage: null.NewInt(100000, false),
Timeout: types.NewNullDuration(1*time.Minute, false),
APIVersion: null.NewInt(1, false),
APIVersion: null.NewInt(2, false),

// The set value (1000) is selected for performance reasons.
// Any change to this value should be first discussed with internal stakeholders.
MaxTimeSeriesInBatch: null.NewInt(1000, false),

// Aggregation is disabled by default, since AggregationPeriod has no default value
// but if it's enabled manually or from the cloud service, those are the default values it will use:
AggregationCalcInterval: types.NewNullDuration(3*time.Second, false),
AggregationWaitPeriod: types.NewNullDuration(5*time.Second, false),
AggregationMinSamples: null.NewInt(25, false),
AggregationOutlierAlgoThreshold: null.NewInt(75, false),
AggregationOutlierIqrRadius: null.NewFloat(0.25, false),
// TODO: the following values were used by the previous default version (v1).
// We decided to keep the same values mostly for having a smoother migration to v2.
// Because the previous version's aggregation config, a few lines below, is overwritten
// by the remote service with the same values that we are now setting here for v2.
// When the migration will be completed we may evaluate to re-discuss them
// as we may evaluate to reduce these values - especially the waiting period.
// A more specific request about waiting period is mentioned in the link below:
// https://github.com/grafana/k6/blob/44e1e63aadb66784ff0a12b8d9821a0fdc9e7467/output/cloud/expv2/collect.go#L72-L77
AggregationPeriod: types.NewNullDuration(3*time.Second, false),
AggregationWaitPeriod: types.NewNullDuration(8*time.Second, false),
}

if c.APIVersion.Int64 == 1 {
// Aggregation is disabled by default for legacy version, since AggregationPeriod has no default value
// but if it's enabled manually or from the cloud service and the cloud doesn't override the config then
// those are the default values it will use.
c.AggregationPeriod = types.NewNullDuration(0, false)
c.AggregationCalcInterval = types.NewNullDuration(3*time.Second, false)
c.AggregationWaitPeriod = types.NewNullDuration(5*time.Second, false)
c.AggregationMinSamples = null.NewInt(25, false)
c.AggregationOutlierAlgoThreshold = null.NewInt(75, false)
c.AggregationOutlierIqrRadius = null.NewFloat(0.25, false)

// Since we're measuring durations, the upper coefficient is slightly
// lower, since outliers from that side are more interesting than ones
// close to zero.
AggregationOutlierIqrCoefLower: null.NewFloat(1.5, false),
AggregationOutlierIqrCoefUpper: null.NewFloat(1.3, false),
c.AggregationOutlierIqrCoefLower = null.NewFloat(1.5, false)
c.AggregationOutlierIqrCoefUpper = null.NewFloat(1.3, false)
}

return c
}

// Apply saves config non-zero config values from the passed config in the receiver.
Expand Down
4 changes: 2 additions & 2 deletions output/cloud/output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func TestOutputCreateTestWithConfigOverwrite(t *testing.T) {
"reference_id": "cloud-create-test",
"config": {
"metricPushInterval": "10ms",
"aggregationPeriod": "30ms"
"aggregationPeriod": "1s"
}
}`)
case "/v1/tests/cloud-create-test":
Expand All @@ -126,7 +126,7 @@ func TestOutputCreateTestWithConfigOverwrite(t *testing.T) {
require.NoError(t, out.Start())

assert.Equal(t, types.NullDurationFrom(10*time.Millisecond), out.config.MetricPushInterval)
assert.Equal(t, types.NullDurationFrom(30*time.Millisecond), out.config.AggregationPeriod)
assert.Equal(t, types.NullDurationFrom(1*time.Second), out.config.AggregationPeriod)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason this is changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is, the aggregation in v2 can't be sub-second precision

if aggrPeriod != aggrPeriod.Truncate(time.Second) {
return nil, errors.New("aggregation period is not allowed to have sub-second precision")
}


// Assert that it overwrites only the provided values
expTimeout := types.NewNullDuration(60*time.Second, false)
Expand Down