Skip to content

Commit

Permalink
Merge pull request #326 from nateberkopec/deprecate-send-on-client
Browse files Browse the repository at this point in the history
Deprecate #send on client
  • Loading branch information
nateberkopec committed May 4, 2015
2 parents 00902b3 + 8c616a2 commit 9f48202
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 12 deletions.
10 changes: 8 additions & 2 deletions lib/raven/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,14 @@ def configure
# @example
# evt = Raven::Event.new(:message => "An error")
# Raven.send(evt)
def send(evt)
client.send(evt)
def send_event(event)
client.send_event(event)
end

def send(event)
Raven.logger.warn "DEPRECATION WARNING: Calling #send on Raven::Base will be \
removed in Raven-Ruby 0.14! Use #send_event instead!"
client.send_event(event)
end

# Capture and process any exceptions from the given block, or globally if
Expand Down
10 changes: 8 additions & 2 deletions lib/raven/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def initialize(configuration)
@state = ClientState.new
end

def send(event)
def send_event(event)
return false unless configuration_allows_sending

# Convert to hash
Expand All @@ -37,7 +37,7 @@ def send(event)
content_type, encoded_data = encode(event)

begin
transport.send(generate_auth_header, encoded_data,
transport.send_event(generate_auth_header, encoded_data,
:content_type => content_type)
rescue => e
failed_send(e, event)
Expand All @@ -49,6 +49,12 @@ def send(event)
event
end

def send(event)
Raven.logger.warn "DEPRECATION WARNING: Calling #send on a Client will be \
removed in Raven-Ruby 0.14! Use #send_event instead!"
send_event(event)
end

private

def configuration_allows_sending
Expand Down
2 changes: 1 addition & 1 deletion lib/raven/transports.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def initialize(configuration)
@configuration = configuration
end

def send#(auth_header, data, options = {})
def send_event#(auth_header, data, options = {})
raise NotImplementedError.new('Abstract method not implemented')
end

Expand Down
9 changes: 7 additions & 2 deletions lib/raven/transports/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
module Raven
module Transports
class HTTP < Transport

def send(auth_header, data, options = {})
def send_event(auth_header, data, options = {})
project_id = self.configuration[:project_id]
path = self.configuration[:path] + "/"

Expand All @@ -20,6 +19,12 @@ def send(auth_header, data, options = {})
response
end

def send(auth_header, data, options = {})
Raven.logger.warn "DEPRECATION WARNING: Calling #send on a Transport will be \
removed in Raven-Ruby 0.14! Use #send_event instead!"
send_event(auth_header, data, options)
end

private

def conn
Expand Down
9 changes: 7 additions & 2 deletions lib/raven/transports/udp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@
module Raven
module Transports
class UDP < Transport

def send(auth_header, data, _options = {})
def send_event(auth_header, data, _options = {})
conn.send "#{auth_header}\n\n#{data}", 0
end

def send(auth_header, data, options = {})
Raven.logger.warn "DEPRECATION WARNING: Calling #send on a Transport will be \
removed in Raven-Ruby 0.14! Use #send_event instead!"
send_event(auth_header, data, options)
end

private

def conn
Expand Down
5 changes: 2 additions & 3 deletions spec/raven/integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,10 @@
config.http_adapter = [:test, stubs]
end

expect(Raven.logger).to receive(:warn).exactly(1).times
expect(Raven.logger).to receive(:warn).exactly(2).times
expect { Raven.capture_exception(build_exception) }.not_to raise_error

stubs.verify_stubbed_calls

end

example "timed backoff should prevent sends" do
Expand All @@ -72,7 +71,7 @@
config.logger = Logger.new(io)
end

expect_any_instance_of(Raven::Transports::HTTP).to receive(:send).exactly(1).times.and_raise(Faraday::Error::ConnectionFailed, "conn failed")
expect_any_instance_of(Raven::Transports::HTTP).to receive(:send_event).exactly(1).times.and_raise(Faraday::Error::ConnectionFailed, "conn failed")
expect { Raven.capture_exception(build_exception) }.not_to raise_error

expect(Raven.logger).to receive(:error).exactly(1).times
Expand Down

0 comments on commit 9f48202

Please sign in to comment.