Skip to content

Commit

Permalink
Make the CollAgentAddr config optional in controller (#279)
Browse files Browse the repository at this point in the history
Co-authored-by: Christos Kalkanis <[email protected]>
Co-authored-by: Florian Lehner <[email protected]>
  • Loading branch information
3 people authored Dec 18, 2024
1 parent a32420f commit 0958f0d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 4 additions & 0 deletions internal/controller/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ type Config struct {
Tracers string
VerboseMode bool
Version bool
// HostName is the name of the host.
HostName string
// IPAddress is the IP address of the host that sends data to CollAgentAddr.
IPAddress string

Reporter reporter.Reporter

Expand Down
9 changes: 2 additions & 7 deletions internal/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,8 @@ func (c *Controller) Start(ctx context.Context) error {
// OTel semantic introduced in https://github.com/open-telemetry/semantic-conventions/issues/66
metadataCollector.AddCustomData("os.kernel.release", kernelVersion)

// hostname and sourceIP will be populated from the root namespace.
hostname, sourceIP, err := helpers.GetHostnameAndSourceIP(c.config.CollAgentAddr)
if err != nil {
log.Warnf("Failed to fetch metadata information in the root namespace: %v", err)
}
metadataCollector.AddCustomData("host.name", hostname)
metadataCollector.AddCustomData("host.ip", sourceIP)
metadataCollector.AddCustomData("host.name", c.config.HostName)
metadataCollector.AddCustomData("host.ip", c.config.IPAddress)

err = c.reporter.Start(ctx)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ func mainWithExitCode() exitCode {
log.Error(err)
return exitFailure
}
cfg.HostName, cfg.IPAddress = hostname, sourceIP

rep, err := reporter.NewOTLP(&reporter.Config{
CollAgentAddr: cfg.CollAgentAddr,
Expand Down

0 comments on commit 0958f0d

Please sign in to comment.