diff --git a/ddtrace/v1.go b/ddtrace/v1.go deleted file mode 100644 index 225a74c619..0000000000 --- a/ddtrace/v1.go +++ /dev/null @@ -1,28 +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 2025 Datadog, Inc. - -package ddtrace - -import ( - "github.com/DataDog/dd-trace-go/v2/internal/log" - "github.com/DataDog/dd-trace-go/v2/internal/version" -) - -func init() { - checkV1NonTransitional() -} - -func checkV1NonTransitional() { - version, transitional, found := version.FindV1Version() - if !found { - // No v1 version detected - return - } - if transitional { - // v1 version is transitional - return - } - log.Warn("Detected %q non-transitional version of dd-trace-go. This version is not compatible with v2 - please upgrade to v1.74.0 or later", version) -} diff --git a/internal/version/version.go b/internal/version/version.go index 56b5a58e5c..70dfa13310 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -6,10 +6,8 @@ package version import ( - "runtime/debug" "strconv" "strings" - "sync" "golang.org/x/mod/semver" ) @@ -36,56 +34,8 @@ var ( Patch int // RC is the current release candidate version number RC int - // once is used to ensure that the v1 version is only found once - once sync.Once ) -func FindV1Version() (string, bool, bool) { - once.Do(func() { - info, ok := debug.ReadBuildInfo() - if !ok { - return - } - v1Tag = findV1Version(info.Deps) - }) - if v1Tag == nil { - return "", false, false - } - return v1Tag.Version, v1Tag.Transitional, true -} - -func init() { - // Check if we are using a transitional v1.74.x or later version - vt, _, found := FindV1Version() - if found { - Tag = vt - } - v := parseVersion(Tag) - Major, Minor, Patch, RC = v.Major, v.Minor, v.Patch, v.RC -} - -func findV1Version(deps []*debug.Module) *v1version { - var version string - for _, dep := range deps { - if dep.Path != "gopkg.in/DataDog/dd-trace-go.v1" { - continue - } - version = dep.Version - break - } - if version == "" { - return nil - } - vt := &v1version{ - Version: version, - } - v := parseVersion(vt.Version) - if v.Major == 1 && v.Minor >= 74 { - vt.Transitional = true - } - return vt -} - type version struct { Major int Minor int diff --git a/internal/version/version_test.go b/internal/version/version_test.go index 7c9e84bc0b..7b3af726b1 100644 --- a/internal/version/version_test.go +++ b/internal/version/version_test.go @@ -8,7 +8,6 @@ package version import ( "bytes" "os/exec" - "runtime/debug" "strconv" "strings" "testing" @@ -55,67 +54,6 @@ func unixDate(u string) (time.Time, error) { return time.Unix(sec, 0), nil } -func TestFindV1Version(t *testing.T) { - tests := []struct { - deps []*debug.Module - expected *v1version - }{ - { - deps: []*debug.Module{ - {Path: "gopkg.in/DataDog/dd-trace-go.v1", Version: "v1.2.3-rc.12"}, - }, - expected: &v1version{ - Version: "v1.2.3-rc.12", - }, - }, - { - deps: []*debug.Module{ - {Path: "gopkg.in/DataDog/dd-trace-go.v1", Version: "v1.74.0"}, - }, - expected: &v1version{ - Version: "v1.74.0", - Transitional: true, - }, - }, - { - deps: []*debug.Module{ - {Path: "gopkg.in/DataDog/dd-trace-go.v1", Version: "v1.73.1"}, - }, - expected: &v1version{ - Version: "v1.73.1", - }, - }, - { - deps: []*debug.Module{}, - expected: nil, - }, - { - deps: []*debug.Module{ - {Path: "github.com/DataDog/dd-trace-go/v2", Version: "v2.0.0"}, - }, - expected: nil, - }, - } - for _, c := range tests { - vt := findV1Version(c.deps) - if c.expected == nil { - if vt != nil { - t.Fatalf("got %v, expected nil", vt) - } - continue - } - if vt == nil { - t.Fatalf("got nil, expected *v1version") - } - if vt.Version != c.expected.Version { - t.Fatalf("got %s, expected %s", vt.Version, c.expected.Version) - } - if vt.Transitional != c.expected.Transitional { - t.Fatalf("got %t, expected %t", vt.Transitional, c.expected.Transitional) - } - } -} - func TestParseVersion(t *testing.T) { tc := []struct { version string