-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set process label #7720
Set process label #7720
Conversation
dgud
commented
Oct 6, 2023
•
edited
Loading
edited
CT Test Results 5 files 155 suites 1h 49m 45s ⏱️ Results for commit 39962c7. ♻️ This comment has been updated with latest results. To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass. See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally. Artifacts// Erlang/OTP Github Action Bot |
1dbd45d
to
03ad472
Compare
03ad472
to
6719c90
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments dropped inline.
I didn't comment on commented out code. I assumed you are still developing and it is needed for reference. If not really needed, should be removed before merging I guess.
a10a48e
to
a0e532f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I've added some minor comments.
As with all great features this leaves me wanting more :D
Some of the things I would like are:
- Ancestors shown with their process description (both for self() and neighbors) in crash reports
- Links shown with their process description (both for self() and neighbors) in crash reports
- A convenience
SpawnOpt
to all gen behaviours to set the process description. This both makes it easier to set and exposes the functionality to users so that they know it exists without digging in the proc_lib docs.
PS. Are there really no tests for appmon_info, observer_backend and c:i? :( DS.
eecd9aa
to
6317d72
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great PR! Thanks.
lib/stdlib/src/c.erl
Outdated
fetch_name([], Info) -> | ||
case fetch({dictionary, '$process_label'}, Info) of | ||
undefined -> ""; | ||
Id -> format_name(Id) | ||
end; | ||
fetch_name(Reg, _) -> | ||
Reg. | ||
|
||
format_name(Id) when is_list(Id); is_binary(Id) -> | ||
case unicode:characters_to_binary(Id) of | ||
{error, _, _} -> | ||
io_lib:format("~0.tp", [Id]); | ||
BinString -> | ||
BinString | ||
end; | ||
format_name(TermId) -> | ||
io_lib:format("~0.tp", [TermId]). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this part is about fetching and formatting label. at a glance, name
might suggest registered name.
6317d72
to
39962c7
Compare
sort_name(#etop_proc_info{name={_,_,_}}, _) -> | ||
false. | ||
|
||
%% sort_name(#etop_proc_info{name=Reg}, #etop_proc_info{name={M,_F,_A}}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we keeping this code as a comment?
If I use Do we need a way to denote that these are labels, rather than registered names? |
Does it matter? It identifies the process(s). |
Possibly not. |
A bug, though -- probably in observer, rather than this: If two children have the same label, observer merges the nodes together. |
Where? In which tab? |
In the "Applications" tab. When I click on my application, all of my poolboy workers are represented by the same object (I assume because they've all got the same label). If I remove the label, they go back to separate objects. |
Oh, and on the earlier observation, note that I was also talking about the applications tab (it's my favourite!), in case that makes a difference about whether it matters. |
@rlipscombe I have pushed a version it kind of solves both your issues, the test app was useful thanks. |
Make it possible for the user to set a process label which can be used in tools and crash reports to identity processes but it doesn't have to be unique, as an registered name needs to be. The process label can any term, for example {worker, 1..N}, {pool_process, 1..N} or something entirely different to identify process that use general code. While at it optimize fetching process info, so we don't have to (rpc:) call the process_info(..) several times.
eba3d1b
to
c4ae057
Compare
@@ -159,6 +159,17 @@ | |||
</desc> | |||
</func> | |||
|
|||
<func> | |||
<name name="get_label" arity="1" since="OTP 26.2"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm interested to learn if this will get included in the upcoming 26.2? It seems this branch was merged to master instead of maint, but the docs say since 26.2 here and for set_label/1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No master only, we changed our mind and forgot to update the docs, thanks.