From 7a2fbad692effff29b5cfdebc2d3e4fbfd9da95b Mon Sep 17 00:00:00 2001 From: Eliott Bouhana <47679741+eliottness@users.noreply.github.com> Date: Mon, 20 Jan 2025 09:26:59 +0000 Subject: [PATCH] internal/telemetry: revert hostname.Get() -> os.Hostname() (#3101) Signed-off-by: Eliott Bouhana --- internal/telemetry/client.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/telemetry/client.go b/internal/telemetry/client.go index 7a94be85cd..27c5baaa30 100644 --- a/internal/telemetry/client.go +++ b/internal/telemetry/client.go @@ -13,6 +13,7 @@ import ( "fmt" "net" "net/http" + "os" "runtime" "runtime/debug" "strings" @@ -21,7 +22,6 @@ import ( "gopkg.in/DataDog/dd-trace-go.v1/internal" "gopkg.in/DataDog/dd-trace-go.v1/internal/globalconfig" - "gopkg.in/DataDog/dd-trace-go.v1/internal/hostname" logger "gopkg.in/DataDog/dd-trace-go.v1/internal/log" "gopkg.in/DataDog/dd-trace-go.v1/internal/osinfo" "gopkg.in/DataDog/dd-trace-go.v1/internal/version" @@ -79,9 +79,16 @@ var ( // LogPrefix specifies the prefix for all telemetry logging LogPrefix = "Instrumentation telemetry: " + + hostname string ) func init() { + var err error + hostname, err = os.Hostname() + if err != nil { + hostname = "unknown" + } GlobalClient = new(client) } @@ -459,7 +466,6 @@ func (c *client) flush(sync bool) { // sent through this Client func (c *client) newRequest(t RequestType) *Request { c.seqID++ - hostname := hostname.Get() body := &Body{ APIVersion: "v2", RequestType: t,