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 1 commit
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
16 changes: 12 additions & 4 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,14 +176,14 @@ 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:
// Aggregation is disabled by default for legacy version (v1), 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),
Expand All @@ -196,6 +196,14 @@ func NewConfig() Config {
AggregationOutlierIqrCoefLower: null.NewFloat(1.5, false),
AggregationOutlierIqrCoefUpper: null.NewFloat(1.3, false),
}

// v2 enables aggregation by default
if c.APIVersion.Int64 == 2 {
olegbespalov marked this conversation as resolved.
Show resolved Hide resolved
c.AggregationPeriod = types.NewNullDuration(3*time.Second, false)
c.AggregationWaitPeriod = types.NewNullDuration(8*time.Second, 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