GoLand
 
Get GoLand

Using profiler labels

Last modified: 26 May 2024

Goroutines are functions or methods that run concurrently with other functions or methods. To create a goroutine, use the go keyword followed by a function invocation (for example, go func(p string, rid int64)). But using lots of goroutines makes a program harder to debug. To differentiate between goroutines, you can label goroutines with custom data.

Since Go 1.9, you can record additional information to provide more context about the execution path. You can record any set of labels as a part of the profiling data and use these labels later to examine the profiler output.

For example, you have a queue handler that processes events created somewhere. The handler can set labels to identify where these events were created.

During debugging and core dump analysis, the context information might be helpful. For example, you can use this information to find a particular goroutine more easily.