The Go Programming Language
http://golang.org/
Go Playground
Go Projects
Revel Web Framework
ry_wang

不知道有什么应用程序状态收集方案,求大家推荐

  •  
  •   ry_wang ·
    saipanno · Oct 31, 2017 · 1754 views
    This topic created in 3200 days ago, the information mentioned may be changed or developed.
    现在线上的程序逻辑比较复杂,协程较多。有的时候会碰到一些异常问题,需要一个较好的 bug 追踪方案。

    目前我们的做法是起一个 safemap,维护一个 map[GoroutineID]map[描述][状态] 的结构,代码中在需要得时候更新这个数据结构,比如开始收集信息、收集信息结束之类得。

    需要收集得不光是 error 信息,还可能包含程序某个协程逻辑运行到哪里了。

    此功能默认不开启。需要 debug 时通过访问程序得一个 http 接口来开启此功能,然后通过接口获取 safemap 的数据。

    现在感觉这种方案太原始了,不知道有没有更好的方案,求大家推荐

    谢谢
    3 replies    2017-11-03 13:50:43 +08:00
    ghonfir
        1
    ghonfir  
       Oct 31, 2017
    goroutine 的堆栈信息 pprof 就能看到了吧
    ry_wang
        2
    ry_wang  
    OP
       Nov 1, 2017
    @sryanyuan 查了查 net/http/pprof 这个库,能满足我们一部分得需求,我详细看看


    谢谢~
    freestyle
        3
    freestyle  
       Nov 3, 2017 via iPhone
    函数返回 err 的时候包装一下嵌入调用栈信息即可. 最后打 log https://github.com/hanjm/errors http 服务打日志时带上 requestID
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   926 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 20:58 · PVG 04:58 · LAX 13:58 · JFK 16:58
    ♥ Do have faith in what you're doing.