Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

提供的pprof有问题 #1701

Closed
overstarry opened this issue Dec 20, 2021 · 12 comments
Closed

提供的pprof有问题 #1701

overstarry opened this issue Dec 20, 2021 · 12 comments
Labels
bug Something isn't working

Comments

@overstarry
Copy link
Contributor

使用了 pprof.NewHandler() 方法,访问 http://192.168.1.117:8888/debug/pprof/allocs?debug=1 404

Environment:

  • Kratos version (use kratos -v):
    kratos version v2.1.2
  • Go version (use go version):
    go version go1.16.3 windows/amd64
  • OS (e.g: cat /etc/os-release):
    win10
  • Others:
@overstarry overstarry added the bug Something isn't working label Dec 20, 2021
@shenqidebaozi
Copy link
Sponsor Member

shenqidebaozi commented Dec 20, 2021

提供个最小复现环境?

@overstarry
Copy link
Contributor Author

就在http.go里加了 srv.Handle("/debug/pprof/", pprof.NewHandler())这一行

@daemon365
Copy link
Member

试一下 srv.Handle("/", pprof.NewHandler())

@overstarry
Copy link
Contributor Author

srv.Handle("/", pprof.NewHandler())

不行

@daemon365
Copy link
Member

那你提供一下 最小仓库吧

@overstarry
Copy link
Contributor Author

好的

@overstarry
Copy link
Contributor Author

@overstarry
Copy link
Contributor Author

@haiyux

@daemon365
Copy link
Member

image
这不是可以的吗

@overstarry
Copy link
Contributor Author

点击allocs 404

@daemon365
Copy link
Member

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()
}

先试一下这个

@daemon365
Copy link
Member

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()
}

或者这个server.Handl() 是重写方法 使用哪个引入哪个就可以了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants