1. Michael Granger
  2. Strelka-NewRelic

Commits

Michael Granger  committed d684919

Change the browser-timing code to use the request notes.

  • Participants
  • Parent commits a4aa86d
  • Branches default

Comments (0)

Files changed (2)

File lib/strelka/app/newrelic.rb

View file
 		response = nil
 		self.log.debug "[:newrelic] Instrumenting with NewRelic."
 
+		request.notes[:rum_header] = NewRelic::Agent.browser_timing_header
+		request.notes[:rum_footer] = NewRelic::Agent.browser_timing_footer
+
 		txname = if !request.notes[:routing][:route].empty?
 				note = request.notes[:routing][:route]
 				self.log.debug "Making route name out of the route notes: %p" % [ note ]
 			request:  request,
 			category: 'Controller/Strelka',
 		}
-		response = self.perform_action_with_newrelic_trace( options ) do
+		return self.perform_action_with_newrelic_trace( options ) do
 			super
 		end
 
-		self.log.debug "Response is: %p" % [ response ]
-		if response && response.respond_to?( :notes ) && response.notes
-			response.notes[:rum_header] = NewRelic::Agent.browser_timing_header
-			response.notes[:rum_footer] = NewRelic::Agent.browser_timing_footer
-			self.log.debug "  response notes: %p" % [ response.notes ]
-		end
-
-		return response
 	rescue => err
 		NewRelic::Agent.notice_error( err.message )
 		raise

File spec/strelka/app/newrelic_spec.rb

View file
 				response.notes[:rum_footer].should =~ /NREUMQ/
 			end
 
-			it "only tries to add browser timing JS to the response if it's got notes" do
+			it "sets browser timings even with a template response" do
 				request = @request_factory.get( '/template' )
 				response = @app.new.start_newrelic_agent.handle( request )
 				response.status.should == HTTP::OK
+				response.notes[:rum_header].should =~ /NREUMQ/
+				response.notes[:rum_footer].should =~ /NREUMQ/
 			end
 
 		end