Skip to content

Conversation

zeripath
Copy link
Contributor

This PR uses unsafe to export the hidden runtime_getProfLabel function from the
runtime package and then casts the result to a map[string]string.

We can then interrogate this map to get the pid label from the goroutine allowing
us to log it with any logging request.

Reference #19202

Signed-off-by: Andrew Thornton [email protected]

@zeripath zeripath added the type/enhancement An improvement of existing functionality label Mar 25, 2022
This PR uses unsafe to export the hidden runtime_getProfLabel function from the
runtime package and then casts the result to a map[string]string.

We can then interrogate this map to get the pid label from the goroutine allowing
us to log it with any logging request.

Reference go-gitea#19202

Signed-off-by: Andrew Thornton <[email protected]>
@zeripath zeripath force-pushed the logging-goroutine-pid-label branch from e1fed29 to b819116 Compare March 25, 2022 19:32
Signed-off-by: Andrew Thornton <[email protected]>
@zeripath
Copy link
Contributor Author

This one may be quite controversial and I've put it up as an example of something that we might want to consider doing.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Mar 25, 2022
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Mar 26, 2022
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Mar 26, 2022
@lunny
Copy link
Member

lunny commented Mar 26, 2022

make L-G-T-M work.

@zeripath zeripath merged commit 70628bd into go-gitea:main Mar 26, 2022
@zeripath zeripath deleted the logging-goroutine-pid-label branch March 26, 2022 20:04
Chianina pushed a commit to Chianina/gitea that referenced this pull request Mar 28, 2022
* Add auto logging of goroutine pid label

This PR uses unsafe to export the hidden runtime_getProfLabel function from the
runtime package and then casts the result to a map[string]string.

We can then interrogate this map to get the pid label from the goroutine allowing
us to log it with any logging request.

Reference go-gitea#19202

Signed-off-by: Andrew Thornton <[email protected]>
@wxiaoguang wxiaoguang added this to the 1.17.0 milestone Mar 29, 2022
@go-gitea go-gitea locked and limited conversation to collaborators Apr 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants