Coder Social home page Coder Social logo

sentry-logger-backend's Introduction

Deprecation notice

As of sentry-elixir 7.0, Sentry now ship their own Sentry.LoggerBackend (including in 8.0 the ability to sent non-exception messages to Sentry), which should be used instead of this. As a result this project is now deprecated. Users are recommended to migrate to the new official Sentry.LoggerBackend as and when they upgrade their sentry-elixir version.

SentryLoggerBackend

Provides a Logger backend for Sentry, to automatically submit Logger events above a configurable threshold to Sentry

Installation

  1. Add sentry_logger_backend to your list of dependencies in mix.exs:
def deps do
  [{:sentry_logger_backend, "~> 0.1.0"}]
end
  1. Add SentryLoggerBackend to the list of logger backends in your config, e.g.
config :logger, backends: [:console, SentryLoggerBackend]
  1. Set the level threshold (defaults to :error - but see warning below):
config :logger, SentryLoggerBackend, level: :error

Fingerprints

Can supply a custom fingerprint to a Logger call with the fingerprint metadata, which should be a list(String.t) (see Sentry's documentation for more info). For example:

Logger.warn "oh no - #{debugging data that's different each time}", fingerprint: ["oh-no"]

Please note if setting level to :warn, :info, or :debug

The current version of elixir-sentry logs problems encountered while posting to sentry at the :warn level.

That means that if you configure the level threshold to anything other than :error, and there's a problem posting to sentry, then this can result in an infinite loop of error-posting attempts.

The suggested solution for now, if you want to use a threshold other than :error, is to use my fork of sentry-elixir, which adds :skip_sentry metadata to that logger call. Future plans are to include a custom http client in sentry-logger-backend, see #1 .

License

This project is licensed under the MIT License.

sentry-logger-backend's People

Contributors

simonwoolf avatar tpitale avatar

Stargazers

Ben Church avatar Takayuki Matsubara avatar Christoph Grabo avatar

Watchers

James Cloos avatar  avatar

sentry-logger-backend's Issues

Log level has no default config?

I added the package to mix and the config, but now I get this error in Sentry:

Elixir.FunctionClauseError: no function clause matching in Logger.level_to_number/1
  File "lib/logger.ex", line 536, in Logger.level_to_number/1
  File "lib/logger.ex", line 533, in Logger.compare_levels/2
  File "lib/sentry_logger_backend.ex", line 76, in SentryLoggerBackend.meet_level?/2
  File "lib/sentry_logger_backend.ex", line 33, in SentryLoggerBackend.handle_event/2
  File "gen_event.erl", line 577, in :gen_event.server_update/4
  File "gen_event.erl", line 559, in :gen_event.server_notify/4
  File "gen_event.erl", line 300, in :gen_event.handle_msg/6
  File "proc_lib.erl", line 249, in :proc_lib.init_p_do_apply/3

I did not include the level: :error because the README says it should be the default.

Fingerprinting callback causes badfun EXIT

(ErlangError) Erlang error: {
  :EXIT, {
    {
      :badfun,
    },
    [
      {SentryLoggerBackend, :handle_event, 2, [file: 'lib/sentry_logger_backend.ex', line: 47]},
      {:gen_event, :server_update, 4, [file: 'gen_event.erl', line: 577]},
      {:gen_event, :server_notify, 4, [file: 'gen_event.erl', line: 559]},
      {:gen_event, :handle_msg, 6, [file: 'gen_event.erl', line: 300]},
      {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 249]}
    ]
  }
}

Callbacks or function to customize fingerprint

For error logs that we don't have access to in our own code (like process crashes) it would be cool to be able to munge the error with our own fingerprint processing so that sentry will properly group the same messages, even if they have different references or pids.

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.