Giter VIP home page Giter VIP logo

rollbax's Introduction

Rollbax

Build Status Hex Version

Elixir client for Rollbar.

Installation

Add Rollbax as a dependency to your mix.exs file:

defp deps() do
  [{:rollbax, ">= 0.0.0"}]
end

Then run mix deps.get in your shell to fetch the dependencies. Add :rollbax to your list of :applications if you're not using :extra_applications.

Usage

Rollbax requires some configuration in order to work. For example, in config/config.exs:

config :rollbax,
  access_token: "ffb8056a621f309eeb1ed87fa0c7",
  environment: "production"

Then, exceptions (errors, exits, and throws) can be reported to Rollbar using Rollbax.report/3:

try do
  DoesNotExist.for_sure()
rescue
  exception ->
    Rollbax.report(:error, exception, System.stacktrace())
end

For detailed information on configuration and usage, take a look at the online documentation.

Crash reports

Rollbax provides a way to automatically report crashes from OTP processes (GenServers, Tasks, and so on). It can be enabled with:

config :rollbax, enable_crash_reports: true

For more information, check out the documentation for Rollbax.Logger. If you had previously configured Rollbax.Logger to be a Logger backend (for example config :logger, backends: [Rollbax.Logger]), you will need to remove since Rollbax.Logger is not a Logger backend anymore and you will get crashes if you use it as such.

Plug and Phoenix

For examples on how to take advantage of Rollbax in Plug-based applications (including Phoenix applications), have a look at the "Using Rollbax in Plug-based applications" page in the documentation.

Non-production reporting

For non-production environments error reporting can be either disabled completely (by setting :enabled to false) or replaced with logging of exceptions (by setting :enabled to :log).

config :rollbax, enabled: :log

Using a proxy to reach the Rollbar server

For environments which require a proxy to connect to hosts outside of the network, the :proxy config entry can be added with a proxy URL as it's defined in the hackney documentation.

config :rollbax, proxy: "https://my-secure-proxy:5001"

Contributing

To run tests, run $ mix test --no-start. The --no-start bit is important so that tests don't fail (because of the :rollbax application being started without an :access_token specifically).

When making changes to the code, adhere to this Elixir style guide.

Finally, thanks for contributing! :)

License

This software is licensed under the ISC license.

rollbax's People

Contributors

capablemonkey avatar cifer-y avatar craig-day avatar eldano avatar fertapric avatar florish avatar germandz avatar janpieper avatar jgmchan avatar jonrowe avatar lexmag avatar michalmuskala avatar mjquinlan2000 avatar novaugust avatar ono avatar oyvindfanebust avatar philss avatar qcam avatar simonwoolf avatar teamon avatar tigerwolf avatar whatyouhide avatar wojtekmach avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rollbax's Issues

Feature Request: filter exception messages

I want to add a filter for certain exception messages that can be put into the config.exs for Rollbax. I was thinking of something similar to the Rails Rollbar gem using a map like this:

config.exception_level_filters.merge!({
  'ActionController::RoutingError' => 'ignore',
  'NoMethodError' => 'critical'
})

We would have to add an :ignore message type and check for it before reporting. If this is something folks want, I'd be willing to work on a PR, although I'd want some feedback on where to implement best prior to starting work.

It could be handled in the router if you are using plug as described here in the docs. Here is my code in some simple filtering using plug. I think we would do something similar if the error structs were stored in the config.exs although the error struct would be checked for reportable exception type when calling report, report_message, or report_exception

  defp handle_errors(_conn, error_params = %{kind: kind, reason: reason, stack: stacktrace}) do
    case reason.__struct__ do
      Phoenix.Router.NoRouteError -> log_errors(error_params)
      Plug.CSRFProtection.InvalidCSRFTokenError -> log_errors(error_params)
      _ -> Rollbax.report(kind, reason, stacktrace)
    end
  end

  defp log_errors(%{kind: kind, reason: reason, stack: stacktrace}) do
    Logger.error "#{inspect(kind)} #{inspect(reason)} #{inspect(stacktrace)}"
  end

How to prevent running on dev server?

I'm finding that my dev server is also reporting errors to rollbar, which is confusing for other devs. How do I configure to prevent this?

I have this is config.exs

config :rollbax,
  access_token: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  environment: "production"

and IO.inspect(Mix.env) returns :dev

automatic crash reporting does not seem to work

have configured rollbax as follows in config/prod.exs

config :rollbax,
   enable_crash_reports: true,
   enabled: true,
   access_token: "xxxxxxxxxxxxxxxxxxxxxxx",
   environment: "staging"

but no exceptions are being reported automatically

manual reporting does end up in my rollbar account

try do
  DoesNotExist.for_sure()
rescue
  exception ->
    Rollbax.report(:error, exception, System.stacktrace())
end

^ This works, but automatic crash reporting does not
appreciate any hints on what I might be doing wrong.

Problem with new guard in Rollbax.Item.draft/3

After this implementation: 47d89bd#diff-17292547d1a8307b8d6fc61ce6dbf363R10

it is not possible to use Confex with Rollbax since the parameters don't match with the new guard.

Error example:

** (Mix) Could not start application rollbax: Rollbax.start(:normal, []) returned an error: shutdown: failed to start child: Rollbax.Client
    ** (EXIT) an exception was raised:
        ** (FunctionClauseError) no function clause matching in Rollbax.Item.draft/3
            (rollbax) lib/rollbax/item.ex:9: Rollbax.Item.draft({:system, "ROLLBAR_ACCESS_TOKEN", ""}, {:system, "ROLLBAR_ENVIRONMENT", ""}, %{})
            (rollbax) lib/rollbax/client.ex:28: Rollbax.Client.start_link/1
            (stdlib) supervisor.erl:365: :supervisor.do_start_child/2
            (stdlib) supervisor.erl:348: :supervisor.start_children/3

Boot errors with enable_crash_reports

How would you suggest handling boot errors when enable_crash_reports is activated? My team has run into this situation a few times, which in matter of seconds or minutes tens of thousands of errors have been reported to Rollbar because of a core process not being able to start (usually a configuration issue, for example: new database was not yet provisioned so the corresponding Ecto.Repo crashes).

I would like to implement some kind of control / back off to avoid generating so many error reports at once in these circumstances. I wonder if anyone has run into this problem before and already found a good solution for it. I suspect Rollbax.Reporter would be the right place to resolve this but any guidance would be appreciated too.

Thank you!

Reporting error in async tasks with Plug and Phoenix

Hi guys,

We are using Rollbax in a Phoenix Framework project. It's helping us a lot tracking errors to rollbar but we have realized one thing we are not really sure how to solve. When we have an error as a result of executing a function inside Task.start the error isn't being handled by the handle_errors private function we declared in router.ex which prevent us from reporting it.

I guess this happens because that code is executed by a different process or something.

Do you guys know any way to handle these errors?

Thank you.

Sending exceptions as exceptions, not messages

Hi,
I was talking with someone from Rollbar yesterday, and we talked about the annoyance of having multiple items in Rollbar for the same errors (#56), he came back to me today and told me you are sending the exceptions as messages and not as exceptions.

Usage?

Hi there,

It doesn't specify but from looking at usage, does this only store things in Rollbar that are explicitly caught and sent to Rollbar, or will it catch unhandled exceptions?

Best way to filter/ignore errors

I'm getting a lot of requests with no route found for mysql/admin.

What do you think is the best option to implement the ignore behavior?
Maybe it is a good idea to be able to ignore errors by config?

Configure Rollbax in different apps in an umbrella project

It is possible use config like this
config :app_name, :rollbax, access_token: "123"
I use it only for one app in umbrella project and wont to add this to deps only for this project.
if set just config :rollbar i need to add rollbar to all projects

Expand config to allow setting defaults for the JSON msg

Due to the deployment of my app on different customer servers, I need to be able to track where the logged error originated. Looking through the API documentation of Rollbar, I see they added the possibility to specify user_ip : "$remote_ip", this will then be replaced with the reporting IP. I would love to be able to add in the config an option to set this all the time.
I know I can add a 5th parameter to Rollbax.report and this will be merged into the json, but I'd love it if we would be able to provide this from the config too.

Are :info and :debug logs supported/working?

I'm having issues getting the Logger.info and Logger.debug to log to Rollbar. I have my level set to :info but I can only log error to the service (the debug/info do log to the console though).

config :logger,
  backends: [:console, Rollbax.Logger],
  level: :debug  # also tried :info with no success

config :rollbax,
  access_token: System.get_env("ROLLBAR_TOKEN"),
  environment: Mix.env

Add a reporter for ranch/cowboy/Plug messages

Today we don't handle logs such as

Ranch listener ~p had connection process started with ~p:start_link/4 at ~p exit with reason: ~999999p~n

I think we should out of the box since they're incredibly common coming from cowboy/Plug. We can provide Rollbax.Reporter.{Ranch|Cowboy|Plug}. Thoughts @lexmag and @ericmj?

Jason.Encoder not implemented

I have opened an issue for jason yesterday, but after reconsidering it tonight, I guess rollbax might be the better place to fix it.

Due to some unexpected errors, I got a lot of rollbax crashes and therefore no information about my errors, when you really want to have the information. They weren't sent because of the following:

09:40:56.159 [error] GenServer Rollbax.Client terminating
** (Protocol.UndefinedError) protocol Jason.Encoder not implemented for {"id", "2"}, Jason.Encoder protocol must always be explicitly implemented. This protocol is implemented for: Any, Atom, BitString, Date, DateTime, Decimal, Float, Integer, Jason.Fragment, List, Map, NaiveDateTime, Time
    lib/encoder.ex:128: Jason.Encoder.Any.encode/2
    lib/encode.ex:138: Jason.Encode.list/3
    lib/encode.ex:172: Jason.Encode.map_naive_loop/3
    lib/encode.ex:173: Jason.Encode.map_naive_loop/3
    lib/encode.ex:162: Jason.Encode.map_naive/3
    lib/encode.ex:172: Jason.Encode.map_naive_loop/3
    lib/encode.ex:173: Jason.Encode.map_naive_loop/3
    lib/encode.ex:162: Jason.Encode.map_naive/3

Better error message titles

Does anyone else have issues with GenSever error message titles?

Almost all our errors result in a GenServer crashing, so the error title is always something like GenServer #PID<0.934.0> terminating. This isn't very helpful and I find myself having to click every error we get on rollbar to see what actually happened. Having better titles would be great.

Ideally, I want to see the second line of the message as the error title (see example below). I think we can do this be manually sending the second line as the exception title. See: https://rollbar.com/docs/api/items_post/

Example Error

GenServer #PID<0.934.0> terminating
** (UndefinedFunctionError) function nil.id/0 is undefined (module nil is not available)
    nil.id()
    (sre) Sre.ListingChannel.handle_in/3
    (phoenix) lib/phoenix/channel/server.ex:226: anonymous fn/4 in Phoenix.Channel.Server.handle_info/2
    (stdlib) gen_server.erl:601: :gen_server.try_dispatch/4
    (stdlib) gen_server.erl:667: :gen_server.handle_msg/5
    (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3

Could Rollbax cause a memory leak in my application?

Hi all,

I'm having some trouble identifying why do I have a memory leak in my application. You can find more info in this Elixir Forum post.
Otherwise, as a TLDR:

I have a process error_logger that keeps accumulating data. When I look into the process' state I see the following:

{items,{"Installed handlers",
        [{handler,'Elixir.Rollbax.Logger',false,
                  #{'__struct__' => 'Elixir.Rollbax.Logger',
                    reporters => ['Elixir.Rollbax.Reporter.Standard']},
                  false}]}}

This is why I think Rollbax may be causing memory leak in my application.

Elixir version:

1.11.2

Erlang version:

23.0.3

Rollbax version:

  "rollbax": {:hex, :rollbax, "0.11.0", "9557935d09d154c8775fa4efc709bfacbb73f20c58a3ced31dea2a74dd6e25de", [:mix], [{:hackney, "~> 1.1", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "a74318b175aae4bdddcc1ecfdf38755df3d8143c9902b1bfd19507ac9901062d"},

Do you know how does Rollbax uses the error_logger?
Does it seem plausible that Rollbax is causing a memory leak and if so, why? ๐Ÿค”

Exception parsing in logs doesn't match errors

Working from current master (64911c0) I'm getting exception logs that don't seem to match any of the patterns in Rollbax.Reporter.Standard.

  defp handle_error_format('** Generic server ' ++ _, [name, last_message, state, reason]) do
  defp handle_error_format('** gen_event handler ' ++ _, [name, manager, last_message, state, reason]) do
  defp handle_error_format('** Task ' ++ _, [name, starter, function, arguments, reason]) do
  defp handle_error_format('** State machine ' ++ _ = message, data) do
  defp handle_error_format('Error in process ' ++ _, [pid, {reason, stacktrace}]) do

Those look maybe like they are generated from erlang processes? My log has the GenServer spelling in it.:

[error] GenServer #PID<0.931.0> terminating
** (stop) killed
Last message: {:EXIT, #PID<0.930.0>, :killed}
State: {:state, {#PID<0.931.0>, :poolboy_sup}, :simple_one_for_one, [{:child, :undefined, DBConnection.Poolboy.Worker, {DBConnection.Poolboy.Worker, :start_link, [{Postgrex.Protocol, [types: Ecto.Adapters.Postgres.TypeModule, port: 5432, name: Bilbo.Repo.Pool, otp_app: :bilbo, repo: Bilbo.Repo, timeout: 15000, pool_timeout: 5000, adapter: Ecto.Adapters.Postgres, username: "postgres", password: "postgres", database: "bilbo_dev", hostname: "172.16.123.1", pool_size: 10, pool: DBConnection.Poolboy]}]}, :temporary, 5000, :worker, [DBConnection.Poolboy.Worker]}], {:set, {:set, 10, 16, 16, 8, 80, 48, {[], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []}, {{[#PID<0.933.0>], [#PID<0.934.0>], [#PID<0.935.0>], [#PID<0.936.0>], [#PID<0.937.0>], [#PID<0.938.0>], [#PID<0.939.0>], [#PID<0.940.0>], [#PID<0.941.0>], [], [], [], [], [], [], [#PID<0.932.0>]}}}}, 0, 1, [], 0, :poolboy_sup, {DBConnection.Poolboy.Worker, {Postgrex.Protocol, [types: Ecto.Adapters.Postgres.TypeModule, port: 5432, name: Bilbo.Repo.Pool, otp_app: :bilbo, repo: Bilbo.Repo, timeout: 15000, pool_timeout: 5000, adapter: Ecto.Adapters.Postgres, username: "postgres", password: "postgres", database: "bilbo_dev", hostname: "172.16.123.1", pool_size: 10, pool: DBConnection.Poolboy]}}}

Should we plan on matching these another way?

% elixir --version
Erlang/OTP 20 [erts-9.1.4] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]

Elixir 1.5.2

Send Formatted Stack Traces

Right now this package only sends string messages. You lose out on lots of good stuff like grouping, linking to source files, and tons of other goodies by underusing the API!

The docs are here: https://rollbar.com/docs/api/items_post/

What you're looking for is the child of body. Right now you send { message: { body: "STRINGIFIED EXCEPTION" } }. What you ought to be sending is the trace or trace_chain.

Rollbax.Client function clause error on handle_info from ssl

We get occasional errors from our rollbax client crashing due to handle_info not having a catch all at the end, which is always a good idea as you don't know how the client might goof and send you weird messages ;)

Rollbax.Client.handle_info({:ssl, {:sslsocket, {:gen_tcp, #Port<0.28573>, :tls_connection, :undefined}, #PID<0.7686.0>}

{m, f, a} configuration access?

๐Ÿ‘‹

First of all, thanks a lot for open sourcing this and enabling everyone to use rollbar with elixir ๐ŸŽ‰ ๐Ÿ‘ ๐Ÿ™

Trying to integrate it, I noticed that the following configuration didn't work:

config :rollbax,
  enabled: true,
  access_token: {System, :get_env, ["ROLLBAR_ACCESS_TOKEN"]},
  environment: {System, :get_env, ["BASE_HOST"]}

(we wanted to have the secret only on the production host not the build host)

and resulted in:

** (Mix) Could not start application rollbax: Rollbax.start(:normal, []) returned an error: shutdown: failed to start child: Rollbax.Client
    ** (EXIT) an exception was raised:
        ** (FunctionClauseError) no function clause matching in Rollbax.Item.draft/3
            (rollbax) lib/rollbax/item.ex:9: Rollbax.Item.draft({System, :get_env, ["ROLLBAR_ACCESS_TOKEN"]}, {System, :get_env, ["BASE_HOST"]}, %{})

I'm rather used to it working though :D Although, probably because we don't have any of the more advanced distillery configuration solutions set up.

Would you be open to a PR implementing {m, f, a} environment access or alternatively am I missing an easier way to do this?

Thanks and cheers!
Tobi

edit: I just realized that the distillery docs might have confused me and that ${VAR} still works but I'm not 100% sure :) Question still stands regardless :)

Enabled must be {true, false, :log}

Rollbax Version: 0.9.2
Elixir version: 1.6.0

Just got bit by a subtle issue. My config looks like this

config :rollbax,
  enabled: System.get_env("ROLLBAR_ACCESS_TOKEN"),
  access_token: System.get_env("ROLLBAR_ACCESS_TOKEN"),
  environment: System.get_env("MIX_ENV")

That leads to

 GenServer Rollbax.Client terminating
** (FunctionClauseError) no function clause matching in Rollbax.Client.handle_cast/2
    (rollbax) lib/rollbax/client.ex:62: Rollbax.Client.handle_cast({:emit, {"info", 1547222886, %{<redacted>}, enabled: <redact_access_token>, hackney_responses: %{}, url: "https://api.rollbar.com/api/1/item
/"})

Importantly:

enabled: <redact_access_token> 

So the Client takes the config values literally. I was expecting a truthy value to work here.

Could I send a PR that either

  1. allows the enabled value to {true, false, :log, truthy} OR
  2. logs an error from the Client that the enabled config is invalid OR
  3. at least updates the README with the allowed values

I vote for allowing the value to be truthy since, I'd generally only want rollbax to be enabled if the access token is present

Should not require access_token when not enabled

Currently rollbax refuses to start if an access_token and environment is not given even if it is not actually enabled. This is inconvenient if we want to add rollbax only in the production environment. It is possibly to specify an invalid token and get around this issue, but it feels like that shouldn't be necessary.

Log errors returned by the Rollbar API

If there's an error in the payload, Rollbar will return "err": 1 in the JSON response, but right now we just log the raw (not undecoded) response with Logger.debug. We should parse it and if there are errors, log them with Logger.error.

This is needed because if someone passes something like "person" (which is a field Rollbar is aware of) in the occurrence data) and the value they pass is not conform to what Rollbar wants, they'll never know about this unless they log at the :debug level.

Getting extra request data from Plug

Hi,

Just thought I'd post something I'm using to get request data from Plug to make Rollbax more useful when identifying issues.

Could be something good to refine and include in this package.

defp handle_errors(conn, %{kind: kind, reason: reason, stack: stack}) do
    conn =
      conn
      |> Plug.Conn.fetch_cookies
      |> Plug.Conn.fetch_query_params
      |> Plug.Conn.fetch_session

    remote_ip =
      conn.remote_ip
      |> Tuple.to_list
      |> Enum.join(".")

    headers =
      conn.req_headers
      |> Enum.into(%{})

    conn_data = %{
      "request" => %{
        "cookies" => conn.req_cookies,
        "url" => "#{conn.scheme}://#{conn.host}:#{conn.port}#{conn.request_path}",
        "user_ip" => remote_ip,
        "headers" => headers,
        "session" => conn.private[:plug_session] || %{},
        "params" => conn.params,
        "method" => conn.method,
        "request_id" => UUID.uuid1,
      },
      "server" => %{
        "pid" => System.get_env("DYNO"),
        "host" => "#{System.get_env("HEROKU_APP_NAME")}:#{System.get_env("PORT")}",
        "root" => System.get_env("HOME")
      }
    }

    Rollbax.report(kind, reason, stack, %{}, conn_data)
  end

Support "people tracking" / "person tracking" for non-custom exceptions

I see in the source code that a person value can be passed for custom exceptions:

https://github.com/ForzaElixir/rollbax/blob/master/lib/rollbax.ex#L146

I'm wondering if its possible to configure Rollbax to populate Person/People information for exceptions which are not custom, as described here:

https://docs.rollbar.com/docs/person-tracking

i.e. something similar to the Ruby gem's notion of a person_method:

https://rollbar.com/docs/notifier/rollbar-gem/#person-tracking

Is it possible?

Integrating with Phoenix

Hi,

Thanks for creating this. I am trying to use it in Phoenix app. I added the config, and following the instructions here I added use Plug.ErrorHandler and the following function to lib/myapp_web/router.ex:

  defp handle_errors(conn, %{kind: kind, reason: reason, stack: stacktrace}) do
    Rollbax.report(kind, reason, stacktrace)
  end

To test, I added a raise in a controller action and when I access that action I see the "Internal server error" message. However the error does not get reported to rollbar. I see this in the server logs:

[error] GenServer Rollbax.Client terminating
** (UndefinedFunctionError) function Jason.encode_to_iodata/1 is undefined (module Jason is not available)
 Jason.encode_to_iodata(%{"access_token" .....[redact]
 (rollbax) lib/rollbax/client.ex:70: Rollbax.Client.handle_cast/2
(stdlib) gen_server.erl:616: :gen_server.try_dispatch/4
(stdlib) gen_server.erl:686: :gen_server.handle_msg/6
(stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3

Any guidance would be appreciated. Thanks.

Configuring :enabled from env variable

I can see in the docs that rollbax allows configuring :access_token and :environment from env variables, but not :enabled. What is the rationale for this choice? Would you accept a PR changing this behaviour?

The `:access_token` and `:environment` options accept a binary or a
  `{:system, "VAR_NAME"}` tuple. When given a tuple like `{:system, "VAR_NAME"}`,
  the value will be referenced from `System.get_env("VAR_NAME")` at runtime.

errors when starting an application, e.g. after a deploy or reboot

I'm getting errors similar to this https://gist.github.com/adamkittelson/65523e2c34f15b26b57825c81a4e6c1d when my application first starts.

My best guess is that it's happening because I've added Rollbax.Notifier to my Logger backends as per the readme and that the exception is being raised for log messages that are sent to that backend before the Rollbax.Client GenServer has had a chance to start / register itself.

I think it could be solved similarly to what the Honeybadger library is doing, i.e. if the user configures Rollbax to use the Logger backend then Rollbax can add Rollbax.Notifier as a hander after the Rollbax.Client is running, similar to this: https://github.com/honeybadger-io/honeybadger-elixir/blob/master/lib/honeybadger.ex#L114-L116

Thanks for putting this library together, I was glad to see it existed. While I don't think Airbrake / Honeybadger are necessarily overpriced, I also don't want my error tracking costs to be equivalent to my hosting costs for my side project so Rollbar's free plan is perfect for what I need.

Require access token when enabled only

Rollbax requires an access token (and an environment) even when disabled or set to log mode.

I use the following configuration in config/config.exs:

config :rollbax,
  access_token: {:system, "ROLLBAR_ACCESS_TOKEN"},
  environment: {:system, "ROLLBAR_ENVIRONMENT"}

I then set it to log mode for testing:

config :rollbax,
  enabled: :log

mix test will still fail:

** (Mix) Could not start application rollbax: exited in: Rollbax.start(:normal, [])
    ** (EXIT) an exception was raised:
        ** (ArgumentError) system environment variable "ROLLBAR_ACCESS_TOKEN" is not set
            (rollbax) lib/rollbax.ex:136: Rollbax.fetch_and_resolve_config/1
            (rollbax) lib/rollbax.ex:54: Rollbax.start/2
            (kernel) application_master.erl:273: :application_master.start_it_old/4

I know that I can run mix test --no-start but other applications do need to start. I'm using Elixir 1.4 and could make it not infer the application by using {:rollbax, "~> 0.8.1", runtime: Mix.env != :test}.

All workarounds require more code to use Rollbax, though, so I thought it would be nice to make these required only when they really are.

I'm happy to submit a pull request for this change.

Issue with function clause after updated to 0.9

Sorry for the vague title, not sure how else to describe this. After updating to 0.9 from 0.8.2 I get a strange error from the rollbax back end when running my tests. I've tried cleaning my build and deps but it persists, any help would be greatly appreciated.

21:41:22.614 [error] :gen_event handler Rollbax.Logger installed at Logger
** (exit) an exception was raised:
    ** (FunctionClauseError) no function clause matching in Rollbax.Logger.handle_event/2
        (rollbax) lib/rollbax/logger.ex:62: Rollbax.Logger.handle_event(:flush, %Rollbax.Logger{reporters: [Rollbax.Reporter.Standard]})
        (stdlib) gen_event.erl:573: :gen_event.server_update/4
        (stdlib) gen_event.erl:555: :gen_event.server_notify/4
        (stdlib) gen_event.erl:299: :gen_event.handle_msg/6
        (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3

Default Plug for Plug based applications

Hey guys.

In your documentation, you provide a whole section about using rollbax in Plug-based applications. How about adding a default plug implementation?
We could even copy & paste the implementation from the sentry.io project (MIT Licence) including tests.
Sure, we could write our own module (90% of the required code is in your documentation already), but we start new applications every 2-3 months and copy & paste this module all the time. We could write our own hex package just for this use case, but before we do this, I just want to ask you, if you could imagine adding a default plug implementation to rollbax directly? Should I submit a Pull Request?

How to run tests?

hey,

thanks for this library. i'm already using it in production.

i wanted to run the tests for this project, but it's not clear to me how. if i just run mix test I get an error about (ArgumentError) the configuration parameter :access_token is not set.

when i add a config/config.exs and provide an access token, i get:

* (MatchError) no match of right hand side value: {:error, {:already_started, #PID<0.153.0>}}
     stacktrace:
       test/rollbax/client_test.exs:7: Rollbax.ClientTest.__ex_unit_setup_all_1/1
       test/rollbax/client_test.exs:1: Rollbax.ClientTest.__ex_unit__/2

Explicit host settings are overwritten

We want to be able to send additional data in the host element (like code_version and root), but our values are not being sent.

It seems that Rollbax prefers the host entry from the draft over the explicitly given values.

iex(1)> item = Rollbax.Item.draft("TOKEN", "ENV", %{})
%{"access_token" => "TOKEN",
  "data" => %{"environment" => "ENV", "language" => "Elixir v1.5.2",
    "notifier" => %{"name" => "Rollbax", "version" => "0.8.2"},
    "platform" => "Erlang/OTP 20 [erts-9.1.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]",
    "server" => %{"host" => "Abels-MacBook-Pro"}}}
iex(2)> item = Rollbax.Item.compose(item, {"error", 0, %{}, %{}, %{"server" => %{"root" => "/my/path"}}})
%{"access_token" => "TOKEN",
  "data" => %{"body" => %{}, "environment" => "ENV",
    "language" => "Elixir v1.5.2", "level" => "error",
    "notifier" => %{"name" => "Rollbax", "version" => "0.8.2"},
    "platform" => "Erlang/OTP 20 [erts-9.1.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]",
    "server" => %{"host" => "Abels-MacBook-Pro"}, "timestamp" => 0}}

I am not sure if this is the intended behaviour. Feels like Rollbax should only add the calculated host value (if not given).

Suggest scrubbing HTTP parameters in the documentation

First, I love this tool. Thanks for writing it.

This is mainly about the docs for using Rollbax in Plug applications (specifically Phoenix). I was playing around with it and noticed that there is no parameter filtering going on inside of the example that you give e.g. "password", "password_confirmation". I realized that we can just use the same filtering logic that Phoenix implements in its own logging system and on the params value I just put this:

"params" => conn.params |> Phoenix.Logger.filter_values(Application.get_env(:phoenix, :filter_parameters)),

That way we're not passing around secret values that are not supposed to be captured.

I understand that this is not applicable to all Plug applications although most are probably using Phoenix. I just thought I would suggest putting in a note that ALL parameters will be passed to Rollbar unless otherwise stated.

Thanks!

What is Rollbax supposed to report when enable_crash_reports = true?

I'm sorry but I'm not been able to get Rollbax to report anything automatically when setting enable_crash_reports = true, perhaps I don't fully understand constitutes a crash in elixir, I'm trying to test it simply by throwing an exception, or doing a miss match like {1} = {2} or the DoesNotExist.for_sure() without try/catch, my app is crashing but nothing gets reported.

With the manual try/catch Rollbax.report(:error, exception, System.stacktrace()) it is working, but I can't see what enable_crash_reports: true does.

Perhaps someone can guide me on how I should be using Rollbax out of a phoenix app (in phoenix it's just like magic), should I be using try/catch and report manually? or is enable_crash_reports: true supposed to catch all/most the errors for me?

Thanks a lot.

Capturing error's background information

Hi folks,

Do you think whether it's possible to capture more information that will ease an investigation, like:

  • HTTP request
  • SQL query (if it happened within the Ecto, for example)

"no function clause matching" error in rollbax 0.6.1

Just upgraded to rollbax 0.6.1 from 0.5, and have started to see some errors:

15:19:53.821 [error]  GenServer Rollbax.Client terminating
** (FunctionClauseError) no function clause matching in Rollbax.Client.handle_hackney_response/3
    (rollbax) lib/rollbax/client.ex:100: Rollbax.Client.handle_hackney_response(#Reference<0.0.1.7727>, {:status, 200, "OK"}, %{__struct__: Rollbax.Client, draft: %{"access_token" => "<redacted>", "data" => %{"environment" => "dev", "language" => "Elixir v1.2.5", "notifier" => %{"name" => "Rollbax", "version" => "0.6.1"}, "platform" => "Erlang/OTP 18 [erts-7.2.1] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:10] [hipe] [kernel-poll:false]", "server" => %{"host" => "6d6fbf0e20d7"}}}, enabled: true, url: "https://api.rollbar.com/api/1/item/"})
    (rollbax) lib/rollbax/client.ex:79: Rollbax.Client.handle_info/2
    (stdlib) gen_server.erl:615: :gen_server.try_dispatch/4
    (stdlib) gen_server.erl:681: :gen_server.handle_msg/5
    (stdlib) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
Last message: {:hackney_response, #Reference<0.0.1.7727>, {:status, 200, "OK"}}
State: %{__struct__: Rollbax.Client, draft: %{"access_token" => "<redacted>", "data" => %{"environment" => "dev", "language" => "Elixir v1.2.5", "notifier" => %{"name" => "Rollbax", "version" => "0.6.1"}, "platform" => "Erlang/OTP 18 [erts-7.2.1] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:10] [hipe] [kernel-poll:false]", "server" => %{"host" => "6d6fbf0e20d7"}}}, enabled: true, url: "https://api.rollbar.com/api/1/item/"}

Should I need to specify an access_token for `enabled: :log` ?

I've created a trial Rollbar account and installed Rollbax into my application. But for development purposes I've specified enabled: :log in my config/dev.exs so that I'm not spamming my limited rollbar account while I'm adding logging procedures around my code.

However during startup it tells me to add an access token, which I don't feel is necessary because it won't be sending anything to rollbar yet.

Additionally, I'd like to keep my access_token in prod.secret.exs instead of anything I commit to my public repo, but would like the development environment to pretty much work out of the box.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.