Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
bdfc8757
authored
Dec 13, 2025
by
Seefs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: pyroscope integrate
parent
7d586ef5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
89 additions
and
17 deletions
+89
-17
common/pyro.go
+49
-0
go.mod
+3
-1
go.sum
+32
-16
main.go
+5
-0
No files found.
common/pyro.go
0 → 100644
View file @
bdfc8757
package
common
import
(
"os"
"runtime"
"github.com/grafana/pyroscope-go"
)
func
StartPyroScope
()
error
{
pyroscopeUrl
:=
os
.
Getenv
(
"PYROSCOPE_URL"
)
if
pyroscopeUrl
==
""
{
return
nil
}
// These 2 lines are only required if you're using mutex or block profiling
// Read the explanation below for how to set these rates:
runtime
.
SetMutexProfileFraction
(
5
)
runtime
.
SetBlockProfileRate
(
5
)
_
,
err
:=
pyroscope
.
Start
(
pyroscope
.
Config
{
ApplicationName
:
SystemName
,
ServerAddress
:
pyroscopeUrl
,
Logger
:
nil
,
Tags
:
map
[
string
]
string
{
"hostname"
:
GetEnvOrDefaultString
(
"HOSTNAME"
,
"new-api"
)},
ProfileTypes
:
[]
pyroscope
.
ProfileType
{
pyroscope
.
ProfileCPU
,
pyroscope
.
ProfileAllocObjects
,
pyroscope
.
ProfileAllocSpace
,
pyroscope
.
ProfileInuseObjects
,
pyroscope
.
ProfileInuseSpace
,
pyroscope
.
ProfileGoroutines
,
pyroscope
.
ProfileMutexCount
,
pyroscope
.
ProfileMutexDuration
,
pyroscope
.
ProfileBlockCount
,
pyroscope
.
ProfileBlockDuration
,
},
})
if
err
!=
nil
{
return
err
}
return
nil
}
go.mod
View file @
bdfc8757
...
@@ -27,6 +27,7 @@ require (
...
@@ -27,6 +27,7 @@ require (
github.com/golang-jwt/jwt/v5 v5.3.0
github.com/golang-jwt/jwt/v5 v5.3.0
github.com/google/uuid v1.6.0
github.com/google/uuid v1.6.0
github.com/gorilla/websocket v1.5.0
github.com/gorilla/websocket v1.5.0
github.com/grafana/pyroscope-go v1.2.7
github.com/jfreymuth/oggvorbis v1.0.5
github.com/jfreymuth/oggvorbis v1.0.5
github.com/jinzhu/copier v0.4.0
github.com/jinzhu/copier v0.4.0
github.com/joho/godotenv v1.5.1
github.com/joho/godotenv v1.5.1
...
@@ -77,11 +78,11 @@ require (
...
@@ -77,11 +78,11 @@ require (
github.com/go-sql-driver/mysql v1.7.0 // indirect
github.com/go-sql-driver/mysql v1.7.0 // indirect
github.com/go-webauthn/x v0.1.25 // indirect
github.com/go-webauthn/x v0.1.25 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/go-tpm v0.9.5 // indirect
github.com/google/go-tpm v0.9.5 // indirect
github.com/gorilla/context v1.1.1 // indirect
github.com/gorilla/context v1.1.1 // indirect
github.com/gorilla/securecookie v1.1.1 // indirect
github.com/gorilla/securecookie v1.1.1 // indirect
github.com/gorilla/sessions v1.2.1 // indirect
github.com/gorilla/sessions v1.2.1 // indirect
github.com/grafana/pyroscope-go/godeltaprof v0.1.9 // indirect
github.com/icza/bitio v1.1.0 // indirect
github.com/icza/bitio v1.1.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
...
@@ -91,6 +92,7 @@ require (
...
@@ -91,6 +92,7 @@ require (
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.8 // indirect
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
...
...
go.sum
View file @
bdfc8757
This diff is collapsed.
Click to expand it.
main.go
View file @
bdfc8757
...
@@ -124,6 +124,11 @@ func main() {
...
@@ -124,6 +124,11 @@ func main() {
common
.
SysLog
(
"pprof enabled"
)
common
.
SysLog
(
"pprof enabled"
)
}
}
err
=
common
.
StartPyroScope
()
if
err
!=
nil
{
common
.
SysError
(
fmt
.
Sprintf
(
"start pyroscope error : %v"
,
err
))
}
// Initialize HTTP server
// Initialize HTTP server
server
:=
gin
.
New
()
server
:=
gin
.
New
()
server
.
Use
(
gin
.
CustomRecovery
(
func
(
c
*
gin
.
Context
,
err
any
)
{
server
.
Use
(
gin
.
CustomRecovery
(
func
(
c
*
gin
.
Context
,
err
any
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment