Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

internal/telemetry: remove DetectLibDl #2517

Merged
merged 2 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions ddtrace/tracer/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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)
}
4 changes: 0 additions & 4 deletions internal/appsec/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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,
Expand Down
54 changes: 0 additions & 54 deletions internal/osinfo/osinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 ""
}
49 changes: 0 additions & 49 deletions internal/osinfo/osinfo_test.go

This file was deleted.