Sha256: f46a4813b5d8c8d8a515d131e2131910edee097a08dab0f5ec843c02697c4149
Contents?: true
Size: 1.4 KB
Versions: 3
Compression:
Stored size: 1.4 KB
Contents
# encoding: utf-8 require 'one_apm/agent/inbound_request_monitor' module OneApm module Agent class SyntheticsMonitor < InboundRequestMonitor SYNTHETICS_HEADER_KEY = 'HTTP_X_ONEAPM_SYNTHETICS'.freeze SUPPORTED_VERSION = 1 EXPECTED_PAYLOAD_LENGTH = 5 def on_finished_configuring(events) events.subscribe(:before_call, &method(:on_before_call)) end 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 = OneApm::TransactionState.tl_get txn = state.current_transaction txn.raw_synthetics_header = encoded_header txn.synthetics_payload = incoming_payload end def is_supported_version?(incoming_payload) incoming_payload.first == SUPPORTED_VERSION end def is_trusted?(incoming_payload) account_id = incoming_payload[1] OneApm::Agent.config[:trusted_account_ids].include?(account_id) end def is_valid_payload?(incoming_payload) incoming_payload.length == EXPECTED_PAYLOAD_LENGTH end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
oneapm_rpm-1.1.2 | lib/one_apm/agent/synthetics_monitor.rb |
oneapm_rpm-1.1.1 | lib/one_apm/agent/synthetics_monitor.rb |
oneapm_rpm-1.1.0 | lib/one_apm/agent/synthetics_monitor.rb |