Skip to content

Commit

Permalink
Merge branch 'main' into romain.marcadier/innovation-week
Browse files Browse the repository at this point in the history
  • Loading branch information
RomainMuller committed Jan 18, 2024
2 parents 840d420 + 9f088b5 commit 3b378e0
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 115 deletions.
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.

0 comments on commit 3b378e0

Please sign in to comment.