Skip to content

Commit cd4855d

Browse files
authored
Olivierg/pr 220 followw up (#225)
* Rename `package hostprofilerrunner` to `runner` * Rename FullHostProfilerSettings to Config * Move cli_flags.go config.go helpers.go to a new package `config` * Rename settings to config in sanityCheck * rename hostprofilerrunner.go to runner.go * Rename configpkg to config and config to `c`
1 parent c356a4b commit cd4855d

6 files changed

Lines changed: 93 additions & 91 deletions

File tree

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This product includes software developed at Datadog (https://www.datadoghq.com/).
22
// Copyright 2024 Datadog, Inc.
33

4-
package hostprofilerrunner
4+
package config
55

66
import (
77
"context"
@@ -52,11 +52,11 @@ const (
5252
// This is the X in 2^(n + x) where n is the default hardcoded map size value
5353
defaultArgMapScaleFactor = 0
5454
// 1TB of executable address space
55-
maxArgMapScaleFactor = 8
55+
MaxArgMapScaleFactor = 8
5656
)
5757

5858
type Arguments struct {
59-
FullHostProfilerSettings
59+
Config
6060
Copyright bool
6161
VerboseMode bool
6262
cmd *cli.Command
@@ -126,7 +126,7 @@ func parseCLIArgs(osArgs []string) (*Arguments, error) {
126126
Usage: fmt.Sprintf("Scaling factor for eBPF map sizes. "+
127127
"Every increase by 1 doubles the map size. Increase if you see eBPF map size errors. "+
128128
"Default is %d corresponding to 4GB of executable address space, max is %d.",
129-
defaultArgMapScaleFactor, maxArgMapScaleFactor),
129+
defaultArgMapScaleFactor, MaxArgMapScaleFactor),
130130
Destination: &args.MapScaleFactor,
131131
Sources: cli.EnvVars("DD_HOST_PROFILING_MAP_SCALE_FACTOR"),
132132
},
@@ -397,10 +397,10 @@ func (args *Arguments) Dump() {
397397
}
398398
}
399399

400-
func CreateDefaultFullHostProfilerSettings() (*FullHostProfilerSettings, error) {
400+
func CreateConfig() (*Config, error) {
401401
args, err := parseCLIArgs(nil)
402402
if err != nil {
403403
return nil, err
404404
}
405-
return &args.FullHostProfilerSettings, nil
405+
return &args.Config, nil
406406
}

hostprofilerrunner/fullhostprofilersettings.go renamed to config/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This product includes software developed at Datadog (https://www.datadoghq.com/).
22
// Copyright 2024 Datadog, Inc.
33

4-
package hostprofilerrunner
4+
package config
55

66
import (
77
"encoding/json"
@@ -57,7 +57,7 @@ func (s *additionalSymbolEndpoints) Get() interface{} {
5757
return s
5858
}
5959

60-
type FullHostProfilerSettings struct {
60+
type Config struct {
6161
BPFVerifierLogLevel uint64
6262
AgentURL string
6363
MapScaleFactor uint64
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// This product includes software developed at Datadog (https://www.datadoghq.com/).
88
// Copyright 2024 Datadog, Inc.
99

10-
package hostprofilerrunner
10+
package config
1111

1212
import (
1313
"fmt"
@@ -48,9 +48,9 @@ func ValidateTags(tags string) reporter.Tags {
4848
return validatedTags
4949
}
5050

51-
func addTagsFromArgs(tags *reporter.Tags, settings *FullHostProfilerSettings) {
52-
if settings.Environment != "" {
53-
*tags = append(*tags, reporter.MakeTag("env", settings.Environment))
51+
func AddTagsFromArgs(tags *reporter.Tags, config *Config) {
52+
if config.Environment != "" {
53+
*tags = append(*tags, reporter.MakeTag("env", config.Environment))
5454
}
5555
}
5656

@@ -80,13 +80,13 @@ func IsAPPKeyValid(key string) bool {
8080
return true
8181
}
8282

83-
func intakeURLForSite(site string) (string, error) {
83+
func IntakeURLForSite(site string) (string, error) {
8484
u := fmt.Sprintf("https://intake.profile.%s/api/v2/profile", site)
8585
_, err := url.Parse(u)
8686
return u, err
8787
}
8888

89-
func intakeURLForAgent(agentURL string) (string, error) {
89+
func IntakeURLForAgent(agentURL string) (string, error) {
9090
const profilingEndPoint = "/profiling/v1/input"
9191
return url.JoinPath(agentURL, profilingEndPoint)
9292
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This product includes software developed at Datadog (https://www.datadoghq.com/).
22
// Copyright 2025 Datadog, Inc.
33

4-
package hostprofilerrunner
4+
package config
55

66
import (
77
"reflect"

main.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,27 @@ import (
1818
log "github.com/sirupsen/logrus"
1919
"golang.org/x/sys/unix"
2020

21-
"github.com/DataDog/dd-otel-host-profiler/hostprofilerrunner"
21+
"github.com/DataDog/dd-otel-host-profiler/config"
22+
"github.com/DataDog/dd-otel-host-profiler/runner"
2223
)
2324

2425
func main() {
2526
os.Exit(int(mainWithExitCode()))
2627
}
2728

28-
func mainWithExitCode() hostprofilerrunner.ExitCode {
29-
args, err := hostprofilerrunner.ParseArgs()
29+
func mainWithExitCode() runner.ExitCode {
30+
args, err := config.ParseArgs()
3031
if err != nil {
31-
return hostprofilerrunner.ParseError("Failure to parse arguments: %v", err)
32+
return runner.ParseError("Failure to parse arguments: %v", err)
3233
}
3334

3435
if args == nil {
35-
return hostprofilerrunner.ExitSuccess
36+
return runner.ExitSuccess
3637
}
3738

3839
if args.Copyright {
39-
fmt.Print(hostprofilerrunner.Copyright)
40-
return hostprofilerrunner.ExitSuccess
40+
fmt.Print(config.Copyright)
41+
return runner.ExitSuccess
4142
}
4243

4344
// Context to drive main goroutine and the Tracer monitors.
@@ -51,5 +52,5 @@ func mainWithExitCode() hostprofilerrunner.ExitCode {
5152
args.Dump()
5253
}
5354

54-
return hostprofilerrunner.RunHostProfiler(mainCtx, &args.FullHostProfilerSettings)
55+
return runner.Run(mainCtx, &args.Config)
5556
}

0 commit comments

Comments
 (0)