Go程序栈追踪中goroutine标注的时间代表什么含义?
Go goroutine栈追踪时间标注含义
你看到的21 minutes是当前goroutine处于对应阻塞状态的持续时长,Go runtime仅在阻塞时长≥1分钟时才会在栈追踪中输出该字段,这就是第一个goroutine没有对应标注的原因。
详细说明
- 该字段的输出规则是Go runtime内置逻辑,所有栈追踪场景(panic自动打印、
runtime.Stack调用输出、pprof抓取栈信息)都会遵循该规则,不需要额外开启配置。 - 你给出的栈追踪中goroutine 8处于
chan receive(channel接收)状态,已经持续阻塞了21分钟。结合调用栈来看这是sentry-go的上报worker协程,该协程的逻辑就是长期阻塞等待channel传入待上报的事件,没有上报任务时就会一直处于阻塞状态,该时长属于正常现象,不属于协程泄漏或者运行异常。
goroutine 6 [chan receive]: go.elastic.co/apm.(*Tracer).loop.func2(0xc000042420, 0xc0000423c0, 0x1551980, 0xc0004da100, 0xc000074300, 0xc000001080, 0xc00000e018) /app/vendor/go.elastic.co/apm/tracer.go:803 +0x21a created by go.elastic.co/apm.(*Tracer).loop /app/vendor/go.elastic.co/apm/tracer.go:800 +0x36e goroutine 8 [chan receive, 21 minutes]: github.com/getsentry/sentry-go.(*HTTPTransport).worker(0xc0003025b0) /app/vendor/github.com/getsentry/sentry-go/transport.go:387 +0x77 created by github.com/getsentry/sentry-go.(*HTTPTransport).Configure.func1 /app/vendor/github.com/getsentry/sentry-go/transport.go:255 +0x3e
内容的提问来源于stack exchange,提问作者Lokesh
相关产品推荐
相关产品推荐

