Skip to content

Commit

Permalink
Release v6.23.0
Browse files Browse the repository at this point in the history
  • Loading branch information
imjoehaines authored Sep 21, 2021
2 parents 0458710 + 00460bf commit 13fe956
Show file tree
Hide file tree
Showing 53 changed files with 2,302 additions and 411 deletions.
51 changes: 51 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,57 @@
Changelog
=========

## v6.23.0 (21 September 2021)

### Enhancements

* Sessions will now be delivered every 10 seconds, instead of every 30 seconds
| [#680](https://github.com/bugsnag/bugsnag-ruby/pull/680)
* Log errors that prevent delivery at `ERROR` level
| [#681](https://github.com/bugsnag/bugsnag-ruby/pull/681)
* Add `on_breadcrumb` callbacks to replace `before_breadcrumb_callbacks`
| [#686](https://github.com/bugsnag/bugsnag-ruby/pull/686)
* Add `context` attribute to configuration, which will be used as the default context for events. Using this option will disable automatic context setting
| [#687](https://github.com/bugsnag/bugsnag-ruby/pull/687)
| [#688](https://github.com/bugsnag/bugsnag-ruby/pull/688)
* Add `Bugsnag#breadcrumbs` getter to fetch the current list of breadcrumbs
| [#689](https://github.com/bugsnag/bugsnag-ruby/pull/689)
* Add `time` (an ISO8601 string in UTC) to `device` metadata
| [#690](https://github.com/bugsnag/bugsnag-ruby/pull/690)
* Add `errors` to `Report`/`Event` containing an array of `Error` objects. The `Error` object contains `error_class`, `error_message`, `stacktrace` and `type` (always "ruby")
| [#691](https://github.com/bugsnag/bugsnag-ruby/pull/691)
* Add `original_error` to `Report`/`Event` containing the original Exception instance
| [#692](https://github.com/bugsnag/bugsnag-ruby/pull/692)
* Add `request` to `Report`/`Event` containing HTTP request metadata
| [#693](https://github.com/bugsnag/bugsnag-ruby/pull/693)
* Add `add_metadata` and `clear_metadata` to `Report`/`Event`
| [#694](https://github.com/bugsnag/bugsnag-ruby/pull/694)
* Add `set_user` to `Report`/`Event`
| [#695](https://github.com/bugsnag/bugsnag-ruby/pull/695)

### Fixes

* Avoid starting session delivery thread when the current release stage is not enabled
| [#677](https://github.com/bugsnag/bugsnag-ruby/pull/677)

### Deprecated

* `before_breadcrumb_callbacks` have been deprecated in favour of `on_breadcrumb` callbacks and will be removed in the next major release
* For consistency with Bugsnag notifiers for other languages, a number of methods have been deprecated in this release. The old options will be removed in the next major version | [#676](https://github.com/bugsnag/bugsnag-ruby/pull/676)
* The `notify_release_stages` configuration option has been deprecated in favour of `enabled_release_stages`
* The `auto_capture_sessions` and `track_sessions` configuration options have been deprecated in favour of `auto_track_sessions`
* The `enabled_automatic_breadcrumb_types` configuration option has been deprecated in favour of `enabled_breadcrumb_types`
* The `Report` class has been deprecated in favour of the `Event` class
* The `Report#meta_data` attribute has been deprecated in favour of `Event#metadata`
* The `Breadcrumb#meta_data` attribute has been deprecated in favour of `Breadcrumb#metadata`
* The `Breadcrumb#name` attribute has been deprecated in favour of `Breadcrumb#message`
* The breadcrumb type constants in the `Bugsnag::Breadcrumbs` module has been deprecated in favour of the constants available in the `Bugsnag::BreadcrumbType` module
For example, `Bugsnag::Breadcrumbs::ERROR_BREADCRUMB_TYPE` is now available as `Bugsnag::BreadcrumbType::ERROR`
* `Report#exceptions` has been deprecated in favour of the new `errors` property
* `Report#raw_exceptions` has been deprecated in favour of the new `original_error` property
* Accessing request data via `Report#metadata` has been deprecated in favour of using the new `request` property. Request data will be moved out of metadata in the next major version
* The `Report#add_tab` and `Report#remove_tab` methods have been deprecated in favour of the new `add_metadata` and `clear_metadata` methods

## v6.22.1 (11 August 2021)

### Fixes
Expand Down
21 changes: 21 additions & 0 deletions TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,24 @@ RUBY_TEST_VERSION=2.6 RAILS_VERSION=6 docker-compose run --use-aliases ruby-maze
```

In order to avoid running flakey or unfinished tests, the tag `"not @wip"` can be added to the tags option. This is recommended for all CI runs. If a tag is already specified, this should be added using the `and` keyword, e.g. `--tags "@rails6 and not @wip"`

## Manually testing queue libraries

To help manually test queue libraries and Active Job with various queue adapters, you can use [the `run-ruby-integrations` script](./features/fixtures/run-ruby-integrations). This takes care of installing your local copy of Bugsnag, booting Rails, setting up the database and booting the queue library

As with the end-to-end tests, only Bugsnag employees can run this script as it relies on the same private resources

The script will default to booting Sidekiq:

```
# run the rails_integrations fixture with sidekiq
$ ./features/fixtures/run-rails-integrations
```

The script can also run Resque, Que or Delayed Job:

```
$ ./features/fixtures/run-rails-integrations resque
$ ./features/fixtures/run-rails-integrations que
$ ./features/fixtures/run-rails-integrations delayed_job
```
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.22.1
6.23.0
6 changes: 6 additions & 0 deletions features/fixtures/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ services:
- SQL_ONLY_BREADCRUMBS
- ADD_ON_ERROR
- USE_DEFAULT_AUTO_CAPTURE_SESSIONS
- ADD_REQUEST_ON_ERROR
restart: "no"

rails4:
Expand Down Expand Up @@ -165,6 +166,7 @@ services:
- SQL_ONLY_BREADCRUMBS
- ADD_ON_ERROR
- USE_DEFAULT_AUTO_CAPTURE_SESSIONS
- ADD_REQUEST_ON_ERROR
restart: "no"

rails5:
Expand Down Expand Up @@ -201,6 +203,7 @@ services:
- SQL_ONLY_BREADCRUMBS
- ADD_ON_ERROR
- USE_DEFAULT_AUTO_CAPTURE_SESSIONS
- ADD_REQUEST_ON_ERROR
restart: "no"

rails6:
Expand Down Expand Up @@ -237,6 +240,7 @@ services:
- SQL_ONLY_BREADCRUMBS
- ADD_ON_ERROR
- USE_DEFAULT_AUTO_CAPTURE_SESSIONS
- ADD_REQUEST_ON_ERROR
restart: "no"
networks:
default:
Expand All @@ -261,6 +265,8 @@ services:
- RUN_AT_EXIT_HOOKS
- ACTIVE_JOB_QUEUE_ADAPTER
restart: "no"
ports:
- "3000:3000"

sidekiq:
build:
Expand Down
2 changes: 1 addition & 1 deletion features/fixtures/plain/app/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def configure_using_environment
conf.auto_notify = ENV["BUGSNAG_AUTO_NOTIFY"] != "false"
conf.ignore_classes << lambda { |ex| ex.class.to_s == ENV["BUGSNAG_IGNORE_CLASS"] } if ENV.include? "BUGSNAG_IGNORE_CLASS"
conf.meta_data_filters << ENV["BUGSNAG_META_DATA_FILTERS"] if ENV.include? "BUGSNAG_META_DATA_FILTERS"
conf.notify_release_stages = [ENV["BUGSNAG_NOTIFY_RELEASE_STAGE"]] if ENV.include? "BUGSNAG_NOTIFY_RELEASE_STAGE"
conf.enabled_release_stages = [ENV["BUGSNAG_NOTIFY_RELEASE_STAGE"]] if ENV.include? "BUGSNAG_NOTIFY_RELEASE_STAGE"
conf.project_root = ENV["BUGSNAG_PROJECT_ROOT"] if ENV.include? "BUGSNAG_PROJECT_ROOT"
conf.proxy_host = ENV["BUGSNAG_PROXY_HOST"] if ENV.include? "BUGSNAG_PROXY_HOST"
conf.proxy_password = ENV["BUGSNAG_PROXY_PASSWORD"] if ENV.include? "BUGSNAG_PROXY_PASSWORD"
Expand Down
7 changes: 7 additions & 0 deletions features/fixtures/rails3/app/config/initializers/bugsnag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,11 @@
})
end)
end

if ENV["ADD_REQUEST_ON_ERROR"] == "true"
config.add_on_error(proc do |report|
report.request[:something] = "hello"
report.request[:params][:another_thing] = "hi"
end)
end
end
7 changes: 7 additions & 0 deletions features/fixtures/rails4/app/config/initializers/bugsnag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,11 @@
})
end)
end

if ENV["ADD_REQUEST_ON_ERROR"] == "true"
config.add_on_error(proc do |report|
report.request[:something] = "hello"
report.request[:params][:another_thing] = "hi"
end)
end
end
11 changes: 9 additions & 2 deletions features/fixtures/rails5/app/config/initializers/bugsnag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
config.auto_notify = ENV["BUGSNAG_AUTO_NOTIFY"] != "false"
config.project_root = ENV["BUGSNAG_PROJECT_ROOT"] if ENV.include? "BUGSNAG_PROJECT_ROOT"
config.ignore_classes << lambda { |ex| ex.class.to_s == ENV["BUGSNAG_IGNORE_CLASS"] } if ENV.include? "BUGSNAG_IGNORE_CLASS"
config.auto_capture_sessions = ENV["BUGSNAG_AUTO_CAPTURE_SESSIONS"] == "true" unless ENV["USE_DEFAULT_AUTO_CAPTURE_SESSIONS"] == "true"
config.auto_track_sessions = ENV["BUGSNAG_AUTO_CAPTURE_SESSIONS"] == "true" unless ENV["USE_DEFAULT_AUTO_CAPTURE_SESSIONS"] == "true"
config.send_code = ENV["BUGSNAG_SEND_CODE"] != "false"
config.send_environment = ENV["BUGSNAG_SEND_ENVIRONMENT"] == "true"
config.meta_data_filters << 'filtered_parameter'

if ENV["SQL_ONLY_BREADCRUMBS"] == "true"
config.before_breadcrumb_callbacks << Proc.new do |breadcrumb|
breadcrumb.ignore! unless breadcrumb.meta_data[:event_name] == "sql.active_record" && breadcrumb.meta_data[:name] == "User Load"
breadcrumb.ignore! unless breadcrumb.metadata[:event_name] == "sql.active_record" && breadcrumb.metadata[:name] == "User Load"
end
end

Expand All @@ -25,4 +25,11 @@
})
end)
end

if ENV["ADD_REQUEST_ON_ERROR"] == "true"
config.add_on_error(proc do |report|
report.request[:something] = "hello"
report.request[:params][:another_thing] = "hi"
end)
end
end
7 changes: 7 additions & 0 deletions features/fixtures/rails6/app/config/initializers/bugsnag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,11 @@
})
end)
end

if ENV["ADD_REQUEST_ON_ERROR"] == "true"
config.add_on_error(proc do |report|
report.request[:something] = "hello"
report.request[:params][:another_thing] = "hi"
end)
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class JobController < ApplicationController
def working
WorkingJob.perform_later

render json: { result: 'queued WorkingJob!' }
end

def unhandled
UnhandledJob.perform_later

render json: { result: 'queued UnhandledJob!' }
end
end
23 changes: 23 additions & 0 deletions features/fixtures/rails_integrations/app/app/jobs/working_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class WorkingJob < ApplicationJob
self.queue_adapter = ENV['ACTIVE_JOB_QUEUE_ADAPTER'].to_sym

def perform
do_stuff

more_stuff

success!
end

def do_stuff
'beep boop'
end

def more_stuff
'boop beep'
end

def success!
'yay'
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Application < Rails::Application
# Only loads a smaller set of middleware suitable for API only apps.
# Middleware like session, flash, cookies can be added back manually.
# Skip views, helpers and assets when generating a new resource.
config.api_only = true
# config.api_only = true

config.autoload_paths << Rails.root.join('app/workers')
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,6 @@
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker

config.hosts = []
end
3 changes: 2 additions & 1 deletion features/fixtures/rails_integrations/app/config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Rails.application.routes.draw do
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
get '/job/working', 'job#working'
get '/job/unhandled', 'job#unhandled'
end
120 changes: 120 additions & 0 deletions features/fixtures/run-ruby-integrations
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
#!/usr/bin/env ruby

require "socket"
require "timeout"
require "pathname"

DOCKER_DIRECTORY = Pathname.new(__dir__)
ROOT_DIRECTORY = DOCKER_DIRECTORY + "../.."
FIXTURE_DIRECTORY = DOCKER_DIRECTORY + "rails_integrations"

raise "Fixture directory does not exist at: '#{FIXTURE_DIRECTORY}'" unless FIXTURE_DIRECTORY.exist?

QUEUE_LIBRARY_COMMANDS = {
sidekiq: 'sidekiq',
resque: 'rake resque:work',
que: 'que --log-level debug --queue-name "*" ./config/environment.rb',
delayed_job: 'rake jobs:work',
}

QUEUE_LIBRARY = ARGV.fetch(0, :sidekiq).to_sym

raise "Invalid queue libarary '#{QUEUE_LIBRARY}'" unless QUEUE_LIBRARY_COMMANDS.key?(QUEUE_LIBRARY)

def wait_for_port(port, max_attempts: 60, seconds_between_attempts: 1)
is_open = false
attempts = 0

until is_open || attempts > max_attempts
begin
attempts += 1

# add a timeout as sometimes TCPSocket will wait for ages before realising
# it can't connect - this is a local port so should be """instant"""
Timeout.timeout(2) do
TCPSocket.new("127.0.0.1", port).close

# success!
is_open = true
end
rescue Timeout::Error, Errno::ECONNREFUSED, Errno::EHOSTUNREACH
# ignore timeouts and errors from the port being closed

# wait between attempts to give the port some time to open
sleep(seconds_between_attempts)
end
end

raise "Port #{port} not open in time!" unless is_open
end

def run_in_shell(command, env: {}, background: false)
puts "running '#{command}' with env: #{env}, background: #{background}"

if background
spawn(env, command)
else
system(env, command, exception: true)
end
end

def run_docker_command(command, env: {}, **kwargs)
default_env = { "NETWORK_NAME" => "notwerk-norm", "ACTIVE_JOB_QUEUE_ADAPTER" => QUEUE_LIBRARY.to_s }

run_in_shell(command, env: default_env.merge(env), **kwargs)
end

# ensure we clean up after ourselves on exit
at_exit do
temp_bugsnag_lib = FIXTURE_DIRECTORY + "temp-bugsnag-lib"
temp_bugsnag_lib.rmtree if temp_bugsnag_lib.exist?

# stop the docker compose stack
Dir.chdir(FIXTURE_DIRECTORY) do
run_docker_command("docker-compose down")
end
end

# build the bugsnag gem and move it to the fixture directory
Dir.chdir(ROOT_DIRECTORY) do
run_in_shell("gem build bugsnag.gemspec -o bugsnag.gem")
run_in_shell("mv bugsnag.gem #{FIXTURE_DIRECTORY}")
end

Dir.chdir(FIXTURE_DIRECTORY) do
# unpack the gem into the directory the dockerfile expects
run_in_shell("gem unpack bugsnag.gem --target temp-bugsnag-lib")
run_in_shell("rm bugsnag.gem")

rails_pid = run_docker_command(
"docker-compose up --build rails_integrations",
env: { "RUBY_TEST_VERSION" => "2.7" },
background: true
)

# wait for the container to finish building & starting
wait_for_port(3000)

# setup and migrate the database
run_docker_command("docker-compose run rails_integrations bundle exec rake db:prepare")
run_docker_command("docker-compose run rails_integrations bundle exec rake db:migrate")

# run the queue library in the background (not using '--detach' so we can see the logs)
queue_library_pid = run_docker_command(
"docker-compose run rails_integrations bundle exec #{QUEUE_LIBRARY_COMMANDS[QUEUE_LIBRARY]}",
background: true
)

# give the queue library some time to start before we print stuff, otherwise
# we'll print before the library does
sleep(5)

puts "Everything is running!"

# this will wait forever as the queue libraries won't exit on their own - quit with Ctrl+C
Process.wait(queue_library_pid)

# the queue library has exited (because of Ctrl+C) so tell rails to stop too,
# otherwise you'll need to Ctrl+C twice and no one has time for that
Process.kill("TERM", rails_pid)
end
Loading

0 comments on commit 13fe956

Please sign in to comment.