Open
Description
I noticed failures in logs like such:
19:25:47.333 request_id=GCc7cySWL7wohx4AAF_h profile_id=a03c7920-ed38-44fd-b132-7be210d95789 [error] Handler ErrorTracker.Integrations.Phoenix has failed and has been detached. Class=:error
Reason=:undef
Stacktrace=[
{JSON, :encode_to_iodata,
[
%{
"request.headers" => %{
"accept" => "*/*",
"accept-encoding" => "gzip, deflate, br, zstd",
"accept-language" => "pl,en-US;q=0.7,en;q=0.3",
"authorization" => "Token …”,
"host" => “my-app.com”,
"origin" => "my-app.com",
"referer" => "my-app.com/contracts?sortBy=%21createdAt&type=ALL",
"sec-fetch-dest" => "empty",
"sec-fetch-mode" => "cors",
"sec-fetch-site" => "same-site",
"te" => "trailers",
"user-agent" => "Mozilla/5.0 (X11; Linux x86_64; rv:135.0) Gecko/20100101 Firefox/135.0",
"x-forwarded-for" => "213.55.186.170",
"x-forwarded-host" => "my-app.com",
"x-forwarded-port" => "443",
"x-forwarded-proto" => "https",
"x-forwarded-server" => "traefik-569dbb7c88-l2nh5",
"x-real-ip" => "213.55.186.170"
},
"request.host" => "my-app.com",
"request.ip" => "213.55.186.170",
"request.method" => "GET",
"request.params" => %{},
"request.path" => “/some/path”,
"request.query" => ""
}
], []},
{ErrorTracker.Occurrence, :validate_context, 1,
[file: ~c"lib/error_tracker/schemas/occurrence.ex", line: 56]},
{ErrorTracker.Occurrence, :changeset, 2,
[file: ~c"lib/error_tracker/schemas/occurrence.ex", line: 35]},
{ErrorTracker, :"-upsert_error!/5-fun-1-", 5,
[file: ~c"lib/error_tracker.ex", line: 325]},
{Ecto.Adapters.SQL, :"-checkout_or_transaction/4-fun-0-", 3,
[file: ~c"lib/ecto/adapters/sql.ex", line: 1400]},
{DBConnection, :run_transaction, 4,
[file: ~c"lib/db_connection.ex", line: 1756]},
{ErrorTracker, :upsert_error!, 5, [file: ~c"lib/error_tracker.ex", line: 307]},
{ErrorTracker, :report, 3, [file: ~c"lib/error_tracker.ex", line: 145]},
{ErrorTracker.Integrations.Plug, :report_error, 3,
[file: ~c"lib/error_tracker/integrations/plug.ex", line: 102]},
{:telemetry, :"-execute/3-fun-0-", 4,
[file: ~c"/app/deps/telemetry/src/telemetry.erl", line: 167]},
{:lists, :foreach_1, 2, [file: ~c"lists.erl", line: 2310]},
{Phoenix.Router, :__call__, 5, [file: ~c"lib/phoenix/router.ex", line: 496]},
{MyApp.Endpoint, :plug_builder_call, 2,
[file: ~c"lib/my_app/endpoint.ex", line: 1]},
{MyApp.Endpoint, :call, 2,
[file: ~c"lib/my_app/endpoint.ex", line: 1]},
{Bandit.Pipeline, :call_plug!, 2,
[file: ~c"lib/bandit/pipeline.ex", line: 129]},
{Bandit.Pipeline, :run, 4, [file: ~c"lib/bandit/pipeline.ex", line: 40]},
{Bandit.HTTP1.Handler, :handle_data, 3,
[file: ~c"lib/bandit/http1/handler.ex", line: 12]},
{Bandit.DelegatingHandler, :handle_data, 3,
[file: ~c"lib/bandit/delegating_handler.ex", line: 18]},
{Bandit.DelegatingHandler, :handle_info, 2,
[file: ~c"lib/bandit/delegating_handler.ex", line: 8]},
{:gen_server, :try_handle_info, 3, [file: ~c"gen_server.erl", line: 2345]},
{:gen_server, :handle_msg, 6, [file: ~c"gen_server.erl", line: 2433]},
{:proc_lib, :init_p_do_apply, 3, [file: ~c"proc_lib.erl", line: 329]}
]
Turns out:
- I set
JSON
as a value for json_encoder configuration for postgrex, error-tracker
uses postgrex json_encoder to encode values,error-tracker
attempts to useencode_to_iodata/1
,- a function with such name is not implemented by JSON module;
encode_to_iodata!/1
(with a bang) is
It would be wonderful if error-tracker could support using JSON module.