Comments (4)
🤖
Based on a similar issue I found in the Kratos repository, you might need to adjust how you're setting up the pprof handler in your Kratos application. Here are two examples of how you can do this:
package main
import (
"github.com/go-kratos/kratos/v2"
"github.com/go-kratos/kratos/v2/transport/http"
"github.com/go-kratos/kratos/v2/transport/http/pprof"
)
func main() {
server := http.NewServer(
http.Address("0.0.0.0:8882"),
)
server.HandlePrefix("/", pprof.NewHandler())
kratos.New(kratos.Server(server)).Run()
}
Or this one:
package main
import (
"github.com/go-kratos/kratos/v2"
"github.com/go-kratos/kratos/v2/transport/http"
"github.com/go-kratos/kratos/v2/transport/http/pprof"
)
func main() {
server := http.NewServer(
http.Address("0.0.0.0:8882"),
)
server.HandlePrefix("/", pprof.NewHandler())
server.Handle("/debug/pprof/", pprof.NewHandler())
server.Handle("/debug/pprof/cmdline", pprof.NewHandler())
server.Handle("/debug/pprof/profile", pprof.NewHandler())
server.Handle("/debug/pprof/symbol", pprof.NewHandler())
server.Handle("/debug/pprof/trace", pprof.NewHandler())
kratos.New(kratos.Server(server)).Run()
}
The server.Handle()
is a rewrite method. You can use whichever one you need. You can find more details about this issue here.
Regarding your question about validating the pprof profile, the pprof tool needs some time to collect profiling data. When you access the "/debug/pprof/profile" endpoint, it collects CPU profile for 30 seconds by default. If you try to access the data immediately, it might appear empty because the profiling data has not been collected yet. Try waiting for at least 30 seconds before trying to access the data.
The pprof.NewHandler()
function in the Kratos codebase is used to create a new HTTP handler that serves the pprof debugging information. This handler is then used to serve HTTP requests. You can find more details about this function in the Kratos codebase.
I hope this helps! Let me know if you have any other questions.
Sources
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
If you want to continue the conversation, start your reply with @dosu-bot.
from kratos.
🤖
Hello @asker-github,
I'm Dosu, a bot here to assist you. I can help with bug solving, answer your questions, and guide you on becoming a contributor. While we wait for a human maintainer, I'm here to ensure you get the help you need.
I'm currently reviewing your issue and will get back to you with a comprehensive response shortly.
from kratos.
Partial code has been omitted from the provided code. From the provided code, it can be seen that there is no registered pprof
interface. Duso has provided relevant prompts, please check if it cannot be obtained due to non registration
from kratos.
Partial code has been omitted from the provided code. From the provided code, it can be seen that there is no registered
pprof
interface. Duso has provided relevant prompts, please check if it cannot be obtained due to non registration
Thank you for your reply. I think it was because the processing was too fast and could not be detected.
from kratos.
Related Issues (20)
- [Feature]Add svrType related fields in proto to protoc-gen-go-http and http transport HOT 3
- proto file used to build the api document reported an error HOT 1
- consul watch, the server is offline and will not receive any notification HOT 6
- [Feature] Add NewClient method to gRPC Client HOT 3
- [Question] DDD的最佳实践方式?包括CQRS、Clean Architecture、六边形结构 HOT 5
- [Question]请教下kratos如何定义支持上传文件接口? HOT 2
- metrics statistics and usage issues [Question] HOT 5
- `stream` response in proto failed to generate http client HOT 6
- [Feature] Add kratos errors to buf remote plugin HOT 1
- [Question] I modified it based on examples/helloworld and found that client/main.go reported an error when executing. I am not sure if it is a BUG. HOT 1
- HTTPClient proto: syntax error (line 1:1): unexpected token 404 HOT 3
- [Question] how to set response content-type as xml for one method HOT 2
- [Question] HTTP Server. extra add route do not pass middleware. HOT 2
- I a new release due soon ? HOT 4
- [Question] Can I custom project layouts by using kratos to generate HOT 1
- [Question]Excuse me, what is the error when compiling? HOT 2
- Kratos middleware seems to only apply to unary gRPC operations HOT 7
- t
- [Question] About the current p2c algorithm HOT 1
- bug in Quick Start HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kratos.