Fl4m3Ph03n1x
Is it possible to use Rexbug to trace messages send/received by processes?
Background
We have an app the keeps running. This is a OTP application that has other OTP applications as dependencies. It uses GenServers and Supervisors as do many of its dependencies.
Problem
The app doesn’t crash, but it constantly prints the following error:
=ERROR REPORT==== 14-Jun-2019::14:31:35.089496 ===
Unexpected message: {#Ref<0.2607974300.3493068808.175359>,badarg}
Rexbug?
I was told about this library, but after reading the README page I could not find any examples of message tracing between processes. I know Rexbug is a wrapper for the erlang counterpart, but I am not familiar with it either.
Questions
- Can this library help me in my task?
- Is it suitable for our use case? If not, what are the alternatives?
Marked As Solved
michalmuskala
I’m not really sure about redbug, but with dbg captureing a process that sends {ref, :badarg} messages would look something like:
# start the logger process
:dbg.tracer()
# set the match spec to only capture {ref, :badarg} messages
# will only trace messages received by receiver, can be :_ to trace all processes as receivers
:dbg.tpe(:send, [{[receiver, {:"$1", :badarg}],[{:is_reference,:"$1"}],[]}])
# start the trace on sender, can also be :processes to trace all processes as senders
:dbg.p(sender, [:r]);
You’ll start receiving log messages in the shape of:
(<0.108.0>) <0.117.0> ! {#Ref<0.3800804343.3707502597.14282>,badarg}
Which means process <0.108.0> sent the above message to <0.117.0>.
Also Liked
idi527
Just in case, here’s what I get in one of my apps running in a release built with erlang 21.0 and elixir 1.8 when I send one of the genservers an “unexpected” message:
[error] Worb.HiraganaSession #PID<0.2565.0> received unexpected message in handle_info/2: {#Reference<0.2424035366.4111728641.125681>, :badarg}
NobbZ
Try handling OTP and SASL reports via Logger, also enable more metadata, at least temporarily. If in doubt just use :all.
Then you’ll get nicer output and it’s in a single line rather then in the block like thing that you get now…
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









