Class: XRay::LeadPoller
- Inherits:
-
Object
- Object
- XRay::LeadPoller
- Includes:
- Logging
- Defined in:
- lib/aws-xray-sdk/sampling/lead_poller.rb
Overview
The poller to report the current statistics of all sampling rules and retrieve the new allocated sampling quota and TTL from X-Ray service. It also controls the rule poller.
Constant Summary collapse
- @@interval =
working frequency of the lead poller
10
- @@rule_interval =
5 minutes on polling rules
5 * 60
Instance Attribute Summary collapse
-
#connector ⇒ Object
readonly
Returns the value of attribute connector.
Instance Method Summary collapse
-
#initialize(cache) ⇒ LeadPoller
constructor
A new instance of LeadPoller.
- #start ⇒ Object
- #worker ⇒ Object
Methods included from Logging
Constructor Details
#initialize(cache) ⇒ LeadPoller
Returns a new instance of LeadPoller.
16 17 18 19 20 21 |
# File 'lib/aws-xray-sdk/sampling/lead_poller.rb', line 16 def initialize(cache) @cache = cache @connector = ServiceConnector.new @rule_poller = RulePoller.new cache: @cache, connector: @connector @rule_poller_elapsed = 0 end |
Instance Attribute Details
#connector ⇒ Object (readonly)
Returns the value of attribute connector.
12 13 14 |
# File 'lib/aws-xray-sdk/sampling/lead_poller.rb', line 12 def connector @connector end |
Instance Method Details
#start ⇒ Object
23 24 25 26 |
# File 'lib/aws-xray-sdk/sampling/lead_poller.rb', line 23 def start @rule_poller.run Thread.new { worker } end |
#worker ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/aws-xray-sdk/sampling/lead_poller.rb', line 28 def worker loop do sleep_time = @@interval + rand sleep sleep_time @rule_poller_elapsed += sleep_time refresh_cache if @rule_poller_elapsed >= @@rule_interval @rule_poller.run @rule_poller_elapsed = 0 end end end |