Skip to content

Commit

Permalink
Merge 1497128 into 72f8d86
Browse files Browse the repository at this point in the history
  • Loading branch information
tycooon committed Dec 26, 2018
2 parents 72f8d86 + 1497128 commit f14787c
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 18 deletions.
4 changes: 1 addition & 3 deletions lib/lamian/raven_context_extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ module Lamian::RavenContextExtension
# @see https://www.rubydoc.info/gems/sentry-raven/0.9.2/Raven/Context#extra-instance_method
def extra
log = Lamian.dump(format: :txt)
return super unless log
extra = super || {}
extra.merge(lamian_log: log)
log ? super.merge!(lamian_log: log) : super
end
end
2 changes: 1 addition & 1 deletion lib/lamian/sidekiq_raven_middleware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def call(*)
begin
yield
rescue Exception # rubocop:disable Lint/RescueException
Raven.extra_context(lamian_log: Lamian.dump(format: :txt))
Raven.extra_context # Just trigger saving of the current log
raise
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/lamian/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ module Lamian
# According to this, it is enought to specify '~> a.b'
# if private API was not used and to specify '~> a.b.c' if it was

VERSION = "1.1.0"
VERSION = "1.1.1"
end
12 changes: 1 addition & 11 deletions spec/lamian/raven_context_extension_spec.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
# frozen_string_literal: true

require "raven"
require "raven/transports/dummy"

Raven::Context.prepend(Lamian::RavenContextExtension)

Raven.configure do |config|
config.dsn = "dummy://public@example.com/project-id"
config.encoding = "json"
config.logger = Logger.new(nil)
end

describe Lamian::RavenContextExtension, :cool_loggers do
after { sent_events.clear }
after { Raven::Context.clear! }

let(:sent_events) { Raven.client.transport.events }
let(:extra_info) { JSON.parse(sent_events.last[1]).fetch("extra") }
Expand Down
3 changes: 1 addition & 2 deletions spec/lamian/sidekiq_raven_middleware_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

describe Lamian::SidekiqRavenMiddleware, :cool_loggers do
it "call Raven.extra_context with proper lamian_log" do
expect(Raven).to receive(:extra_context).with(lamian_log: "some log\n")
expect(Raven).to receive(:extra_context)

middleware_call = proc do
Lamian::SidekiqRavenMiddleware.new.call do
generic_logger.info "some log"
raise "some error"
end
end
Expand Down
2 changes: 2 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

require "lamian"

require_relative "support/raven"

RSpec.configure do |config|
config.order = :random
end
Expand Down
12 changes: 12 additions & 0 deletions spec/support/raven.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

require "raven"
require "raven/transports/dummy"

Raven::Context.prepend(Lamian::RavenContextExtension)

Raven.configure do |config|
config.dsn = "dummy://public@example.com/project-id"
config.encoding = "json"
config.logger = Logger.new(nil)
end

0 comments on commit f14787c

Please sign in to comment.