<div dir="ltr"><div>Hello!</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, May 6, 2021 at 6:55 PM Nathan Long <<a href="mailto:him@nathanmlong.com">him@nathanmlong.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Is there a way to add a non-unique label to a process? If not, I would like to propose that it be added.<br><br>The label could be shown with or instead of a PID. I think this would be useful in at least two areas.<br><br>First, when observing a running system, the PID is not descriptive. I have Observer open right now looking at part of my system, and I can see one globally registered process name displayed, but everything else is a PID. What are those processes? I might be able to figure it out by clicking the process and seeing what its initial call was, but often I can tell is "it's a GenServer." The structure of the system would be much more apparent if I saw labels like "db_connection" or "request_queue_worker".<br></div></div></blockquote><div><br></div><div>Adding something like this would be relatively simple as it could just use the same mechanism as when observer gets the "initial call", that is something is put in the process dictionary of that process that observer can fetch. Today the "initial call" is manager by proc_lib: <a href="https://erlang.org/doc/man/proc_lib.html#initial_call-1">https://erlang.org/doc/man/proc_lib.html#initial_call-1</a></div><div><br></div><div>I would not be against extending proc_lib to allow setting additional metadata that be fetched by observer.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Second, when reading error messages in logs or an exception tracker, the PID is not useful. For example, I'm looking at an error in Sentry right now that says "Sentry.CrashError error ** (exit) 'stopping because dependent process <0.2255.0> died: killed'". I have no idea what `<0.2555.0>` was, so I don't know what to debug.<br></div></div></blockquote><div><br></div><div>When a process dies, all of the data about that process is deleted, the only thing that remains is the PID. So in order to print anything useful the label would have to be part of the PID term. This is doable, though it would make the PID term about 4 times as large and make comparison a bit slower. Also since it would have to work with distribution, it would require extensions to the External Term Format together with capability flags etc etc, in other words, a lot of work writing C code.</div><div><br></div><div>Another way would be to store all of the PIDs that you are interested in somewhere and then create a logger formatter that processes all of the strings being emitted by logging and look for the PID that you want to replace with a more meaningful name. I suppose that observer could be extended to fetch information from this source as well when displaying processes.</div><div><br></div><div>I would prefer the second solution here as that would be something that could be done by any library. If the feature becomes popular, we can check and see if we can create a more performant solution later.</div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><br>Does this exist or would others support it being added to the BEAM? </div></div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><br></div>-- Nathan<br></div>
</blockquote></div></div>