Skip to content
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

Fix log formatting under 1.14 #851

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

solnic
Copy link
Collaborator

@solnic solnic commented Jan 17, 2025

I traced it down to being an Elixir < 1.15 issue. This is what log_unfiltered receives under 1.14 when system crashes internally:

%{
        label: {:proc_lib, :crash},
        report: [
          [
            initial_call: {Phoenix.LiveReloader.Channel, :join, [:Argument__1, :Argument__2, :Argument__3]},
            pid: "pid id",
            registered_name: [],
            error_info: {
              :error,
              %ArgumentError{message: "unknown registry: PhoenixApp.PubSub"},
              [
                {Registry, :info!, 1, [file: 'lib/registry.ex', line: 1373]},
                {Registry, :register, 3, [file: 'lib/registry.ex', line: 989]},
                {Phoenix.PubSub, :subscribe, 3, [file: 'lib/phoenix/pubsub.ex', line: 121]},
                {Phoenix.Channel.Server, :init_join, 3, [file: 'lib/phoenix/channel/server.ex', line: 434]},
                {Phoenix.Channel.Server, :channel_join, 4, [file: 'lib/phoenix/channel/server.ex', line: 396]},
                {Phoenix.Channel.Server, :handle_info, 2, [file: 'lib/phoenix/channel/server.ex', line: 305]},
                {:gen_server, :try_handle_info, 3, [file: 'gen_server.erl', line: 1095]},
                {:gen_server, :handle_msg, 6, [file: 'gen_server.erl', line: 1183]},
                {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 241]}
              ]
            },
            ancestors: ["pid id", PhoenixAppWeb.Endpoint.Phoenix.LiveReloader.Socket, PhoenixAppWeb.Endpoint, PhoenixApp.Supervisor, "pid id"],
            message_queue_len: 0,
            messages: [],
            links: ["pid id"],
            dictionary: ["$callers": ["pid id"]],
            trap_exit: false,
            status: :running,
            heap_size: 17731,
            stack_size: 28,
            reductions: 15540
          ],
          []
        ]
      }

As a quick PoC I just updated log_unfiltered to match this and extract error_info to capture exception.

WITHOUT the fix, here's how it looked like:

Screenshot 2025-01-17 at 14 22 28

Here's the result WITH the fix

Screenshot 2025-01-17 at 14 50 21

TODO

  • Make it work 🙃
  • Somehow reproduce this in a test (any suggestions how?)
  • Make it capture it only under Elixir older than 1.15
  • Verify that it's the same with 1.13 actually
  • Include label info in the report too in metadata?

@solnic solnic requested a review from whatyouhide January 17, 2025 14:05
@solnic
Copy link
Collaborator Author

solnic commented Jan 17, 2025

@whatyouhide could you take a quick look? any idea how to reproduce this in a test?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant