草庐IT

cpu 的 golang no/debug/pprof/profile 端点,同时拥有其他一切

coder 2024-07-07 原文

我对无法分析我的 golang 程序的问题感到非常困惑,我在/debug/pprof 下有所有其他端点但没有用于 CPU 分析的/debug/pprof/profile 有没有人偶然发现过这样的问题?

go tool pprof http://localhost:7778/debug/pprof/profile
Fetching profile from http://localhost:7778/debug/pprof/profile
Please wait... (30s)
server response: 404 Not Found

同时

/debug/pprof/

profiles:
19  block
31  goroutine
10  heap
0   mutex
11  threadcreate

full goroutine stack dump

我是这样配置的

r := http.NewServeMux()
r.Handle("/debug/pprof/", http.HandlerFunc(pprof.Index))

可能是什么原因?

更新:正在运行

http.ListenAndServe("localhost:4444", nil)

(即启动默认的 http 服务器)修复了我的自定义端点的问题

最佳答案

我遇到了和你一样的错误,我都是按照文档注册的。万一有人遇到同样的问题,原来你需要添加 http.DefaultServeMux,所以完整的行应该是:

  r := mux.NewRouter()

  r.PathPrefix("/debug/").Handler(http.DefaultServeMux)

  r.HandleFunc("/debug/pprof/", pprof.Index)
  r.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
  r.HandleFunc("/debug/pprof/profile", pprof.Profile)
  r.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
  r.HandleFunc("/debug/pprof/trace", pprof.Trace)

引用是 here

关于cpu 的 golang no/debug/pprof/profile 端点,同时拥有其他一切,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44065511/

有关cpu 的 golang no/debug/pprof/profile 端点,同时拥有其他一切的更多相关文章

  1. ruby - 其他文件中的 Rake 任务 - 2

    我试图在一个项目中使用rake,如果我把所有东西都放到Rakefile中,它会很大并且很难读取/找到东西,所以我试着将每个命名空间放在lib/rake中它自己的文件中,我添加了这个到我的rake文件的顶部:Dir['#{File.dirname(__FILE__)}/lib/rake/*.rake'].map{|f|requiref}它加载文件没问题,但没有任务。我现在只有一个.rake文件作为测试,名为“servers.rake”,它看起来像这样:namespace:serverdotask:testdoputs"test"endend所以当我运行rakeserver:testid时

  2. ruby - 如何将脚本文件的末尾读取为数据文件(Perl 或任何其他语言) - 2

    我正在寻找执行以下操作的正确语法(在Perl、Shell或Ruby中):#variabletoaccessthedatalinesappendedasafileEND_OF_SCRIPT_MARKERrawdatastartshereanditcontinues. 最佳答案 Perl用__DATA__做这个:#!/usr/bin/perlusestrict;usewarnings;while(){print;}__DATA__Texttoprintgoeshere 关于ruby-如何将脚

  3. ruby - 调用其他方法的 TDD 方法的正确方法 - 2

    我需要一些关于TDD概念的帮助。假设我有以下代码defexecute(command)casecommandwhen"c"create_new_characterwhen"i"display_inventoryendenddefcreate_new_character#dostufftocreatenewcharacterenddefdisplay_inventory#dostufftodisplayinventoryend现在我不确定要为什么编写单元测试。如果我为execute方法编写单元测试,那不是几乎涵盖了我对create_new_character和display_invent

  4. java - 我的模型类或其他类中应该有逻辑吗 - 2

    我只想对我一直在思考的这个问题有其他意见,例如我有classuser_controller和classuserclassUserattr_accessor:name,:usernameendclassUserController//dosomethingaboutanythingaboutusersend问题是我的User类中是否应该有逻辑user=User.newuser.do_something(user1)oritshouldbeuser_controller=UserController.newuser_controller.do_something(user1,user2)我

  5. spring.profiles.active和spring.profiles.include的使用及区别说明 - 2

    转自:spring.profiles.active和spring.profiles.include的使用及区别说明下文笔者讲述spring.profiles.active和spring.profiles.include的区别简介说明,如下所示我们都知道,在日常开发中,开发|测试|生产环境都拥有不同的配置信息如:jdbc地址、ip、端口等此时为了避免每次都修改全部信息,我们则可以采用以上的属性处理此类异常spring.profiles.active属性例:配置文件,可使用以下方式定义application-${profile}.properties开发环境配置文件:application-dev

  6. ruby - 使用 ruby​​ gem net-ssh-multi 同时在多个服务器上执行 sudo 命令 - 2

    在previousquestion中我想出了如何在多个服务器上启动经过密码验证的sshsession来运行单个命令。现在我需要能够执行“sudo”命令。问题是,net-ssh-multi没有分配sudo需要运行的伪终端(pty),导致以下错误:[127.0.0.1:stderr]sudo:sorry,youmusthaveattytorunsudo根据documentation,可以通过调用channel对象的方法来分配伪终端,但是,以下代码不起作用:它会生成上面的“notty”错误:require'net/ssh'require'net/ssh/multi'Net::SSH::Mul

  7. ruby - Formtastic,拥有 :as input type - 2

    如何将自己的字段类型添加到formtastic中?例如,我需要一个自定义的日期时间输入,我想要这样的东西::my_date%>这显然是行不通的,因为formtastic不知道:my_date(只有:boolean、:string、:datetime等等...)但是我怎样才能添加额外的输入类型呢? 最佳答案 您需要添加自定义输入法:classMyCustomFormtasticFormBuilder这非常适合新的HTML5输入类型。你可以这样使用它:MyCustomFormtasticFormBuilderdo|f|%>:my_dat

  8. ruby - 为什么在 Ruby 中一切都是 Class 的实例? - 2

    这个问题在这里已经有了答案:Rubymetaclassconfusion(4个答案)关闭7年前。我对Ruby对象模型不太了解。首先,Ruby中的一切都是Class的实例吗??这些都产生true:pObject.instance_of?(Class)pClass.instance_of?(Class)pModule.instance_of?(Class)pBasicObject.instance_of?(Class)classHello;endpHello.instance_of?(Class)我不太明白这怎么可能,如果Object是Class的父类(superclass),它怎么可能都

  9. ruby-on-rails - Ruby on Rails,在更新其他列值时更改列值 - 2

    我在Rails模型中有两列相互关联:Article.bodyArticle.body_updated_on每次Article.body更新时,我想将Article.body_updated_on更改为Time.now。如果任何其他字段已更新,则无需进行任何操作。 最佳答案 只需在将回调保存到您的文章模型之前添加classArticle 关于ruby-on-rails-RubyonRails,在更新其他列值时更改列值,我们在StackOverflow上找到一个类似的问题:

  10. ruby-on-rails - 用一系列时间增量填充选择,加上其他选项 - 2

    使用RubyonRails,我使用给定的增量(例如每30分钟)用时间填充“选择”。目前我正在YAML文件中写出所有的可能性,但我觉得有一种更巧妙的方法。我想我想提供一个开始时间、一个结束时间、一个增量,并且目前只提供一个名为“关闭”的选项(想想“business_hours”)。所以,我的选择可能会显示:'Closed'5:00am5:30am6:00am...[allthewayto]...11:30pm谁能想出更好的方法,或者只是将它们全部“拼写”出来的最佳方法? 最佳答案 此答案基于@emh的答案。defcreate_hour

随机推荐