Skip to content

Commit 3ad03b5

Browse files
committed
Use Process.label() instead of Process.register(). Deprecate :components option for :unsafely_name_processes_for_stalker
1 parent a5c43db commit 3ad03b5

2 files changed

Lines changed: 20 additions & 25 deletions

File tree

lib/membrane/core/stalker.ex

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,7 @@ defmodule Membrane.Core.Stalker do
117117
end
118118

119119
# Sets component path, logger metadata and adds necessary entries to the process dictionary
120-
# Also registers the process with a meaningful name for easier introspection with
121-
# stalker if enabled by setting `unsafely_name_processes_for_observer: :components`
122-
# in config.exs.
120+
# and labels the process with a meaningful name for easier introspection with stalker
123121
defp setup_process_local_observability(config, opts) do
124122
config = parse_observability_config(config, opts)
125123

@@ -169,23 +167,14 @@ defmodule Membrane.Core.Stalker do
169167
}
170168
end
171169

172-
if :components in @unsafely_name_processes_for_observer do
173-
defp register_name_for_stalker(config) do
174-
if Process.info(self(), :registered_name) == {:registered_name, []} do
175-
Process.register(
176-
self(),
177-
"""
178-
##{config.pid_string} #{if config.is_name_provided, do: config.name_string}\
179-
#{unless config.is_name_provided, do: " (#{config.component_type})"}#{config.utility_name}"\
180-
"""
181-
|> String.to_atom()
182-
)
183-
end
170+
defp register_name_for_stalker(config) do
171+
label =
172+
"""
173+
##{config.pid_string} #{if config.is_name_provided, do: config.name_string}\
174+
#{unless config.is_name_provided, do: " (#{config.component_type})"}#{config.utility_name}"\
175+
"""
184176

185-
:ok
186-
end
187-
else
188-
defp register_name_for_stalker(_config), do: :ok
177+
Process.set_label(label)
189178
end
190179

191180
@doc """
@@ -204,12 +193,22 @@ defmodule Membrane.Core.Stalker do
204193
}
205194
end
206195

196+
if :components in @unsafely_name_processes_for_observer do
197+
IO.warn(
198+
"""
199+
Deprecated `:components` value for :unsafely_name_processes_for_observer option.
200+
Now the processes are always labeled so there is no need to use this option.
201+
""",
202+
__STACKTRACE__
203+
)
204+
end
205+
207206
if :links in @unsafely_name_processes_for_observer do
208207
defp run_link_dbg_process(pad_ref, observability_data) do
209208
{:ok, observer_dbg_process} =
210209
Task.start_link(fn ->
211210
Process.flag(:trap_exit, true)
212-
Process.register(self(), :"pad #{inspect(pad_ref)} #{:erlang.pid_to_list(self())}")
211+
Process.label(self(), :"pad #{inspect(pad_ref)} #{:erlang.pid_to_list(self())}")
213212
process_to_link = Map.get(observability_data, :observer_dbg_process)
214213
if process_to_link, do: Process.link(process_to_link)
215214

lib/membrane/pipeline.ex

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,7 @@ defmodule Membrane.Pipeline do
4545
### Visualizing the supervision tree
4646
4747
Use the [Applications tab](https://www.erlang.org/doc/apps/observer/observer_ug#applications-tab) in Erlang's Observer GUI
48-
(or the `Kino` library in Livebook) to visualize a pipeline's internal supervision tree. Use the following configuration for debugging purposes only:
49-
50-
config :membrane_core, unsafely_name_processes_for_observer: [:components]
51-
52-
This improves the readability of the Observer's process tree graph by naming the pipeline descendants, as demonstrated here:
48+
(or the `Kino` library in Livebook) to visualize a pipeline's internal supervision tree.
5349
5450
![Observer graph](assets/images/observer_graph.png).
5551
"""

0 commit comments

Comments
 (0)