scoutapp / scout_apm_elixir

ScoutAPM Elixir Agent. Supports Phoenix and other frameworks.
https://scoutapm.com
Other
36 stars 20 forks source link

ScoutApm.Command does not work in Elixir 1.14 #123

Open pvthuyen opened 2 years ago

pvthuyen commented 2 years ago

Implementations for ScoutApm.Command are not recognized by Elixir 1.14. I've included the stack trace and errors below. I'm guessing that it's because we are defining the implementation inside the modules.

** (Protocol.UndefinedError) protocol ScoutApm.Command not implemented for %ScoutApm.Command.Batch{commands: [%ScoutApm.Command.StartRequest{timestamp: ~N[2022-10-12 04:05:26.620713], request_id: "Abv3nnKNCVMm"}, %ScoutApm.Command.StartSpan{timestamp: ~N[2022-10-12 04:05:26.620713], request_id: "Abv3nnKNCVMm", span_id: "rNE42VNUmsI5", parent: nil, operation: "Job/WallChannel.check_access"}, %ScoutApm.Command.StopSpan{timestamp: ~N[2022-10-12 04:05:26.800598], request_id: "Abv3nnKNCVMm", span_id: "rNE42VNUmsI5"}, %ScoutApm.Command.FinishRequest{timestamp: ~N[2022-10-12 04:05:26.800598], request_id: "Abv3nnKNCVMm"}]} of type ScoutApm.Command.Batch (a struct). This protocol is implemented for the following type(s): Kernel
    (scout_apm 1.0.7) lib/scout_apm/commands.ex:1: ScoutApm.Command.impl_for!/1
    (scout_apm 1.0.7) lib/scout_apm/commands.ex:2: ScoutApm.Command.message/1
    (scout_apm 1.0.7) lib/scout_apm/tracked_request.ex:227: anonymous fn/1 in ScoutApm.TrackedRequest.build_collector_fn/1
    (scout_apm 1.0.7) lib/scout_apm/tracked_request.ex:110: ScoutApm.TrackedRequest.stop_layer/2
    (scout_apm 1.0.7) lib/scout_apm/tracked_request.ex:259: ScoutApm.TrackedRequest.with_saved_tracked_request/1
dlanderson commented 2 years ago

Thanks @pvthuyen. @jeregrine is this something RokkinCat can help with?

pvthuyen commented 2 years ago

I tried to fix the issue and upgrade Elixir version to 1.14 in this PR. Please give it a review.

https://github.com/scoutapp/scout_apm_elixir/pull/124

jeregrine commented 2 years ago

Sorry for delay. I will take alook now.

jeregrine commented 2 years ago

@pvthuyen I need to do some more testing but master branch should be fully functioning now thanks to your PR and some extra stuff I needed to do.

Please confirm by pointing your mix dep to github {:scout_apm, github: "scoutapp/scout_apm_elixir"} and running it.

pvthuyen commented 2 years ago

Thanks @jeregrine. I will try it on my project later. I have a small comment on your commit though, https://github.com/scoutapp/scout_apm_elixir/commit/4b9c43fb03131e827faf80709851fa96ac2a74b3#r87762936.

pvthuyen commented 2 years ago

I'm getting this when running my project after updating the dependencies.

** (Mix) Could not start application scout_apm: exited in: ScoutApm.Application.start(:normal, [])
    ** (EXIT) an exception was raised:
        ** (MatchError) no match of right hand side value: {:error, {:shutdown, {:failed_to_start_child, ScoutApm.Core.AgentManager, {:EXIT, {:undef, [{ScoutApm.Core.AgentManager, :start_link, [[]], []}, {:supervisor, :do_start_child_i, 3, [file: 'supervisor.erl', line: 414]}, {:supervisor, :do_start_child, 2, [file: 'supervisor.erl', line: 400]}, {:supervisor, :"-start_children/2-fun-0-", 3, [file: 'supervisor.erl', line: 384]}, {:supervisor, :children_map, 4, [file: 'supervisor.erl', line: 1242]}, {:supervisor, :init_children, 2, [file: 'supervisor.erl', line: 350]}, {:gen_server, :init_it, 2, [file: 'gen_server.erl', line: 423]}, {:gen_server, :init_it, 6, [file: 'gen_server.erl', line: 390]}]}}}}}
            (scout_apm 1.0.7) lib/scout_apm/application.ex:20: ScoutApm.Application.start/2
            (kernel 8.1.2) application_master.erl:293: :application_master.start_it_old/4
pvthuyen commented 2 years ago

It's due to ScoutApm.Core.AgentManager does not have the correct start_link definition. Sent a PR for it.

https://github.com/scoutapp/scout_apm_elixir/pull/125

pvthuyen commented 2 years ago

@jeregrine master branch seems to work on my project now. Please kindly help me release a new version.