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
Display value of '$process_label' in observer #5039
Conversation
|
Would it make sense to support any term in there and use |
|
I would expect this kind of property to at least support strings, binaries and tuples: as Michał said, there are multiple reasons to use a multi-valued label, e.g. Note that for tuples, |
2111552
to
f0e6f38
Compare
|
I've updated the commit to allow process labels to be any term. |
|
You need to separate formatting of strings (lists or binaries) and other terms; using Something such as: case proplists:get_value('$process_label', D) of
undefined ->
pid_to_list(P);
Label when is_list(Label); is_binary(Label) ->
io_lib:format("~ts ~tp", [Label, P]);
Label ->
io_lib:format("~tp ~tp", [Label, P])
end; |
|
So we agreed that this is useful information but it was decided that we should have 'proc_lib' or 'sys' might be a good place for this functionality with set/get_process_description/1. |
Is there a compelling reason to choose one over the other? Based on a quick skim through the docs, it seems to me that 'sys' would be the better place, since it's already got "inspection"-type stuff in it. |
|
We have not discussed the name or where to put them it was just a suggestion, we leave that to you |
|
Just to be clear: I've not forgotten about this; been busy with the day job. |
8d040bd
to
8a8d142
Compare
|
I've updated the PR. See the new commit. |
|
Still wishing and hoping for this to land. ✨ ✨ ✨ |
|
I've got time to work on this now, but I'm waiting for some feedback on the implementation. |
|
Yes, I have been thinking on this on and off, and don't know what to do about it. What I want to avoid is a performance load on the target node, and as it is today getting the Now as it is written in the current PR, it is used in observer in the application tab only, But if we add it there people will want it in the 'Processes' tab, at least I want it there, (which works as 'top') and then it will be fetched on every update (1-10s) and for all processes. |
|
If we discard the idea of I prefer using a well-known value in the process dictionary because it removes short-term compatibility concerns: I can decorate my code with labels without worrying about which version of OTP I'm targetting. It adds coupling in the long term, though. |
|
We decided to use a functional interface so we can change it later to something with more performance. But maybe move the functions to proc_lib and add a new function there, |
8a8d142
to
cb00c90
Compare
CT Test Results 3 files 96 suites 38m 40s ⏱️ Results for commit f876043. ♻️ 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 |
Can do, but...
I don't like this. The fallback from the label to the initial call feels like an
This feels like it needs further discussion. If we provided a way to get only some of the process dictionary, and if we continued to keep the process label in the dictionary, something like
However: is there any evidence that large process dictionaries are common, and how much impact does it really have...? |
|
Today I ran into an issue that would benefit from this (process label on Observer). Is this pull request still being considered? I see it as marked Stalled, but don't know why. |
|
Not in the current form, but stalled means we need to take a look at this but it is down on the priority list. |
That's on me. I stepped away from working with Erlang for a few months. Nudging discussion slightly:
I've thought about this some more, and I'm thinking that So it'd look something like this:
It's relatively low-impact, hides the implementation details, and is easy to change later. |
cb00c90
to
82c7b05
Compare
We add the concept of non-unique labels for processes, which are displayed in observer. A process can have at most one label; labels need not be unique between processes. Labels can be any valid Erlang term. This adds `sys:put_label/1`, `sys:get_label/0` and `sys:get_label/1` function. See http://erlang.org/pipermail/erlang-questions/2021-May/100972.html and http://erlang.org/pipermail/erlang-questions/2021-June/101152.html for discussion. The labels are currently stored in the process dictionary (under '$process_label'), but this is an implementation detail.
82c7b05
to
f876043
Compare
|
I've looked into a couple of options:
So: I think the least-bad option at this point is:
This is basically the state of the PR right now. If that's not good enough, then I'm out of ideas. |
|
Although "observer" is in the issue title, I like that this code is not Observer-specific. These labels could be useful in Observer itself and also other tools like it, such as Phoenix.LiveDashboard's process view |
|
Replaced by #7720 |
In http://erlang.org/pipermail/erlang-questions/2021-May/100972.html, it was suggested (after some discussion) that non-unique process labels would make using
observernicer. I followed this up here: http://erlang.org/pipermail/erlang-questions/2021-June/101152.htmlThis is a first stab at implementing that, for feedback.
It defines a convention where the process dictionary can contain
'$process_label', which is assumed to be an Erlang string (list of chars). If there's interest in the concept, I'll look at extendinggen_serveret. al. to support this through options.I'm currently using it to make it easier to observe a particularly nested supervision tree.