class Mmtrix::Agent::SyntheticsMonitor

Constants

EXPECTED_PAYLOAD_LENGTH
SUPPORTED_VERSION
SYNTHETICS_HEADER_KEY

Public Instance Methods

is_supported_version?(incoming_payload) click to toggle source
# File lib/mmtrix/agent/synthetics_monitor.rb, line 36
def is_supported_version?(incoming_payload)
  incoming_payload.first == SUPPORTED_VERSION
end
is_trusted?(incoming_payload) click to toggle source
# File lib/mmtrix/agent/synthetics_monitor.rb, line 40
def is_trusted?(incoming_payload)
  account_id = incoming_payload[1]
  Mmtrix::Agent.config[:trusted_account_ids].include?(account_id)
end
is_valid_payload?(incoming_payload) click to toggle source
# File lib/mmtrix/agent/synthetics_monitor.rb, line 45
def is_valid_payload?(incoming_payload)
  incoming_payload.length == EXPECTED_PAYLOAD_LENGTH
end
on_before_call(request) click to toggle source
# File lib/mmtrix/agent/synthetics_monitor.rb, line 19
def on_before_call(request) #THREAD_LOCAL_ACCESS
  encoded_header = request[SYNTHETICS_HEADER_KEY]
  return unless encoded_header

  incoming_payload = deserialize_header(encoded_header, SYNTHETICS_HEADER_KEY)

  return unless incoming_payload &&
      is_valid_payload?(incoming_payload) &&
      is_supported_version?(incoming_payload) &&
      is_trusted?(incoming_payload)

  state = Mmtrix::Agent::TransactionState.tl_get
  txn = state.current_transaction
  txn.raw_synthetics_header = encoded_header
  txn.synthetics_payload    = incoming_payload
end
on_finished_configuring(events) click to toggle source
# File lib/mmtrix/agent/synthetics_monitor.rb, line 15
def on_finished_configuring(events)
  events.subscribe(:before_call, &method(:on_before_call))
end