scoutapp / scout_apm_elixir

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

(Protocol.UndefinedError) protocol Jason.Encoder not implemented #113

Open ZombieHarvester opened 4 years ago

ZombieHarvester commented 4 years ago

When I tried to use ScoutAPM in dev env following the instruction from ReadMe, i'm getting the following error when I start the app. Phoenix version 1.4.16

** (exit) an exception was raised:
    ** (Protocol.UndefinedError) protocol Jason.Encoder not implemented for %ScoutApm.Payload.Metadata{agent_pid: 16608, agent_time: "2020-04-21T09:26:10.701350Z", agent_version: "1.0.6", app_root: "/Users/*******", language: "elixir", language_version: "1.10.2", payload_version: 1, platform: "elixir", platform_version: "1.10.2", unique_id: "an3e4bqsGNsyhWeHQRIh"} of type ScoutApm.Payload.Metadata (a struct), Jason.Encoder protocol must always be explicitly implemented.

If you own the struct, you can derive the implementation specifying which fields should be encoded to JSON:

    @derive {Jason.Encoder, only: [....]}
    defstruct ...

It is also possible to encode all fields, although this should be used carefully to avoid accidentally leaking private information when new fields are added:

    @derive Jason.Encoder
    defstruct ...
antondomratchev commented 2 years ago

I recently ran into this exact issue. I was able to resolve this by setting dev_trace config to false