Skip to content

Commit

Permalink
Fix service destination max group scaling based on memory (#11905)
Browse files Browse the repository at this point in the history
* Fix service destination max group scaling based on memory

Fix regression introduced in #11739

- Fix bug where code is never executed
- Fix wrong log message
- Fix failing test
  • Loading branch information
carsonip authored Oct 20, 2023
1 parent d2c362d commit 791f582
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 12 deletions.
2 changes: 1 addition & 1 deletion internal/beater/beater.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ func (s *Runner) Run(ctx context.Context) error {
if s.config.Aggregation.ServiceDestinations.MaxGroups <= 0 {
s.config.Aggregation.ServiceDestinations.MaxGroups = linearScaledValue(5_000, memLimitGB, 5_000)
s.logger.Infof("Aggregation.ServiceDestinations.MaxGroups set to %d based on %0.1fgb of memory",
s.config.Aggregation.Transactions.MaxGroups, memLimitGB,
s.config.Aggregation.ServiceDestinations.MaxGroups, memLimitGB,
)
}

Expand Down
12 changes: 2 additions & 10 deletions internal/beater/config/aggregation.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@

package config

const (
defaultServiceDestinationAggregationMaxGroups = 10000
)

// AggregationConfig holds configuration related to various metrics aggregations.
type AggregationConfig struct {
MaxServices int `config:"max_services"` // if <= 0 then will be set based on memory limits
Expand All @@ -36,7 +32,7 @@ type TransactionAggregationConfig struct {

// ServiceDestinationAggregationConfig holds configuration related to span metrics aggregation for service maps.
type ServiceDestinationAggregationConfig struct {
MaxGroups int `config:"max_groups" validate:"min=1"`
MaxGroups int `config:"max_groups"` // if <= 0 then will be set based on memory limits
}

// ServiceTransactionAggregationConfig holds configuration related to service transaction metrics aggregation.
Expand All @@ -45,9 +41,5 @@ type ServiceTransactionAggregationConfig struct {
}

func defaultAggregationConfig() AggregationConfig {
return AggregationConfig{
ServiceDestinations: ServiceDestinationAggregationConfig{
MaxGroups: defaultServiceDestinationAggregationMaxGroups,
},
}
return AggregationConfig{}
}
2 changes: 1 addition & 1 deletion internal/beater/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ func TestUnpackConfig(t *testing.T) {
MaxGroups: 0, // Default value is set as per memory limit
},
ServiceDestinations: ServiceDestinationAggregationConfig{
MaxGroups: 10000,
MaxGroups: 0, // Default value is set as per memory limit
},
ServiceTransactions: ServiceTransactionAggregationConfig{
MaxGroups: 0, // Default value is set as per memory limit
Expand Down

0 comments on commit 791f582

Please sign in to comment.