Skip to content

Commit

Permalink
internal: remove pre-Go 1.18 workaround for reading build info (#2638)
Browse files Browse the repository at this point in the history
We haven't supported Go 1.17 or older since February 2023, when Go 1.20
was released. So we don't need the workaround for reading debug info
from the binary for pre-Go 1.18 builds.
  • Loading branch information
nsrip-dd authored Mar 29, 2024
1 parent aaf8af5 commit 6b4d009
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 60 deletions.
29 changes: 29 additions & 0 deletions internal/gitmetadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ package internal
import (
"net/url"
"os"
"runtime/debug"
"sync"

"gopkg.in/DataDog/dd-trace-go.v1/internal/log"
)

const (
Expand Down Expand Up @@ -73,6 +76,32 @@ func getTagsFromDDTags() map[string]string {
}
}

// getTagsFromBinary extracts git metadata from binary metadata
func getTagsFromBinary() map[string]string {
res := make(map[string]string)
info, ok := debug.ReadBuildInfo()
if !ok {
log.Debug("ReadBuildInfo failed, skip source code metadata extracting")
return res
}
goPath := info.Path
var vcs, commitSha string
for _, s := range info.Settings {
if s.Key == "vcs" {
vcs = s.Value
} else if s.Key == "vcs.revision" {
commitSha = s.Value
}
}
if vcs != "git" {
log.Debug("Unknown VCS: '%s', skip source code metadata extracting", vcs)
return res
}
res[TagCommitSha] = commitSha
res[TagGoPath] = goPath
return res
}

// GetGitMetadataTags returns git metadata tags
func GetGitMetadataTags() map[string]string {
lock.Lock()
Expand Down
41 changes: 0 additions & 41 deletions internal/gitmetadatabinary.go

This file was deleted.

19 changes: 0 additions & 19 deletions internal/gitmetadatabinary_legacy.go

This file was deleted.

0 comments on commit 6b4d009

Please sign in to comment.