Skip to content

Commit

Permalink
Revert "RUBY-1732 Kwargify ExternalRequestSegment constructor"
Browse files Browse the repository at this point in the history
Kwargs in constructors incur additional object allocations.
  • Loading branch information
mwear committed Oct 9, 2017
1 parent aa54224 commit b041bf6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 23 deletions.
5 changes: 4 additions & 1 deletion lib/new_relic/agent/transaction/external_request_segment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class ExternalRequestSegment < Segment

NR_SYNTHETICS_HEADER = 'X-NewRelic-Synthetics'.freeze

<<<<<<< HEAD
def initialize(library: nil,
uri: nil,
procedure: nil,
Expand All @@ -28,6 +29,9 @@ def initialize(library: nil,
raise ArgumentError, 'missing required argument: uri' if uri.nil?
raise ArgumentError, 'missing required argument: procedure' if procedure.nil?

=======
def initialize library, uri, procedure # :nodoc:
>>>>>>> parent of c48e98d... RUBY-1732 Kwargify ExternalRequestSegment constructor
@library = library
@uri = HTTPClients::URIUtil.parse_and_normalize_url(uri)
@procedure = procedure
Expand Down Expand Up @@ -78,7 +82,6 @@ def add_request_headers request
# @param [Hash] response a hash of response headers
#
# @api public

def read_response_headers response
return unless record_metrics? && CrossAppTracing.cross_app_enabled?
return unless CrossAppTracing.response_has_crossapp_header?(response)
Expand Down
8 changes: 1 addition & 7 deletions lib/new_relic/agent/transaction/tracing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,7 @@ def start_external_request_segment(library: nil,
raise ArgumentError, 'missing required argument: uri' if uri.nil?
raise ArgumentError, 'missing required argument: procedure' if procedure.nil?

segment = ExternalRequestSegment.new(
library: library,
uri: uri,
procedure: procedure,
start_time: start_time
)

segment = ExternalRequestSegment.new library, uri, procedure
start_and_add_segment segment, parent
end

Expand Down
18 changes: 3 additions & 15 deletions test/new_relic/agent/transaction/external_request_segment_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,29 +44,17 @@ def teardown
end

def test_generates_expected_name
segment = ExternalRequestSegment.new(
library: "Typhoeus",
uri: "http://remotehost.com/blogs/index",
procedure: "GET"
)
segment = ExternalRequestSegment.new "Typhoeus", "http://remotehost.com/blogs/index", "GET"
assert_equal "External/remotehost.com/Typhoeus/GET", segment.name
end

def test_downcases_hostname
segment = ExternalRequestSegment.new(
library: "Typhoeus",
uri: "http://ReMoTeHoSt.Com/blogs/index",
procedure: "GET"
)
segment = ExternalRequestSegment.new "Typhoeus", "http://ReMoTeHoSt.Com/blogs/index", "GET"
assert_equal "External/remotehost.com/Typhoeus/GET", segment.name
end

def test_segment_does_not_record_metrics_outside_of_txn
segment = ExternalRequestSegment.new(
library: "Net::HTTP",
uri: "http://remotehost.com/blogs/index",
procedure: "GET"
)
segment = ExternalRequestSegment.new "Net::HTTP", "http://remotehost.com/blogs/index", "GET"
segment.finish

refute_metrics_recorded [
Expand Down

0 comments on commit b041bf6

Please sign in to comment.