Class: Instana::Backend::HostAgentReportingObserver
- Inherits:
-
Object
- Object
- Instana::Backend::HostAgentReportingObserver
- Defined in:
- lib/instana/backend/host_agent_reporting_observer.rb
Overview
Process which is responsible for reporting metrics and tracing to the local agent
Constant Summary collapse
- ENTITY_DATA_URL =
'/com.instana.plugin.ruby.%i'.freeze
- RESPONSE_DATA_URL =
'/com.instana.plugin.ruby/response.%i?messageId=%s'.freeze
- TRACES_DATA_URL =
"/com.instana.plugin.ruby/traces.%i".freeze
- TRACE_METRICS_URL =
"/tracermetrics".freeze
Instance Attribute Summary collapse
- #metrics_timer ⇒ Object readonly
- #traces_timer ⇒ Object readonly
Instance Method Summary collapse
-
#initialize(client, discovery, logger: ::Instana.logger, timer_class: Concurrent::TimerTask, processor: ::Instana.processor) ⇒ HostAgentReportingObserver
constructor
A new instance of HostAgentReportingObserver.
- #update(time, _old_version, new_version) ⇒ Object
Constructor Details
#initialize(client, discovery, logger: ::Instana.logger, timer_class: Concurrent::TimerTask, processor: ::Instana.processor) ⇒ HostAgentReportingObserver
Returns a new instance of HostAgentReportingObserver.
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/instana/backend/host_agent_reporting_observer.rb', line 18 def initialize(client, discovery, logger: ::Instana.logger, timer_class: Concurrent::TimerTask, processor: ::Instana.processor) @client = client @discovery = discovery @logger = logger @timer_class = timer_class @nonce = Time.now @processor = processor # Initialize timers with default 1 second interval @metrics_timer = @timer_class.new(execution_interval: 1, run_now: true) { report_metrics_to_backend } @traces_timer = @timer_class.new(execution_interval: 1, run_now: true) { report_traces_to_backend } end |
Instance Attribute Details
#metrics_timer ⇒ Object (readonly)
14 15 16 |
# File 'lib/instana/backend/host_agent_reporting_observer.rb', line 14 def metrics_timer @metrics_timer end |
#traces_timer ⇒ Object (readonly)
14 15 16 |
# File 'lib/instana/backend/host_agent_reporting_observer.rb', line 14 def traces_timer @traces_timer end |
Instance Method Details
#update(time, _old_version, new_version) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/instana/backend/host_agent_reporting_observer.rb', line 31 def update(time, _old_version, new_version) return unless time > @nonce @nonce = time if new_version.nil? @metrics_timer&.shutdown @traces_timer&.shutdown else # Read poll_rate from discovery payload - it's nested under plugin.ruby.poll_rate discovery = @discovery.value poll_rate = discovery&.dig('plugin', 'ruby', 'poll_rate') || 1 # Only recreate metrics_timer if poll_rate is different from current interval if @metrics_timer.nil? || @metrics_timer.execution_interval != poll_rate @metrics_timer&.shutdown @metrics_timer = @timer_class.new(execution_interval: poll_rate, run_now: true) { report_metrics_to_backend } end @metrics_timer.execute # Traces timer always uses 1 second interval @traces_timer&.shutdown @traces_timer = @timer_class.new(execution_interval: 1, run_now: true) { report_traces_to_backend } @traces_timer.execute end end |