This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-go.git
The following commit(s) were added to refs/heads/main by this push:
new 8abb20f Support enhancement with go 1.23 (#192)
8abb20f is described below
commit 8abb20fab04488341cbc27e0cc4f5cbb216f1493
Author: mrproliu <[email protected]>
AuthorDate: Mon Aug 19 21:29:23 2024 +0800
Support enhancement with go 1.23 (#192)
* Support enhancement with go 1.23
* update go version in native http
---
CHANGES.md | 1 +
test/plugins/scenarios/gin/plugin.yml | 3 +++
test/plugins/scenarios/http/plugin.yml | 3 +++
test/plugins/scenarios/trace-activation/plugin.yml | 3 +++
tools/go-agent/instrument/api/flags.go | 1 +
tools/go-agent/instrument/runtime/instrument.go | 24 +++++++++++++++++++++-
6 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/CHANGES.md b/CHANGES.md
index b68bb56..a65caf7 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -8,6 +8,7 @@ Release Notes.
* Add support trace ignore.
* Enhance the observability of makefile execution.
* Update the error message if the peer address is empty when creating exit
span.
+* Support enhancement go`1.23`.
#### Plugins
* Support [Pulsar](https://github.com/apache/pulsar-client-go) MQ.
diff --git a/test/plugins/scenarios/gin/plugin.yml
b/test/plugins/scenarios/gin/plugin.yml
index 9a836ae..6bdeecb 100644
--- a/test/plugins/scenarios/gin/plugin.yml
+++ b/test/plugins/scenarios/gin/plugin.yml
@@ -26,5 +26,8 @@ support-version:
- v1.8.0
- v1.8.2
- go: 1.18
+ framework:
+ - v1.9.0
+ - go: 1.23
framework:
- v1.9.0
\ No newline at end of file
diff --git a/test/plugins/scenarios/http/plugin.yml
b/test/plugins/scenarios/http/plugin.yml
index 401b195..5dae6d0 100644
--- a/test/plugins/scenarios/http/plugin.yml
+++ b/test/plugins/scenarios/http/plugin.yml
@@ -24,3 +24,6 @@ support-version:
- go: 1.18
- go: 1.19
- go: 1.20
+ - go: 1.21
+ - go: 1.22
+ - go: 1.23
diff --git a/test/plugins/scenarios/trace-activation/plugin.yml
b/test/plugins/scenarios/trace-activation/plugin.yml
index 7b60c17..cb46b2c 100644
--- a/test/plugins/scenarios/trace-activation/plugin.yml
+++ b/test/plugins/scenarios/trace-activation/plugin.yml
@@ -23,4 +23,7 @@ support-version:
- go: 1.18
- go: 1.19
- go: 1.20
+ - go: 1.21
+ - go: 1.22
+ - go: 1.23
toolkit: true
\ No newline at end of file
diff --git a/tools/go-agent/instrument/api/flags.go
b/tools/go-agent/instrument/api/flags.go
index 48e5fc5..5ad3ca6 100644
--- a/tools/go-agent/instrument/api/flags.go
+++ b/tools/go-agent/instrument/api/flags.go
@@ -23,6 +23,7 @@ type CompileOptions struct {
Package string `swflag:"-p"`
Output string `swflag:"-o"`
AllArgs []string `swflag:"all-args"`
+ Lang string `swflag:"-lang"`
DebugDir string `swflag:"-debug"` // from tools flag
}
diff --git a/tools/go-agent/instrument/runtime/instrument.go
b/tools/go-agent/instrument/runtime/instrument.go
index 967ae7c..cf9adcd 100644
--- a/tools/go-agent/instrument/runtime/instrument.go
+++ b/tools/go-agent/instrument/runtime/instrument.go
@@ -18,6 +18,9 @@
package runtime
import (
+ "strconv"
+ "strings"
+
"github.com/dave/dst"
"github.com/dave/dst/dstutil"
@@ -26,8 +29,11 @@ import (
"github.com/apache/skywalking-go/tools/go-agent/tools"
)
+var defaultInternalAtomicPath = "runtime/internal/atomic"
+
type Instrument struct {
goIDType string
+ opts *api.CompileOptions
}
func NewInstrument() *Instrument {
@@ -35,6 +41,7 @@ func NewInstrument() *Instrument {
}
func (r *Instrument) CouldHandle(opts *api.CompileOptions) bool {
+ r.opts = opts
return opts.Package == "runtime"
}
@@ -98,6 +105,19 @@ func (r *Instrument) AfterEnhanceFile(fromPath, newPath
string) error {
return nil
}
+func (r *Instrument) parseInternalAtomicPath() string {
+ if strings.HasPrefix(r.opts.Lang, "go1.") {
+ _, after, found := strings.Cut(r.opts.Lang, ".")
+ if found {
+ i, err := strconv.ParseInt(after, 10, 64)
+ if err == nil && i >= 23 {
+ return "internal/runtime/atomic"
+ }
+ }
+ }
+ return defaultInternalAtomicPath
+}
+
// nolint
func (r *Instrument) WriteExtraFiles(dir string) ([]string, error) {
return tools.WriteMultipleFile(dir, map[string]string{
@@ -106,7 +126,7 @@ func (r *Instrument) WriteExtraFiles(dir string) ([]string,
error) {
import (
_ "unsafe"
- atomic "runtime/internal/atomic"
+ atomic "{{.InternalAtomicPath}}"
)
var {{.GlobalTracerFieldName}} interface{}
@@ -271,6 +291,7 @@ func goroutineChange(tls interface{}) interface{} {
MetricsObtainMethodName string
MetricsHookFieldName string
MetricsHookAppendMethodName string
+ InternalAtomicPath string
}{
TLSFiledName:
consts.TLSFieldName,
TLSGetMethod:
consts.TLSGetMethodName,
@@ -292,6 +313,7 @@ func goroutineChange(tls interface{}) interface{} {
MetricsObtainMethodName:
consts.MetricsObtainMethodName,
MetricsHookFieldName:
consts.MetricsHookFieldName,
MetricsHookAppendMethodName:
consts.MetricsHookAppendMethodName,
+ InternalAtomicPath:
r.parseInternalAtomicPath(),
}),
})
}