-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [collector]support pyroscope ebpf data (#471)
- Loading branch information
1 parent
0b10d1a
commit d975f20
Showing
14 changed files
with
7,037 additions
and
1 deletion.
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 |
---|---|---|
@@ -1 +1 @@ | ||
0.64.x | ||
0.65.x |
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
module github.com/TencentBlueKing/bkmonitor-datalink/pkg/collector/example/pyroscope/push | ||
|
||
go 1.22.3 | ||
|
||
require ( | ||
connectrpc.com/connect v1.16.2 | ||
github.com/TencentBlueKing/bkmonitor-datalink/pkg/collector v0.0.0-00010101000000-000000000000 | ||
) | ||
|
||
require ( | ||
github.com/gorilla/mux v1.8.0 // indirect | ||
github.com/planetscale/vtprotobuf v0.6.0 // indirect | ||
golang.org/x/net v0.25.0 // indirect | ||
golang.org/x/sys v0.20.0 // indirect | ||
golang.org/x/text v0.15.0 // indirect | ||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect | ||
google.golang.org/grpc v1.63.1 // indirect | ||
google.golang.org/protobuf v1.33.0 // indirect | ||
) | ||
|
||
replace ( | ||
github.com/TencentBlueKing/bkmonitor-datalink/pkg/collector => ../../../ | ||
k8s.io/apiserver => k8s.io/apiserver v0.25.0 | ||
k8s.io/cli-runtime => k8s.io/cli-runtime v0.25.0 | ||
k8s.io/cloud-provider => k8s.io/cloud-provider v0.25.0 | ||
k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.25.0 | ||
k8s.io/code-generator => k8s.io/code-generator v0.25.0 | ||
k8s.io/component-helpers => k8s.io/component-helpers v0.25.0 | ||
k8s.io/controller-manager => k8s.io/controller-manager v0.25.0 | ||
k8s.io/cri-api => k8s.io/cri-api v0.25.0 | ||
k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.25.0 | ||
k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.25.0 | ||
k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.25.0 | ||
k8s.io/kube-proxy => k8s.io/kube-proxy v0.25.0 | ||
k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.25.0 | ||
k8s.io/kubectl => k8s.io/kubectl v0.25.0 | ||
k8s.io/kubelet => k8s.io/kubelet v0.25.0 | ||
k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.25.0 | ||
k8s.io/metrics => k8s.io/metrics v0.25.0 | ||
k8s.io/mount-utils => k8s.io/mount-utils v0.25.0 | ||
k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.25.0 | ||
) |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
connectrpc.com/connect v1.16.2 h1:ybd6y+ls7GOlb7Bh5C8+ghA6SvCBajHwxssO2CGFjqE= | ||
connectrpc.com/connect v1.16.2/go.mod h1:n2kgwskMHXC+lVqb18wngEpF95ldBHXjZYJussz5FRc= | ||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= | ||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= | ||
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= | ||
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= | ||
github.com/planetscale/vtprotobuf v0.6.0 h1:nBeETjudeJ5ZgBHUz1fVHvbqUKnYOXNhsIEabROxmNA= | ||
github.com/planetscale/vtprotobuf v0.6.0/go.mod h1:t/avpk3KcrXxUnYOhZhMXJlSEyie6gQbtLq5NM3loB8= | ||
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= | ||
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= | ||
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= | ||
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= | ||
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= | ||
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= | ||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de h1:cZGRis4/ot9uVm639a+rHCUaG0JJHEsdyzSQTMX+suY= | ||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:H4O17MA/PE9BsGx3w+a+W2VOLLD1Qf7oJneAoU6WktY= | ||
google.golang.org/grpc v1.63.1 h1:pNClQmvdlyNUiwFETOux/PYqfhmA7BrswEdGRnib1fA= | ||
google.golang.org/grpc v1.63.1/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= | ||
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= | ||
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= |
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 |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// Tencent is pleased to support the open source community by making | ||
// 蓝鲸智云 - 监控平台 (BlueKing - Monitor) available. | ||
// Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. | ||
// Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at http://opensource.org/licenses/MIT | ||
// 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 main | ||
|
||
import ( | ||
"bytes" | ||
"context" | ||
"log" | ||
"math/rand" | ||
"net/http" | ||
"runtime/pprof" | ||
"time" | ||
|
||
"connectrpc.com/connect" | ||
|
||
pushv1 "github.com/TencentBlueKing/bkmonitor-datalink/pkg/collector/receiver/pyroscope/gen/proto/go/push/v1" | ||
"github.com/TencentBlueKing/bkmonitor-datalink/pkg/collector/receiver/pyroscope/gen/proto/go/push/v1/pushv1connect" | ||
typesv1 "github.com/TencentBlueKing/bkmonitor-datalink/pkg/collector/receiver/pyroscope/gen/proto/go/types/v1" | ||
) | ||
|
||
func collectCpuProfile() ([]byte, error) { | ||
var buf bytes.Buffer | ||
if err := pprof.StartCPUProfile(&buf); err != nil { | ||
log.Println(err) | ||
return nil, err | ||
} | ||
|
||
// random wait [1, 10] seconds | ||
waitSecond := time.Duration(rand.Intn(10)) + 1 | ||
time.Sleep(time.Second * waitSecond) | ||
pprof.StopCPUProfile() | ||
|
||
return buf.Bytes(), nil | ||
} | ||
|
||
func main() { | ||
client := pushv1connect.NewPusherServiceClient( | ||
http.DefaultClient, | ||
"http://localhost:4318", | ||
) | ||
cpuProfile, err := collectCpuProfile() | ||
if err != nil { | ||
log.Println(err) | ||
return | ||
} | ||
req := connect.NewRequest(&pushv1.PushRequest{ | ||
Series: []*pushv1.RawProfileSeries{ | ||
{ | ||
Labels: []*typesv1.LabelPair{ | ||
{Name: "service_name", Value: "test_service"}, | ||
{Name: "env", Value: "test"}, | ||
}, | ||
Samples: []*pushv1.RawSample{ | ||
{ | ||
RawProfile: cpuProfile, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}) | ||
req.Header().Set("X-BK-TOKEN", "Ymtia2JrYmtia2JrYmtiaxUtdLzrldhHtlcjc1Cwfo1u99rVk5HGe8EjT761brGtKm3H4Ran78rWl85HwzfRgw==") | ||
res, err := client.Push( | ||
context.Background(), | ||
req, | ||
) | ||
if err != nil { | ||
log.Println(err) | ||
return | ||
} | ||
log.Println(res.Msg) | ||
} |
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
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
Oops, something went wrong.