{"id":13507858,"url":"https://github.com/getsentry/sentry-elixir","last_synced_at":"2025-12-11T23:53:09.365Z","repository":{"id":19679616,"uuid":"22933562","full_name":"getsentry/sentry-elixir","owner":"getsentry","description":"The official Elixir SDK for Sentry (sentry.io)","archived":false,"fork":false,"pushed_at":"2025-05-13T13:55:25.000Z","size":18900,"stargazers_count":652,"open_issues_count":14,"forks_count":200,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-05-13T14:54:20.491Z","etag":null,"topics":["hacktoberfest","sdk","tag-production","team-web-backend"],"latest_commit_sha":null,"homepage":"https://sentry.io","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/getsentry.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"custom":["https://sentry.io/pricing/","https://sentry.io/"]}},"created_at":"2014-08-13T22:38:05.000Z","updated_at":"2025-05-06T12:29:24.000Z","dependencies_parsed_at":"2023-07-15T04:14:49.304Z","dependency_job_id":"2db31002-76e1-4ab9-b27d-e394eb60147a","html_url":"https://github.com/getsentry/sentry-elixir","commit_stats":{"total_commits":1042,"total_committers":121,"mean_commits":8.611570247933884,"dds":0.6074856046065259,"last_synced_commit":"3fa60491391d0d345bac42b983c2ca540b02f531"},"previous_names":["vishnevskiy/raven-elixir"],"tags_count":80,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getsentry%2Fsentry-elixir","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getsentry%2Fsentry-elixir/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getsentry%2Fsentry-elixir/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getsentry%2Fsentry-elixir/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/getsentry","download_url":"https://codeload.github.com/getsentry/sentry-elixir/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253990468,"owners_count":21995774,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","sdk","tag-production","team-web-backend"],"created_at":"2024-08-01T02:00:41.251Z","updated_at":"2025-12-11T23:53:09.355Z","avatar_url":"https://github.com/getsentry.png","language":"Elixir","readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://sentry.io/?utm_source=github\u0026utm_medium=logo\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://sentry-brand.storage.googleapis.com/sentry-wordmark-dark-280x84.png\" alt=\"Sentry\" width=\"280\" height=\"84\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n_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 [\u003ckbd\u003e**Check out our open positions**\u003c/kbd\u003e](https://sentry.io/careers/)_\n\n![Build Status](https://github.com/getsentry/sentry-elixir/actions/workflows/main.yml/badge.svg)\n[![Hex Package](https://img.shields.io/hexpm/v/sentry.svg)](https://hex.pm/packages/sentry)\n[![Hex Docs](https://img.shields.io/badge/hex-docs-blue.svg)](https://hexdocs.pm/sentry)\n\nThis is the official Sentry SDK for [Sentry].\n\n*💁: This README documents unreleased features (from the `master` branch). For documentation on the current release, see [the official documentation][docs].*\n\n## Getting Started\n\n### Install\n\nTo use Sentry in your project, add it as a dependency in your `mix.exs` file.\n\nSentry does not install a JSON library nor an HTTP client by itself. Sentry will default to the [built-in `JSON`](https://hexdocs.pm/elixir/JSON.html) for JSON and [Hackney] for HTTP requests, but can be configured to use other ones. To use the default ones, do:\n\n```elixir\ndefp deps do\n  [\n    # ...\n\n    {:sentry, \"~\u003e 11.0\"},\n    {:hackney, \"~\u003e 1.20\"}\n  ]\nend\n```\n\n\u003e [!WARNING]\n\u003e If you're using an Elixir version before 1.18, the Sentry SDK will default to [Jason] as the JSON library. However, you **must** add it to your dependencies:\n\u003e\n\u003e ```elixir\n\u003e defp deps do\n\u003e   [\n\u003e     # ...\n\u003e     {:sentry, \"~\u003e 10.8.1\"},\n\u003e     {:jason, \"~\u003e 1.4\"}\n\u003e   ]\n\u003e end\n\u003e ```\n\n### Configuration\n\nSentry has a range of configuration options, but most applications will have a configuration that looks like the following:\n\n```elixir\n# config/config.exs\nconfig :sentry,\n  dsn: \"https://public_key@app.getsentry.com/1\",\n  environment_name: config_env(),\n  enable_source_code_context: true,\n  root_source_code_paths: [File.cwd!()]\n```\n\n### Usage\n\nThis library comes with a [`:logger` handler][logger-handlers] to capture error messages coming from process crashes. To enable this, add [`Sentry.LoggerHandler`](https://hexdocs.pm/sentry/Sentry.LoggerHandler.html) to your production configuration:\n\n```elixir\n# config/prod.exs\nconfig :my_app, :logger, [\n  {:handler, :my_sentry_handler, Sentry.LoggerHandler, %{\n    config: %{\n      metadata: [:file, :line],\n      rate_limiting: [max_events: 10, interval: _1_second = 1_000],\n      # Logs all messages with level `:error` and above to Sentry.\n      # Remove :capture_log_messages and :level if you only want to report crashes.\n      capture_log_messages: true,\n      level: :error\n    }\n  }}\n]\n\n```\n\nAnd then add your logger when your application starts:\n\n```elixir\n# lib/my_app/application.ex\ndef start(_type, _args) do\n  Logger.add_handlers(:my_app)\n\n  # ...\nend\n```\n\nAlternatively, you can skip the `:logger` configuration and add the handler directly\nto your application's `start/2` callback:\n\n```elixir\n# lib/my_app/application.ex\ndef start(_type, _args) do\n  :logger.add_handler(:my_sentry_handler, Sentry.LoggerHandler, %{\n    config: %{\n      metadata: [:file, :line],\n      rate_limiting: [max_events: 10, interval: _1_second = 1_000],\n      capture_log_messages: true,\n      level: :error\n    }\n  })\n\n  # ...\nend\n```\n\nSee all logger configuration options [here](https://hexdocs.pm/sentry/Sentry.LoggerHandler.html).\n\n#### Capture exceptions manually\n\nSometimes you want to capture specific exceptions manually. To do so, use [`Sentry.capture_exception/2`](https://hexdocs.pm/sentry/Sentry.html#capture_exception/2).\n\n```elixir\ntry do\n  ThisWillError.really()\nrescue\n  my_exception -\u003e\n    Sentry.capture_exception(my_exception, stacktrace: __STACKTRACE__)\nend\n```\n\nSometimes you want to capture **messages** that are not exceptions. To do that, use [`Sentry.capture_message/2`](https://hexdocs.pm/sentry/Sentry.html#capture_exception/2):\n\n```elixir\nSentry.capture_message(\"custom_event_name\", extra: %{extra: information})\n```\n\nTo learn more about how to use this SDK, refer to [the documentation][docs].\n\n#### Testing Your Configuration\n\nTo ensure you've set up your configuration correctly we recommend running the\nincluded 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:\n\n```bash\nMIX_ENV=dev mix sentry.send_test_event\n```\n\n### Testing with Sentry\n\nIn 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`][exunit-on-exit] callback that ships with ExUnit.\n\nFor example:\n\n```elixir\ntest \"add/2 does not raise but sends an event to Sentry when given bad input\" do\n  bypass = Bypass.open()\n\n  Bypass.expect(bypass, fn conn -\u003e\n    assert {:ok, _body, conn} = Plug.Conn.read_body(conn)\n    Plug.Conn.resp(conn, 200, ~s\u003c{\"id\": \"340\"}\u003e)\n  end)\n\n  Sentry.put_config(:dsn, \"http://public:secret@localhost:#{bypass.port}/1\")\n  Sentry.put_config(:send_result, :sync)\n\n  on_exit(fn -\u003e\n    Sentry.put_config(:dsn, nil)\n    Sentry.put_config(:send_result, :none)\n  end)\n\n  MyModule.add(1, \"a\")\nend\n```\n\nWhen testing, you will also want to set the `:send_result` type to `:sync`, so that sending Sentry events blocks until the event is sent.\n\n## Integrations\n\n  * [Phoenix and Plug][setup-phoenix-and-plug]\n\n## Contributing to the SDK\n\nPlease make sure to read the [CONTRIBUTING.md](CONTRIBUTING.md) before making a pull request.\n\nThanks to everyone who has contributed to this project so far.\n\n\u003ca href=\"https://github.com/getsentry/sentry-elixir/graphs/contributors\"\u003e\n  \u003cimg src=\"https://contributors-img.web.app/image?repo=getsentry/sentry-elixir\" /\u003e\n\u003c/a\u003e\n\n## Getting Help/Support\n\nIf 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](https://discord.com/invite/Ww9hbqr). There is a ton of great people in our Discord community ready to help you!\n\n## Resources\n\n  * [![Documentation](https://img.shields.io/badge/documentation-hexdocs.svg)][docs]\n  * [![Forum](https://img.shields.io/badge/forum-sentry-green.svg)](https://forum.sentry.io/c/sdks)\n  * [![Discord](https://img.shields.io/discord/621778831602221064)](https://discord.gg/Ww9hbqr)\n  * [![Stack Overflow](https://img.shields.io/badge/stack%20overflow-sentry-green.svg)](http://stackoverflow.com/questions/tagged/sentry)\n  * [![X Follow](https://img.shields.io/twitter/follow/sentry?label=sentry\u0026style=social)](https://x.com/intent/follow?screen_name=sentry)\n\n## License\n\nLicensed under the MIT license, see [`LICENSE`](./LICENSE).\n\n[Sentry]: http://sentry.io/\n[Jason]: https://github.com/michalmuskala/jason\n[Hackney]: https://github.com/benoitc/hackney\n[Bypass]: https://github.com/PSPDFKit-labs/bypass\n[docs]: https://hexdocs.pm/sentry/readme.html\n[logger-handlers]: https://www.erlang.org/doc/apps/kernel/logger_chapter#handlers\n[setup-phoenix-and-plug]: https://hexdocs.pm/sentry/setup-with-plug-and-phoenix.html\n[exunit-on-exit]: https://hexdocs.pm/ex_unit/ExUnit.Callbacks.html#on_exit/2\n","funding_links":["https://sentry.io/pricing/","https://sentry.io/"],"categories":["Errors and Exception Handling","Elixir","Errors logging"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgetsentry%2Fsentry-elixir","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgetsentry%2Fsentry-elixir","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgetsentry%2Fsentry-elixir/lists"}