Class: Leafy::Instrumented::BasicInstrumented
- Inherits:
-
Object
- Object
- Leafy::Instrumented::BasicInstrumented
- Defined in:
- lib/leafy/instrumented/basic_instrumented.rb
Direct Known Subclasses
Constant Summary collapse
- NAME_PREFIX =
"responseCodes"
Instance Method Summary collapse
-
#call(&block) ⇒ Object
basically wraps a rack middleware call.
-
#initialize(registry, name, meter_names_by_status_code = {}) ⇒ BasicInstrumented
constructor
creates the metrics.
- #mark_meter_for_status_code(status) ⇒ Object
Constructor Details
#initialize(registry, name, meter_names_by_status_code = {}) ⇒ BasicInstrumented
creates the metrics. all none registered status codes are marked on the meter named ‘other’
13 14 15 16 17 18 19 |
# File 'lib/leafy/instrumented/basic_instrumented.rb', line 13 def initialize( registry, name, meter_names_by_status_code = {} ) @meters_by_status_code = java.util.concurrent.ConcurrentHashMap.new meter_names_by_status_code.each do |k,v| @meters_by_status_code[ k ] = registry.register_meter( "#{name}.#{v}" ) end @other = registry.register_meter( "#{name}.#{NAME_PREFIX}.other" ) end |
Instance Method Details
#call(&block) ⇒ Object
basically wraps a rack middleware call
22 23 24 25 26 27 |
# File 'lib/leafy/instrumented/basic_instrumented.rb', line 22 def call( &block ) raise "block needed" unless block_given? result = block.call mark_meter_for_status_code result[0] result end |
#mark_meter_for_status_code(status) ⇒ Object
29 30 31 32 |
# File 'lib/leafy/instrumented/basic_instrumented.rb', line 29 def mark_meter_for_status_code( status ) metric = @meters_by_status_code[ status ] || @other metric.mark end |