Skip to content

Fix log formatting under 1.14 #851

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

Merged

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

@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?

@whatyouhide
Copy link
Collaborator

Since this is for an older Elixir version that we will eventually (maybe soon enough) drop, we can leave out the testing and just ship the fix IMO.

Include label info in the report too in metadata?

Nah it's fine not to. Basically, as soon as CI passes I think this PR is ready to go.

This will go away soon once we drop support for <= 1.14
So we're skipping tests for this.
@solnic solnic force-pushed the solnic/847-more-formatting-issues-in-sentryloggerhandler branch from d9936a8 to 772829b Compare January 22, 2025 13:29
@solnic solnic marked this pull request as ready for review January 22, 2025 13:30
@solnic
Copy link
Collaborator Author

solnic commented Jan 22, 2025

@whatyouhide alright, so it's ready to go, just need a ✅ 😄

@whatyouhide whatyouhide merged commit 652e1dc into master Jan 23, 2025
4 checks passed
@whatyouhide whatyouhide deleted the solnic/847-more-formatting-issues-in-sentryloggerhandler branch January 23, 2025 08:38
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.

2 participants