Git Product home page Git Product logo

task_bunny_sentry's Introduction

TaskBunnySentry

Hex.pm

TaskBunny failure backend for Sentry. A port of task_bunny_rollbar.

Installation

def deps do
  [{:task_bunny_sentry, "~> 0.2.0"}]
end

Configuration

config :task_bunny,
  failure_backend: [TaskBunnySentry]

Check TaskBunny for more configuration options.

Customization

Report only rejected

Sometimes it's best to report only when the job has entered a rejected state. To do this, one can write a wrapper around the reporting module, pattern matting on the JobError.

defmodule TaskBunnySentryWrapper do
  use TaskBunny.FailureBackend
  alias TaskBunny.JobError

  # Match only on rejected state
  def report_job_error(error = %JobError{reject: true}),
    do: TaskBunnySentry.report_job_error(error)

  # Otherwise ignore
  def report_job_error(_), do: nil
end

Passing additional exception fields

For instances where one needs to pass additional meta information, a wrapper and be similarly used to extract values from the exception struct.

defmodule FooError do
  defexception([:message, :foo, :fizz])
end

defmodule TaskBunnySentryWrapper do
  use TaskBunny.FailureBackend
  alias TaskBunny.JobError

  # Define the props to be collected from FooError
  def report_job_error(error = %JobError{exception: %FooError{}}),
    do: TaskBunnySentry.report_job_error(error, extra: [:foo, :fizz])

  # Otherwise delegate
  def report_job_error(error), do: TaskBunnySentry.report_job_error(error)
end

Note: When using a wrapper module, it must be set as the failure backend.

config :task_bunny, failure_backend: [TaskBunnySentryWrapper]

Copyright and License

Copyright (c) 2018 Homepolish, Inc.

TaskBunnySentry code is licensed under the MIT License.

task_bunny_sentry's People

Contributors

ono avatar erikreedstrom avatar christianjgreen avatar stanislav-lapata avatar

Watchers

James Cloos avatar Carlos Lira avatar

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.