Skip to content

Commit 556e620

Browse files
call underlying os.Hostname instead of the entire hostInfo gopsutil call (#479)
* call underlying os.Hostname instad of the entire hostInfo gopsutil call
1 parent d1f6013 commit 556e620

File tree

3 files changed

+9
-15
lines changed

3 files changed

+9
-15
lines changed

src/core/environment.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,12 @@ func getUnixName() string {
185185
}
186186

187187
func (env *EnvironmentType) GetHostname() string {
188-
ctx := context.Background()
189-
defer ctx.Done()
190-
hostInformation, err := host.InfoWithContext(ctx)
188+
hostname, err := os.Hostname()
191189
if err != nil {
192190
log.Warnf("Unable to read hostname from dataplane, defaulting value. Error: %v", err)
193-
return ""
191+
hostname = ""
194192
}
195-
return hostInformation.Hostname
193+
return hostname
196194
}
197195

198196
func (env *EnvironmentType) GetSystemUUID() string {

test/integration/vendor/github.com/nginx/agent/v2/src/core/environment.go

+3-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/performance/vendor/github.com/nginx/agent/v2/src/core/environment.go

+3-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)