Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
124 commits
Select commit Hold shift + click to select a range
fcc3bca
feat(add profilefetchinterval)
cqhasy Jul 17, 2025
34c055f
feat(add fetchhandle,print task success)
cqhasy Jul 17, 2025
9178edd
fix(mod)
cqhasy Jul 20, 2025
0b7ddd6
feat(try get trace id in middleware and add profilemanager)
cqhasy Jul 21, 2025
48cbdaf
feat(add profile manager into repoter)
cqhasy Jul 22, 2025
c0d41c3
feat(add toProfile)
cqhasy Jul 22, 2025
f227ebb
feat(add profiling success and chunc splice,plan to report)
cqhasy Jul 25, 2025
ac8175a
fix(add some profile tools)
cqhasy Jul 30, 2025
1d56153
fix(pretend report,add end profile when trace end )
cqhasy Aug 1, 2025
325ec79
feat(try to add spanId label)
cqhasy Aug 1, 2025
e60dc3a
fix(add span label success)
cqhasy Aug 2, 2025
efaefe9
fix(before devide routinue)
cqhasy Aug 9, 2025
25e219e
fix(change ctx,delete stop span,enable routinues profile)
cqhasy Aug 11, 2025
6c43a54
fix(add currentTask struct)
cqhasy Aug 12, 2025
de4b252
fix(Translate the comments from Chinese into English,test final with …
cqhasy Aug 14, 2025
5568022
Merge branch 'main' into main
mrproliu Aug 14, 2025
85f6f20
fix(move the task cache to report)
cqhasy Aug 18, 2025
6e095d0
fix(devide no related method from repoter)
cqhasy Aug 19, 2025
8a2d862
Devide no related method from repoter Merge branch 'main' of github.c…
cqhasy Aug 19, 2025
2534de1
fix(solve the memory buffer to weight problem)
cqhasy Aug 22, 2025
9579f9f
feat(add owen add profile labels logic)
cqhasy Aug 24, 2025
8eabad6
fix(change profile test name,use to profile.go)
cqhasy Aug 24, 2025
4d0538d
change profile location
cqhasy Aug 27, 2025
ee2e86b
feat(add profile invoke logic)
cqhasy Aug 29, 2025
6492822
feat(update plugins/go.mod goapi to latest)
cqhasy Aug 31, 2025
aa8e811
fix(add license headers to core and pprof plugins)
cqhasy Aug 31, 2025
98c6867
fix (change go.work version)
cqhasy Aug 31, 2025
ce99dd7
fix(add NewProfileManager for test_base)
cqhasy Aug 31, 2025
a87b28b
chore(change grpc version from 1.73 to 1.55,delete slices,use sort)
cqhasy Sep 2, 2025
8f6739c
fix(keep the go.mod go.work original format)
cqhasy Sep 2, 2025
7447e53
fix(delete duplicated method in pprof_labels)
cqhasy Sep 2, 2025
1cc674a
feat(add log for profileManager)
cqhasy Sep 3, 2025
90ec5cb
fix(Separate profiling from specific traces)
cqhasy Sep 5, 2025
e4c9e6b
feat(add data collect proto in go agent)
cqhasy Sep 6, 2025
a6952b6
Lock skywalking-data-collect-protocol to specific version
cqhasy Sep 6, 2025
151cadd
fix(change pull-proto.sh to adapt git submodule)
cqhasy Sep 6, 2025
4e1e9aa
feat(add generate-proto in workflows)
cqhasy Sep 7, 2025
595a35b
fix (remove git submodule update in pull-proto.sh)
cqhasy Sep 7, 2025
d317ecf
feat(add license in file and check if install protoc in make proto)
cqhasy Sep 7, 2025
14eade2
fix(solve tar protoc no power in CI)
cqhasy Sep 7, 2025
1645ab7
fix(lower protoc-gen-go-grpc version in CI,fix expoter for protoc)
cqhasy Sep 7, 2025
95219ac
fix(keep pull-proto.sh protoc path same with user download)
cqhasy Sep 7, 2025
f111ad4
feat(ignore tools/protocols/temp)
cqhasy Sep 7, 2025
2ca045c
fix(add goPROXY,add unzip process info)
cqhasy Sep 7, 2025
f9c18e5
fix(lower /protoc-gen-go-grpc /protoc-gen-go version, install dos2uni…
cqhasy Sep 7, 2025
2f1a379
fix(back golang.org/x/net, add go version in pull-proto)
cqhasy Sep 7, 2025
4ccf44f
fix(ignore protocols license,lower go mod to adapt go 1.19)
cqhasy Sep 7, 2025
2efd447
fix(ignore proto license,add make proto for test,extend wait time )
cqhasy Sep 8, 2025
2a0ae41
fix(change protocol import path to access lint,add some log info in h…
cqhasy Sep 8, 2025
301beb8
fix(adapt to lint,add GOPONXY in kafka E2E,extend sleep time in wsl-s…
cqhasy Sep 8, 2025
3e11a49
fix(force e2e test use 1.19,add generate proto in build)
cqhasy Sep 9, 2025
111f712
fix(change infra-e2e version,devide zip install in windows and linux)
cqhasy Sep 9, 2025
8f25978
fix(change infra-e2e)
cqhasy Sep 9, 2025
8fe61bf
fix(advance install docker)
cqhasy Sep 9, 2025
dac5c6c
fix(add env /bin/bash)
cqhasy Sep 9, 2025
4942066
fix(add PATH user/bin)
cqhasy Sep 9, 2025
bc6a8a5
fix(add go-version)
cqhasy Sep 9, 2025
062c4f8
fix(force go-version)
cqhasy Sep 9, 2025
d6486ab
roll back
cqhasy Sep 9, 2025
0ff9580
use 1.24 to adapt apache/skywalking-infra-e2e
cqhasy Sep 9, 2025
64f08f0
fix(fix e2e.yaml)
cqhasy Sep 9, 2025
865b4c1
role back to pull request
cqhasy Sep 9, 2025
f6725df
fix(merge dev2 and dev3)
cqhasy Sep 9, 2025
6d6bbc3
fix(add some DNS log for wsl-scenarios)
cqhasy Sep 9, 2025
1b5839e
fix(change HTTP_HOST from service to 127.0.0.1)
cqhasy Sep 10, 2025
2bbb8d6
fix(delete Chinese notes in pull-proto.sh)
cqhasy Sep 10, 2025
f32a8d5
fix(role back)
cqhasy Sep 10, 2025
3f1100a
fix(try print container status)
cqhasy Sep 10, 2025
26047d2
fix(try print container status)
cqhasy Sep 10, 2025
b9f4146
fix(try print container status)
cqhasy Sep 10, 2025
e6b4628
fix(try print container status)
cqhasy Sep 10, 2025
3818324
fix(try print container status)
cqhasy Sep 10, 2025
2625ba0
fix(try print container status)
cqhasy Sep 10, 2025
d90f993
role back action on
cqhasy Sep 10, 2025
a4ce676
chang windows host
cqhasy Sep 10, 2025
d190906
role back windows host
cqhasy Sep 10, 2025
61a7727
select could use windows host
cqhasy Sep 10, 2025
ab84e58
add more log info,extend curl time
cqhasy Sep 10, 2025
abcf0d2
roll workflows on
cqhasy Sep 11, 2025
3cfa652
test
cqhasy Sep 11, 2025
7a3c2aa
add resolv info
cqhasy Sep 11, 2025
6f8fc85
roll workflows on
cqhasy Sep 11, 2025
8deff0d
dont use resolv.conf
cqhasy Sep 11, 2025
8983f85
fix(add full log when get ip in windows)
cqhasy Sep 11, 2025
a849a09
roll back workflows on
cqhasy Sep 11, 2025
35035fa
delete generate proto in e2e
cqhasy Sep 11, 2025
4c9ec42
fix(delete generate proto in CI)
cqhasy Sep 11, 2025
941a29d
fix(rename pull-proto.sh,delete no use shell in pull-proto.sh,add cha…
cqhasy Sep 11, 2025
328a144
fix(mov changes from doc to feature,delete some common)
cqhasy Sep 11, 2025
d697977
fix(delete make generate proto in publish docker)
cqhasy Sep 11, 2025
5595008
feat(add delete temp in generate.sh)
cqhasy Sep 11, 2025
eee3bfe
before merge dev2
cqhasy Sep 12, 2025
03196b5
after merge
cqhasy Sep 12, 2025
c337161
fix(remove runtime/pprof.runtime_getProfLabel to avoid version error)
cqhasy Sep 12, 2025
ec7f548
fix(fix lint error)
cqhasy Sep 13, 2025
c94385a
feat(add no getProfileTask RPC err log)
cqhasy Sep 13, 2025
075831a
fix(fix zap log order error)
cqhasy Sep 13, 2025
dd21590
feat(add GetProfileTask grpc err in logrus)
cqhasy Sep 13, 2025
78834f6
fix(fix excepted.yml)
cqhasy Sep 13, 2025
12b283e
test
cqhasy Sep 13, 2025
ab908d9
test
cqhasy Sep 13, 2025
45f276b
test
cqhasy Sep 13, 2025
b441ce3
fix(update skywalking-agent-test-tool)
cqhasy Sep 14, 2025
e9d4c25
roll back ci
cqhasy Sep 14, 2025
12626e8
Merge branch 'main' into main
cqhasy Sep 14, 2025
45fab22
fix(delete unnecessary newline,fix command.pd taskID to taskId,Adjust…
cqhasy Sep 15, 2025
c2b9f1a
fix(enable setting labels for goroutines, optimize label storage, and…
cqhasy Sep 21, 2025
b6be276
test(test ci)
cqhasy Sep 21, 2025
a470a19
fix(add license in share.go)
cqhasy Sep 21, 2025
f7b89fe
fix(roll back)
cqhasy Sep 21, 2025
d59ab2e
fix(change TraceProfileTask to impl,delete the no using instrument)
cqhasy Sep 26, 2025
c73a289
test ci
cqhasy Sep 26, 2025
ea9a467
fix ci
cqhasy Sep 26, 2025
c2f646e
before merge origin
cqhasy Sep 28, 2025
91c5a33
merge(merge the go trace profile func)
cqhasy Sep 28, 2025
6af1c4c
fix(ci log error)
cqhasy Sep 28, 2025
efd26aa
roll back ci
cqhasy Sep 29, 2025
9bf7a23
fix(use regexp not string to compare version,use own set function not…
cqhasy Oct 8, 2025
67252e5
fix(delete no use counter,rename event manager,fix ci)
cqhasy Oct 10, 2025
0470716
feat(add pprof plugins test)
cqhasy Oct 11, 2025
09ddf95
fix(replace kafka docker image to bitnamilegacy)
cqhasy Oct 11, 2025
76a7f4a
fix(fix lint error)
cqhasy Oct 11, 2025
633e15c
roll back ci
cqhasy Oct 11, 2025
bb371a8
fix(use profile task quece not singleton,use timefunc to start profile)
cqhasy Oct 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions agent/core/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package core
import (
//go:nolint
_ "bytes"
_ "context"
_ "encoding/base64"
_ "fmt"
_ "io"
Expand All @@ -30,6 +31,7 @@ import (
_ "os"
_ "path/filepath"
_ "reflect"
_ "regexp"
_ "runtime"
_ "runtime/debug"
_ "runtime/metrics"
Expand All @@ -45,6 +47,7 @@ import (
//go:nolint
_ "github.com/apache/skywalking-go/agent/core/metrics"
_ "github.com/apache/skywalking-go/agent/core/operator"
_ "github.com/apache/skywalking-go/agent/core/profile"
_ "github.com/apache/skywalking-go/agent/core/tracing"
_ "github.com/apache/skywalking-go/agent/reporter"
_ "github.com/apache/skywalking-go/log"
Expand Down
41 changes: 41 additions & 0 deletions agent/core/profile/compile.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Licensed to Apache Software Foundation (ASF) under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Apache Software Foundation (ASF) licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

package profile

import (
//go:nolint
_ "bytes"
_ "context"
_ "fmt"
_ "runtime/pprof"
_ "strconv"
_ "strings"
_ "sync"
_ "sync/atomic"
_ "time"
_ "unsafe"

//go:nolint
_ "github.com/pkg/errors"

//go:nolint
_ "github.com/apache/skywalking-go/agent/core/operator"

//go:nolint
_ "github.com/apache/skywalking-go/agent/reporter"
)
6 changes: 5 additions & 1 deletion agent/reporter/imports.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,26 @@ package reporter

import (
// imports required packages for gRPC reporter
_ "bytes"
_ "context"
_ "crypto/tls"
_ "crypto/x509"
_ "fmt"
_ "io"
_ "os"
_ "runtime"
_ "runtime/pprof"
_ "strconv"
_ "strings"
_ "sync"
_ "time"

// imports the logs for reporter
// imports the logs and profiles for reporter
_ "github.com/apache/skywalking-go/agent/core/operator"
_ "github.com/apache/skywalking-go/log"

// imports configuration and starter for gRPC
_ "github.com/pkg/errors"
_ "google.golang.org/grpc"
_ "google.golang.org/grpc/backoff"
_ "google.golang.org/grpc/balancer"
Expand Down
3 changes: 3 additions & 0 deletions go.work
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use (
./plugins/rocketmq
./plugins/amqp
./plugins/pulsar
./plugins/pprof
./plugins/segmentio-kafka
./plugins/go-elasticsearchv8
./plugins/goframe
Expand Down Expand Up @@ -72,8 +73,10 @@ use (
./test/plugins/scenarios/goframe
./test/plugins/scenarios/so11y
./test/plugins/scenarios/cross-goroutine
./test/plugins/scenarios/pprof

./tools/go-agent

./toolkit
)

213 changes: 79 additions & 134 deletions plugins/core/go.sum

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions plugins/core/operator/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var MetricsCollectAppender = func(func()) {}
type Operator interface {
Tracing() interface{} // to TracingOperator
Logger() interface{} // to LogOperator
Profiler() interface{} // to ProfileOperator
Tools() interface{} // to ToolsOperator
DebugStack() []byte // Getting the stack of the current goroutine, for getting details when plugin broken.
Entity() interface{} // Get the entity of the service
Expand Down
23 changes: 23 additions & 0 deletions plugins/core/operator/profiler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

package operator

type ProfileOperator interface {
// GetNowLabels get skywalking internal labels from goroutine,avoid covered by user
GetNowLabels() interface{}
}
221 changes: 221 additions & 0 deletions plugins/core/prof_labels.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

package core

import (
"context"
"regexp"
"runtime"
"runtime/pprof"
"sort"
"strconv"
"unsafe"
)

type label struct {
key string
value string
}

type LabelSet struct {
list []label
}

type labelMap struct {
LabelSet
}

type labelMap19 map[string]string

type labelContextKey struct{}

//go:linkname runtimeGetProfLabel runtime/pprof.runtime_getProfLabel
func runtimeGetProfLabel() unsafe.Pointer

//go:linkname runtimeSetProfLabel runtime/pprof.runtime_setProfLabel
func runtimeSetProfLabel(label unsafe.Pointer)

func setGoroutineLabelsInternal(ctx context.Context) {
if isGoVersionLMoreThan120(runtime.Version()) {
ctxLabels, _ := ctx.Value(labelContextKey{}).(*labelMap)
runtimeSetProfLabel(unsafe.Pointer(ctxLabels))
return
}
ctxLabels, _ := ctx.Value(labelContextKey{}).(*labelMap19)
runtimeSetProfLabel(unsafe.Pointer(ctxLabels))
}

func labelValue(ctx context.Context) labelMap19 {
labels, _ := ctx.Value(labelContextKey{}).(*labelMap19)
if labels == nil {
return labelMap19(nil)
}
return *labels
}

func WithLabels(ctx context.Context, s LabelSet) context.Context {
if isGoVersionLMoreThan120(runtime.Version()) {
ctx = context.WithValue(ctx, labelContextKey{}, &labelMap{s})
return ctx
}
return withLabels19(ctx, s)
}

func withLabels19(ctx context.Context, labels LabelSet) context.Context {
childLabels := make(labelMap19)
parentLabels := labelValue(ctx)
for k, v := range parentLabels {
childLabels[k] = v
}
for _, label := range labels.list {
childLabels[label.key] = label.value
}
return context.WithValue(ctx, labelContextKey{}, &childLabels)
}

func GetNowLabelSet() LabelSet {
pl := LabelSet{
list: make([]label, 0),
}
p := runtimeGetProfLabel()
if p != nil {
version := runtime.Version()
if !isGoVersionLMoreThan120(version) {
// Go1.19:map[string]string -> []label
m := *(*labelMap19)(p)
pl.list = make([]label, 0, len(m))
for k, v := range m {
pl.list = append(pl.list, label{key: k, value: v})
}
} else {
lm := (*labelMap)(p)
pl.list = lm.list
}
}
return pl
}

// isGoVersionLMoreThan120 parses version strings like "go1.19.8"
func isGoVersionLMoreThan120(version string) bool {
re := regexp.MustCompile(`go(\d+)\.(\d+)`)
sub := re.FindStringSubmatch(version)
if len(sub) != 3 {
return false
}
major, err1 := strconv.Atoi(sub[1])
minor, err2 := strconv.Atoi(sub[2])
if err1 != nil || err2 != nil {
return false
}
if major < 1 {
return false
}
if major > 1 {
return true
}
return minor >= 20
}

func (m *ProfileManager) AddSkyLabels(traceID, segmentID string, spanID int32) interface{} {
pl := GetNowLabelSet()
re := UpdateTraceLabels(pl, TraceLabel, traceID, SegmentLabel, segmentID, SpanLabel, parseString(spanID))
return &re
}

func (m *ProfileManager) TurnToPprofLabel(l *LabelSet) pprof.LabelSet {
li := l.List()
if len(li) == 0 {
return pprof.LabelSet{}
}
re := pprof.Labels(li...)
return re
}

func UpdateTraceLabels(s LabelSet, args ...string) LabelSet {
if len(args)%2 != 0 {
panic("uneven number of arguments to profile.UpdateTraceLabels")
}

// add first
for i := 0; i < len(args); i += 2 {
s.list = append(s.list, label{key: args[i], value: args[i+1]})
}

// sort
sort.SliceStable(s.list, func(i, j int) bool {
return s.list[i].key < s.list[j].key
})

// remove duplicates
deduped := make([]label, 0, len(s.list))
for i, lbl := range s.list {
if i == 0 || lbl.key != s.list[i-1].key {
deduped = append(deduped, lbl)
} else {
deduped[len(deduped)-1] = lbl
}
}
s.list = deduped

return s
}

func (s *LabelSet) List() []string {
var ret []string
for _, v := range s.list {
ret = append(ret, v.key, v.value)
}
return ret
}

func SetGoroutineLabels(s *LabelSet) {
if s.IsEmpty() {
var c = context.Background()
setGoroutineLabelsInternal(c)
return
}
var c = context.Background()
l := *s
c = WithLabels(c, l)
setGoroutineLabelsInternal(c)
}

func extractSkyInternalLabels(s LabelSet) LabelSet {
re := LabelSet{list: make([]label, 0)}
for _, l := range s.list {
if l.key == SpanLabel || l.key == SegmentLabel || l.key == TraceLabel || l.key == MinDurationLabel {
re.list = append(re.list, l)
}
}
return re
}

// GetNowLabels Expose to operator
func (m *ProfileManager) GetNowLabels() interface{} {
row := GetNowLabelSet()
filter := extractSkyInternalLabels(row)
re := m.TurnToPprofLabel(&filter)
return re
}

func (s *LabelSet) IsEmpty() bool {
if s == nil || s.list == nil {
return true
}
return len(s.list) == 0
}
Loading
Loading