Class: NewRelic::Agent::SyntheticsMonitor
Constant Summary
collapse
'HTTP_X_NEWRELIC_SYNTHETICS'
'HTTP_X_NEWRELIC_SYNTHETICS_INFO'
- SUPPORTED_VERSION =
1
- EXPECTED_PAYLOAD_LENGTH =
5
Instance Attribute Summary
#obfuscator
Class Method Summary
collapse
Instance Method Summary
collapse
#deserialize_header, #initialize, #setup_obfuscator
Class Method Details
.is_supported_version?(incoming_payload) ⇒ Boolean
45
46
47
|
# File 'lib/new_relic/agent/monitors/synthetics_monitor.rb', line 45
def is_supported_version?(incoming_payload)
incoming_payload.first == SUPPORTED_VERSION
end
|
.is_trusted?(incoming_payload) ⇒ Boolean
49
50
51
52
|
# File 'lib/new_relic/agent/monitors/synthetics_monitor.rb', line 49
def is_trusted?(incoming_payload)
account_id = incoming_payload[1]
Agent.config[:trusted_account_ids].include?(account_id)
end
|
.is_valid_payload?(incoming_payload) ⇒ Boolean
54
55
56
|
# File 'lib/new_relic/agent/monitors/synthetics_monitor.rb', line 54
def is_valid_payload?(incoming_payload)
incoming_payload.length == EXPECTED_PAYLOAD_LENGTH
end
|
58
59
60
|
# File 'lib/new_relic/agent/monitors/synthetics_monitor.rb', line 58
def ()
.reject { |k, _| k == CrossAppTracing:: }
end
|
Instance Method Details
#load_json(header, key) ⇒ Object
37
38
39
40
41
42
|
# File 'lib/new_relic/agent/monitors/synthetics_monitor.rb', line 37
def load_json(, key)
::JSON.load()
rescue => err
NewRelic::Agent.logger.debug("Failure loading json header '#{key}' in #{self.class}, #{err.class}, #{err.message}")
nil
end
|
#on_before_call(request) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/new_relic/agent/monitors/synthetics_monitor.rb', line 18
def on_before_call(request)
= request[]
= request[]
return unless
incoming_payload = (, )
return unless incoming_payload &&
SyntheticsMonitor.is_valid_payload?(incoming_payload) &&
SyntheticsMonitor.is_supported_version?(incoming_payload) &&
SyntheticsMonitor.is_trusted?(incoming_payload)
txn = Tracer.current_transaction
txn. =
txn. =
txn.synthetics_payload = incoming_payload
txn.synthetics_info_payload = load_json(, )
end
|
#on_finished_configuring(events) ⇒ Object
14
15
16
|
# File 'lib/new_relic/agent/monitors/synthetics_monitor.rb', line 14
def on_finished_configuring(events)
events.subscribe(:before_call, &method(:on_before_call))
end
|