Skip to content

Commit

Permalink
output/cloud: Set v2 as the default (#3400)
Browse files Browse the repository at this point in the history
  • Loading branch information
codebien committed Oct 17, 2023
1 parent 44e1e63 commit 036f8a0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
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)

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

0 comments on commit 036f8a0

Please sign in to comment.