Long Question Ahead
I am trying to understand how does the trace package of go extracts and assign the goroutine their respective id’s.
I am using the code shown here
After I run this code, I run the following commands:
curl localhost:1328/debug/pprof/trace?seconds=10 > trace.out
go tool trace trace.out
I get this as the output :
Opening browser. Trace viewer is listening on http://127.0.0.1:xxxx
This runs and provides me with a GUI where I can see all the methods that got called and their respective trace fields and values. There is a section in there, which is Gorotuine analysis and when I click that link, the code inside this link gets executed.
After changing the source code to try to understand how I get the ID’s for each gorutine, I still can’t figure out this code section.
I am able to print the ID’s that runs on this route. But how does it actually stores these, like based on what criteria? I know this is happening somewhere here.
Any help would be appreciated. Thanks.