-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace deprecated GenEvent with Erlang's :gen_event #12
Open
clifton-mcintosh
wants to merge
12
commits into
romul:master
Choose a base branch
from
clifton-mcintosh:use_erlang_gen_event
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Replace deprecated GenEvent with Erlang's :gen_event #12
clifton-mcintosh
wants to merge
12
commits into
romul:master
from
clifton-mcintosh:use_erlang_gen_event
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I am going to make a small change to this PR because configs from a library are not imported by a project that uses the library. I will close this PR until that change is made. I will re-open it once that change is made. |
Configs from a library are not normally imported by a project that uses that library. This sets HTTPoisong as a default HTTP handler if/when the config for a handler is not present.
Retrieving the HTTP adapter has been updated to:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The main goal of the work in this change is to replace the deprecated
GenEvent
with Erlang's:gen_event
. In support of that goal, the HTTP handler is set in test using a Mock handler with the Mox library while HTTPPoison is set as the HTTP handler outside of test. With a mock HTTP handler available, tests forAirbrake.Worker.report/1
andAirbrake.Worker.remember/1
are also aded.Replace deprecated
GenEvent
with Erlang's:gen_event
The
GenEvent
behaviour in Elixir is deprecated. When it is in use,Airbrake.LoggerBackend
generates the following warning.Using
@behaviour :gen_event
is one of the suggested ways to replaceuse GenEvent
. That replacement is done here: https://github.com/clifton-mcintosh/airbrake-elixir/blob/use_erlang_gen_event/lib/airbrake/logger_backend.ex#L4.This is the central change in this pull request.
Tests to increase confidence that replacement is safe
In order to increase confidence that replacing
use GenEvent
with@behaviour :gen_event
inAirbrake.LoggerBackend
is safe, tests were added toAirbrake.LoggerBackend
prior to changing to verify that when the logger backend is set toAirbrake.LoggerBackend
and an error is logged, it is correctly sent to the HTTP handler that is responsible for sending an error to Airbrake.Once the tests were added (see ae37114),
use GenEvent
was replaced with@behaviour :gen_event
. (See 323f01d).Tests for
Airbrake.Worker
With a test HTTP handler in place, tests were also added for
Airbrake.Worker.report/1
andAirbrake.Worker.remember/1
. The tests forAirbrake.Worker.report/1
use the test HTTP handler to verify that the expected data are sent when a report is requested.Calling
Airbrake.start()
in specific testsBecause
Airbrake.Worker.remember/1
alters the state of theAirbrake.Worker
module, having one version start up can present difficulties during testing. In particular, sometimes extra data would be present in other tests (forAirbrake.Worker.report/1
) when the tests forAirbrake.Worker.remember/1
. To remove this problem, testing is set to use the--no-start
flag and tests that needAirbrake.start()
to run have it explicitly invoked during setup.Tests for the
Airbrake.Worker
module start and stop that module before and after each test so that state from one test does not affect the results of another one.Commit order
GitHub is listing commits out of order. When I run git log locally, this is the order I see:
That also matches the order of the commits when looking at the branch in GitHub. See https://github.com/clifton-mcintosh/airbrake-elixir/commits/use_erlang_gen_event.
The incorrect order in the pull request may be because I did some rebasing before pushing to GitHub.