-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
584a5b3
commit c517e86
Showing
1 changed file
with
6 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,6 @@ import ( | |
"bytes" | ||
"embed" | ||
"fmt" | ||
"go/build" | ||
"go/parser" | ||
"go/token" | ||
"io/fs" | ||
|
@@ -51,6 +50,10 @@ import ( | |
//go:embed templates | ||
var templatesFS embed.FS | ||
|
||
var ( | ||
errNoVersionFound = errors.New("no version found in the path of the source file") | ||
) | ||
|
||
type Instrument struct { | ||
realInst instrument.Instrument | ||
methodFilters []*instrument.Point | ||
|
@@ -107,7 +110,7 @@ func (i *Instrument) CouldHandle(opts *api.CompileOptions) bool { | |
} | ||
// check the version of the framework could handler | ||
version, err := i.tryToFindThePluginVersion(opts, ins) | ||
if err != nil { | ||
if err != nil && !errors.Is(err, errNoVersionFound) { | ||
logrus.Warnf("ignore the plugin %s, because %s", ins.Name(), err) | ||
continue | ||
} | ||
|
@@ -551,11 +554,6 @@ func (i *Instrument) tryToFindThePluginVersion(opts *api.CompileOptions, ins ins | |
continue | ||
} | ||
|
||
// support local import. example: arg=../../../../toolkit/trace/api.go | ||
if build.IsLocalImport(arg) { | ||
continue | ||
} | ||
|
||
// example: github.com/Shopify/sarama | ||
basePkg := ins.BasePackage() | ||
|
||
|
@@ -568,7 +566,7 @@ func (i *Instrument) tryToFindThePluginVersion(opts *api.CompileOptions, ins ins | |
// arg example: github.com/!shopify/[email protected]/acl.go | ||
_, afterPkg, found := strings.Cut(arg, escapedBasePkg) | ||
if !found { | ||
return "", fmt.Errorf("could not found the go version of the package %s, go file path: %s", basePkg, arg) | ||
return "", errors.Wrapf(errNoVersionFound, "package %s, go file path: %s", basePkg, arg) | ||
} | ||
|
||
if !strings.HasPrefix(afterPkg, "@") { | ||
|