diff --git a/ddtrace/tracer/telemetry.go b/ddtrace/tracer/telemetry.go index 7ac27990c9..5e039681b8 100644 --- a/ddtrace/tracer/telemetry.go +++ b/ddtrace/tracer/telemetry.go @@ -7,10 +7,8 @@ package tracer import ( "fmt" - "runtime" "strings" - "gopkg.in/DataDog/dd-trace-go.v1/internal/osinfo" "gopkg.in/DataDog/dd-trace-go.v1/internal/telemetry" ) @@ -102,11 +100,5 @@ func startTelemetry(c *config) { telemetryConfigs = append(telemetryConfigs, telemetry.Configuration{Name: "orchestrion_" + k, Value: v}) } } - if runtime.GOOS == "linux" { - if path := osinfo.DetectLibDl("/"); path != "" { - // Help collect data on the libdl path for Linux - telemetryConfigs = append(telemetryConfigs, telemetry.Configuration{Name: "osinfo_libdl_path", Value: path}) - } - } telemetry.GlobalClient.ProductChange(telemetry.NamespaceTracers, true, telemetryConfigs) } diff --git a/internal/appsec/telemetry.go b/internal/appsec/telemetry.go index 13e4aa808d..229b52aed6 100644 --- a/internal/appsec/telemetry.go +++ b/internal/appsec/telemetry.go @@ -9,7 +9,6 @@ import ( "runtime" waf "github.com/DataDog/go-libddwaf/v2" - "gopkg.in/DataDog/dd-trace-go.v1/internal/osinfo" "gopkg.in/DataDog/dd-trace-go.v1/internal/telemetry" ) @@ -44,9 +43,6 @@ func newAppsecTelemetry() *appsecTelemetry { configs := make([]telemetry.Configuration, len(staticConfigs)+1, len(staticConfigs)+2) configs[0] = telemetry.Configuration{Name: "cgo_enabled", Value: cgoEnabled} copy(configs[1:], staticConfigs) - if runtime.GOOS == "linux" { - configs = append(configs, telemetry.Configuration{Name: "osinfo_libdl_path", Value: osinfo.DetectLibDl("/")}) - } return &appsecTelemetry{ configs: configs, diff --git a/internal/osinfo/osinfo.go b/internal/osinfo/osinfo.go index da828a427b..7519a917e9 100644 --- a/internal/osinfo/osinfo.go +++ b/internal/osinfo/osinfo.go @@ -6,14 +6,6 @@ // Package osinfo provides information about the current operating system release package osinfo -import ( - "io/fs" - "os" - "path" - "runtime" - "sync" -) - // OSName returns the name of the operating system, including the distribution // for Linux when possible. func OSName() string { @@ -27,49 +19,3 @@ func OSVersion() string { // call out to OS-specific implementation return osVersion() } - -var ( - detectLibDlOnce sync.Once - detectedLibDl string -) - -// DetectLibDl returns the path to libdl.so if present under one of the -// traditional library paths (under `/lib`, `/lib64`, `/usr/lib`, etc...). This -// is a no-op on platforms other than Linux. The lookup is done exactly once, -// and the result will be re-used by subsequent calls. -func DetectLibDl(root string) string { - if runtime.GOOS != "linux" { - return "" - } - - detectLibDlOnce.Do(func() { detectedLibDl = detectLibDl(root, os.DirFS(root)) }) - return detectedLibDl -} - -// detectLibDl is the testable implementation of DetectLibDl. -func detectLibDl(root string, fsys fs.FS) string { - prefixes := [...]string{ - "lib", - "lib64", - "usr/lib", - "usr/lib64", - "usr/local/lib", - "usr/local/lib64", - } - - var result string - for _, prefix := range prefixes { - _ = fs.WalkDir(fsys, prefix, func(path string, dir fs.DirEntry, err error) error { - if dir == nil || dir.IsDir() || dir.Name() != "libdl.so.2" { - return nil - } - // Found it! - result = path - return fs.SkipDir // TODO: fs.SkipAll once 1.20+ is the minimum supported Go version - }) - if result != "" { - return path.Join(root, result) - } - } - return "" -} diff --git a/internal/osinfo/osinfo_test.go b/internal/osinfo/osinfo_test.go deleted file mode 100644 index 6e30ff9753..0000000000 --- a/internal/osinfo/osinfo_test.go +++ /dev/null @@ -1,49 +0,0 @@ -// Unless explicitly stated otherwise all files in this repository are licensed -// under the Apache License Version 2.0. -// This product includes software developed at Datadog (https://www.datadoghq.com/). -// Copyright 2016 Datadog, Inc. - -package osinfo - -import ( - "testing" - "testing/fstest" - - "github.com/stretchr/testify/require" -) - -func TestDetectLibDl(t *testing.T) { - testCases := []struct { - expectedPath string - testFs fstest.MapFS - }{ - { - expectedPath: "/lib/libdl.so.2", - testFs: fstest.MapFS{ - "lib/libdl.so.2": &fstest.MapFile{}, - }, - }, - { - expectedPath: "/lib64/libdl.so.2", - testFs: fstest.MapFS{ - "lib64/libdl.so.2": &fstest.MapFile{}, - }, - }, - { - expectedPath: "", - testFs: fstest.MapFS{ - "nope/libdl.so.2": &fstest.MapFile{}, - }, - }, - { - expectedPath: "/lib/arm64-linux-gnu/libdl.so.2", - testFs: fstest.MapFS{ - "lib/arm64-linux-gnu/libdl.so.2": &fstest.MapFile{}, - }, - }, - } - for _, tc := range testCases { - got := detectLibDl("/", tc.testFs) - require.Equal(t, tc.expectedPath, got) - } -}