Class: Sbmt::Strangler::MetricTracker

Inherits:
Object
  • Object
show all
Defined in:
lib/sbmt/strangler/metric_tracker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rails_controller) ⇒ MetricTracker

Returns a new instance of MetricTracker.



8
9
10
# File 'lib/sbmt/strangler/metric_tracker.rb', line 8

def initialize(rails_controller)
  @rails_controller = rails_controller
end

Instance Attribute Details

#rails_controllerObject (readonly)

Returns the value of attribute rails_controller.



6
7
8
# File 'lib/sbmt/strangler/metric_tracker.rb', line 6

def rails_controller
  @rails_controller
end

Instance Method Details

#log_unallowed_paramsObject



16
17
18
19
20
21
# File 'lib/sbmt/strangler/metric_tracker.rb', line 16

def log_unallowed_params
  unallowed_params = all_request_params - allowed_request_params
  Sbmt::Strangler.logger.log_warn(<<~WARN.strip) if unallowed_params.any?
    Not allowed parameters in #{controller_path}##{action_name}: #{unallowed_params}
  WARN
end

#track_compare_call(success) ⇒ Object



33
34
35
36
# File 'lib/sbmt/strangler/metric_tracker.rb', line 33

def track_compare_call(success)
  yabeda_tags = common_tags.merge(success: success.to_s)
  ::Yabeda.sbmt_strangler.compare_call.increment(yabeda_tags)
end

#track_compare_call_result(value) ⇒ Object



38
39
40
41
# File 'lib/sbmt/strangler/metric_tracker.rb', line 38

def track_compare_call_result(value)
  yabeda_tags = common_tags.merge(value: value.to_s)
  ::Yabeda.sbmt_strangler.compare_call_result.increment(yabeda_tags)
end

#track_mirror_call(success) ⇒ Object



28
29
30
31
# File 'lib/sbmt/strangler/metric_tracker.rb', line 28

def track_mirror_call(success)
  yabeda_tags = common_tags.merge(success: success.to_s)
  ::Yabeda.sbmt_strangler.mirror_call.increment(yabeda_tags)
end

#track_params_usageObject



12
13
14
# File 'lib/sbmt/strangler/metric_tracker.rb', line 12

def track_params_usage
  ::Yabeda.sbmt_strangler.params_usage.increment(common_tags)
end

#track_render_call(success) ⇒ Object



43
44
45
46
# File 'lib/sbmt/strangler/metric_tracker.rb', line 43

def track_render_call(success)
  yabeda_tags = common_tags.merge(success: success.to_s)
  ::Yabeda.sbmt_strangler.render_call.increment(yabeda_tags)
end

#track_work_mode(mode) ⇒ Object



23
24
25
26
# File 'lib/sbmt/strangler/metric_tracker.rb', line 23

def track_work_mode(mode)
  yabeda_tags = common_tags.merge(mode: mode.to_s)
  ::Yabeda.sbmt_strangler.work_mode.increment(yabeda_tags)
end