Skip to content

Commit

Permalink
Fix runtime setting registration of goroutine profiling (#20910)
Browse files Browse the repository at this point in the history
  • Loading branch information
lebauce authored Nov 16, 2023
1 parent b8e5aa4 commit 7b97e89
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion cmd/system-probe/subcommands/run/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ func initRuntimeSettings() error {
if err := commonsettings.RegisterRuntimeSetting(&commonsettings.RuntimeBlockProfileRate{ConfigPrefix: configPrefix, Config: pkgconfig.SystemProbe}); err != nil {
return err
}
if err := commonsettings.RegisterRuntimeSetting(&commonsettings.ProfilingGoroutines{ConfigPrefix: configPrefix, Config: pkgconfig.SystemProbe}); err != nil {
profilingGoRoutines := commonsettings.NewProfilingGoroutines()
profilingGoRoutines.Config = pkgconfig.SystemProbe
profilingGoRoutines.ConfigPrefix = configPrefix
if err := commonsettings.RegisterRuntimeSetting(profilingGoRoutines); err != nil {
return err
}
if err := commonsettings.RegisterRuntimeSetting(&commonsettings.ProfilingRuntimeSetting{SettingName: "internal_profiling", Service: "system-probe", ConfigPrefix: configPrefix, Config: pkgconfig.SystemProbe}); err != nil {
Expand Down
3 changes: 1 addition & 2 deletions pkg/config/settings/runtime_setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
package settings

import (
"errors"
"fmt"
"strconv"
"sync"
Expand Down Expand Up @@ -45,7 +44,7 @@ type RuntimeSetting interface {
// RegisterRuntimeSetting keeps track of configurable settings
func RegisterRuntimeSetting(setting RuntimeSetting) error {
if _, ok := runtimeSettings[setting.Name()]; ok {
return errors.New("duplicated settings detected")
return fmt.Errorf("duplicated settings detected: %s", setting.Name())
}
runtimeSettings[setting.Name()] = setting
return nil
Expand Down
3 changes: 2 additions & 1 deletion pkg/config/settings/runtime_settings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package settings

import (
"fmt"
"testing"

"github.com/DataDog/datadog-agent/pkg/config"
Expand Down Expand Up @@ -65,7 +66,7 @@ func TestRuntimeSettings(t *testing.T) {

err = RegisterRuntimeSetting(&runtimeSetting)
assert.NotNil(t, err)
assert.Equal(t, "duplicated settings detected", err.Error())
assert.Equal(t, fmt.Sprintf("duplicated settings detected: %s", runtimeSetting.Name()), err.Error())
}

func TestLogLevel(t *testing.T) {
Expand Down

0 comments on commit 7b97e89

Please sign in to comment.