From ca5c95f6fe90320a40b3a67bdb8e2b3b6a2f8293 Mon Sep 17 00:00:00 2001 From: Jin Date: Tue, 1 Nov 2022 14:19:43 +0800 Subject: [PATCH] Support gops --- common/profiling/profiling.go | 6 ++++++ go.mod | 1 + go.sum | 2 ++ 3 files changed, 9 insertions(+) diff --git a/common/profiling/profiling.go b/common/profiling/profiling.go index e00546b2..ec7cebd6 100644 --- a/common/profiling/profiling.go +++ b/common/profiling/profiling.go @@ -3,6 +3,7 @@ package profiling import ( "fmt" "github.com/Qitmeer/qng/config" + "github.com/google/gops/agent" "net" "net/http" "os" @@ -37,6 +38,11 @@ func Start(port string) { log.Error(err.Error()) } }() + go func() { + if err := agent.Listen(agent.Options{}); err != nil { + log.Error(err.Error()) + } + }() } // TrackHeap tracks the size of the heap and dumps a profile if it passes a limit diff --git a/go.mod b/go.mod index 96388ef2..22e054a5 100644 --- a/go.mod +++ b/go.mod @@ -17,6 +17,7 @@ require ( github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3 github.com/golang/protobuf v1.5.2 github.com/golang/snappy v0.0.4 + github.com/google/gops v0.3.25 github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d github.com/ipfs/go-ds-leveldb v0.5.0 github.com/jessevdk/go-flags v1.4.0 diff --git a/go.sum b/go.sum index 1ef258e4..99f58918 100644 --- a/go.sum +++ b/go.sum @@ -290,6 +290,8 @@ github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/ github.com/google/gopacket v1.1.17/go.mod h1:UdDNZ1OO62aGYVnPhxT1U6aI7ukYtA/kB8vaU0diBUM= github.com/google/gopacket v1.1.19 h1:ves8RnFZPGiFnTS0uPQStjwru6uO6h+nlr9j6fL7kF8= github.com/google/gopacket v1.1.19/go.mod h1:iJ8V8n6KS+z2U1A8pUwu8bW5SyEMkXJB8Yo/Vo+TKTo= +github.com/google/gops v0.3.25 h1:Pf6uw+cO6pDhc7HJ71NiG0x8dyQTeQcmg3HQFF39qVw= +github.com/google/gops v0.3.25/go.mod h1:8A7ebAm0id9K3H0uOggeRVGxszSvnlURun9mg3GdYDw= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=