在Elixir应用程序中设置Sentry,获取未定义的函数String.trim / 2

时间:2016-12-02 01:07:04

标签: heroku elixir phoenix-framework sentry

我按照这些说明(https://github.com/getsentry/sentry-elixir)在Elixir / Phoenix应用中设置Sentry错误通知。它在我的开发环境中运行良好,但是当我推向生产时(使用Heroku),我得到以下错误,这似乎发生在Sentry模块本身内:(UndefinedFunctionError) undefined function String.trim/2

这是完整的日志输出:

** (exit) an exception was raised:
2016-12-01T23:14:00.741733+00:00 app[web.1]:     ** (UndefinedFunctionError) undefined function String.trim/2
2016-12-01T23:14:00.741736+00:00 app[web.1]:         (elixir) String.trim("** (Phoenix.ActionClauseError) bad request to MyApp.UserController.create, no matching action clause to process request", "*")
2016-12-01T23:14:00.741737+00:00 app[web.1]:         (sentry) lib/sentry/event.ex:65: Sentry.Event.transform_exception/2
2016-12-01T23:14:00.741738+00:00 app[web.1]:         (sentry) lib/sentry.ex:86: Sentry.capture_exception/2
2016-12-01T23:14:00.741739+00:00 app[web.1]:         (plug) lib/plug/error_handler.ex:96: Plug.ErrorHandler.__catch__/5
2016-12-01T23:14:00.741740+00:00 app[web.1]:         (my_app) lib/my_app/endpoint.ex:1: MyApp.Endpoint.phoenix_pipeline/1
2016-12-01T23:14:00.741741+00:00 app[web.1]:         (my_app) lib/my_app/endpoint.ex:1: MyApp.Endpoint.call/2
2016-12-01T23:14:00.741742+00:00 app[web.1]:         (plug) lib/plug/adapters/cowboy/handler.ex:15: Plug.Adapters.Cowboy.Handler.upgrade/4
2016-12-01T23:14:00.741742+00:00 app[web.1]:         (cowboy) src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4

当我尝试通过alias String登录iex来尝试访问heroku run时,我得到了nil

知道为什么String模块仅在生产中未定义?

1 个答案:

答案 0 :(得分:3)

我认为您需要强制heroku使用elixir版本1.3.x. 如果你使用heroku-buildpack-elixir将你的灵丹妙药版本设置为最低1.3.0

  

https://github.com/HashNuke/heroku-buildpack-elixir

有相应的问题:

  

https://github.com/getsentry/sentry-elixir/issues/95