newrelic / elixir_agent

New Relic's Open Source Elixir Agent

Home Page:https://hex.pm/packages/new_relic_agent

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Provide Notice Errors in Elixir Agent

JamieMaclean opened this issue · comments

I'd just like to say thank you for maintaining this library! So far my experience with it has been great!

Is your feature request related to a problem? Please describe.
From what I can see, error reporting is handled via cowboy telemetry events which means that handled errors are never sent to New Relic to be seen in the UI.

I've seen that some of the other agents support this via e.g. in Python:

newrelic.agent.notice_error(error=None, attributes={}, expected=None, ignore=None, status_code=None, application=None)

It would be good to have similar functionality in Elixir.

Describe the solution you'd like
Creation of something similar to:

NewRelic.report_notice_error(%{error: nil, attributes=%{}, expected: nil, ignore: nil, status_code: nil, application: nil})

Describe alternatives you've considered
So far our work around is to send a custom event with the stacktrace and create an alert in the UI. But this is a non-optimal solution.

I may also be able to find some time to work on this.

hi @JamieMaclean. May I ask you how have you implemented the workaround you described using this elixir agent ? Thx!

hi @JamieMaclean. May I ask you how have you implemented the workaround you described using this elixir agent ? Thx!

Hey @ivanfrias, sure thing. It is something along the lines of:

try do
  raise("Raise for some reason")
rescue
  e ->
    NewRelic.report_custom_event("MyHandledError", %{
      exception: inspect(e),
      stacktrace: inspect(__STACKTRACE__)
    })

  continue_as_if_nothing_ever_happened()
end

Then, in the UI, you can create alerts based on this custom event.

Like I said, not ideal... But it works.

I think Sentry has this one implemented, but they have to parse the log to achieve this. It looks like BEAM is that easy to instrument to catch all unhandled exceptions