ProductPromotion
Logo

Elixir

made by https://0x3d.site

GitHub - getsentry/sentry-elixir: The official Elixir SDK for Sentry (sentry.io)
The official Elixir SDK for Sentry (sentry.io). Contribute to getsentry/sentry-elixir development by creating an account on GitHub.
Visit Site

GitHub - getsentry/sentry-elixir: The official Elixir SDK for Sentry (sentry.io)

GitHub - getsentry/sentry-elixir: The official Elixir SDK for Sentry (sentry.io)

Bad software is everywhere, and we're tired of it. Sentry is on a mission to help developers write better software faster, so we can get back to enjoying technology. If you want to join us Check out our open positions

Build Status Hex Package Hex Docs

This is the official Sentry SDK for Sentry.

💁: This README documents unreleased features (from the master branch). For documentation on the current release, see the official documentation.

Getting Started

Install

To use Sentry in your project, add it as a dependency in your mix.exs file. Sentry does not install a JSON library nor HTTP client by itself. Sentry will default to trying to use Jason for JSON serialization and Hackney for HTTP requests, but can be configured to use other ones. To use the default ones, do:

defp deps do
  [
    # ...

    {:sentry, "~> 10.0"},
    {:jason, "~> 1.4"},
    {:hackney, "~> 1.19"}
  ]
end

Configuration

Sentry has a range of configuration options, but most applications will have a configuration that looks like the following:

# config/config.exs
config :sentry,
  dsn: "https://[email protected]/1",
  environment_name: config_env(),
  enable_source_code_context: true,
  root_source_code_paths: [File.cwd!()]

Usage

This library comes with a :logger handler to capture error messages coming from process crashes. To enable this, add the handler when your application starts:

  def start(_type, _args) do
+   :logger.add_handler(:sentry_handler, Sentry.LoggerHandler, %{})

    # ...
  end

The handler can also be configured to capture Logger metadata. See the documentation here.

Sometimes you want to capture specific exceptions manually. To do so, use Sentry.capture_exception/2.

try do
  ThisWillError.really()
rescue
  my_exception ->
    Sentry.capture_exception(my_exception, stacktrace: __STACKTRACE__)
end

Sometimes you want to capture messages that are not exceptions. To do that, use Sentry.capture_message/2:

Sentry.capture_message("custom_event_name", extra: %{extra: information})

To learn more about how to use this SDK, refer to the documentation.

Testing Your Configuration

To ensure you've set up your configuration correctly we recommend running the included Mix task. It can be tested on different Mix environments and will tell you if it is not currently configured to send events in that environment:

MIX_ENV=dev mix sentry.send_test_event

Testing with Sentry

In some cases, you may want to test that certain actions in your application cause a report to be sent to Sentry. Sentry itself does this by using Bypass. It is important to note that when modifying the environment configuration the test case should not be run asynchronously, since you are modifying global configuration. Not returning the environment configuration to its original state could also affect other tests depending on how the Sentry configuration interacts with them. A good way to make sure to revert the environment is to use the on_exit/2 callback that ships with ExUnit.

For example:

test "add/2 does not raise but sends an event to Sentry when given bad input" do
  bypass = Bypass.open()

  Bypass.expect(bypass, fn conn ->
    assert {:ok, _body, conn} = Plug.Conn.read_body(conn)
    Plug.Conn.resp(conn, 200, ~s<{"id": "340"}>)
  end)

  Sentry.put_config(:dsn, "http://public:secret@localhost:#{bypass.port}/1")
  Sentry.put_config(:send_result, :sync)

  on_exit(fn ->
    Sentry.put_config(:dsn, nil)
    Sentry.put_config(:send_result, :none)
  end)

  MyModule.add(1, "a")
end

When testing, you will also want to set the :send_result type to :sync, so that sending Sentry events blocks until the event is sent.

Integrations

Contributing to the SDK

Please make sure to read the CONTRIBUTING.md before making a pull request.

Thanks to everyone who has contributed to this project so far.

Getting Help/Support

If you need help setting up or configuring the Elixir SDK (or anything else in the Sentry universe) please head over to the Sentry Community on Discord. There is a ton of great people in our Discord community ready to help you!

Resources

  • Documentation
  • Forum
  • Discord
  • Stack Overflow
  • Twitter Follow

License

Licensed under the MIT license, see LICENSE.

Articles
to learn more about the elixir concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here 🔥.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here 🔥.

Queries
or most google FAQ's about Elixir.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory