diff --git a/internal/controller/config.go b/internal/controller/config.go index 16daddc6..dfd96b91 100644 --- a/internal/controller/config.go +++ b/internal/controller/config.go @@ -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 diff --git a/internal/controller/controller.go b/internal/controller/controller.go index 17f796ef..3b3f96da 100644 --- a/internal/controller/controller.go +++ b/internal/controller/controller.go @@ -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 { diff --git a/main.go b/main.go index 106413b8..17debe3b 100644 --- a/main.go +++ b/main.go @@ -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,