Class: NewRelic::Agent::Instrumentation::ControllerInstrumentation::TransactionNamer
- Inherits:
-
Object
- Object
- NewRelic::Agent::Instrumentation::ControllerInstrumentation::TransactionNamer
- Defined in:
- lib/new_relic/agent/instrumentation/controller_instrumentation.rb
Instance Method Summary collapse
- #category_name(type = nil) ⇒ Object
-
#initialize(traced_obj) ⇒ TransactionNamer
constructor
A new instance of TransactionNamer.
- #name(options = {}) ⇒ Object
- #path_name(options = {}) ⇒ Object
Constructor Details
#initialize(traced_obj) ⇒ TransactionNamer
Returns a new instance of TransactionNamer.
177 178 179 180 181 182 183 184 |
# File 'lib/new_relic/agent/instrumentation/controller_instrumentation.rb', line 177 def initialize(traced_obj) @traced_obj = traced_obj if (@traced_obj.is_a?(Class) || @traced_obj.is_a?(Module)) @traced_class_name = @traced_obj.name else @traced_class_name = @traced_obj.class.name end end |
Instance Method Details
#category_name(type = nil) ⇒ Object
190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/new_relic/agent/instrumentation/controller_instrumentation.rb', line 190 def category_name(type = nil) type ||= Transaction.current && Transaction.current.type case type when :controller, nil then 'Controller' when :task then 'OtherTransaction/Background' when :rack then 'Controller/Rack' when :uri then 'Controller' when :sinatra then 'Controller/Sinatra' # for internal use only else type.to_s end end |
#name(options = {}) ⇒ Object
186 187 188 |
# File 'lib/new_relic/agent/instrumentation/controller_instrumentation.rb', line 186 def name(={}) name = "#{category_name([:category])}/#{path_name()}" end |
#path_name(options = {}) ⇒ Object
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
# File 'lib/new_relic/agent/instrumentation/controller_instrumentation.rb', line 203 def path_name(={}) # if we have the path, use the path path = [:path] class_name = [:class_name] || @traced_class_name # if we have an explicit action name option, use that if [:name] path ||= [ class_name, [:name] ].compact.join('/') end # if newrelic_metric_path() is defined, use that if @traced_obj.respond_to?(:newrelic_metric_path) path ||= @traced_obj.newrelic_metric_path end # fall back on just the traced class name path ||= class_name return path end |