oneapm_rpm 1.3.7 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.gitignore +3 -2
- data/Gemfile +1 -1
- data/lib/one_apm/agent.rb +17 -10
- data/lib/one_apm/agent/agent/connect.rb +9 -3
- data/lib/one_apm/agent/agent/container_data_manager.rb +20 -3
- data/lib/one_apm/agent/agent/cross_app_samples_sender.rb +22 -0
- data/lib/one_apm/agent/agent/rule_fetcher.rb +15 -0
- data/lib/one_apm/agent/agent/start.rb +15 -3
- data/lib/one_apm/agent/agent/start_worker_thread.rb +8 -2
- data/lib/one_apm/agent/cross_app/cross_app_monitor.rb +7 -6
- data/lib/one_apm/agent/cross_app/cross_app_tracing.rb +45 -9
- data/lib/one_apm/agent/cross_app/cross_app_tracing_message.rb +130 -0
- data/lib/one_apm/agent/database/active_record_helper.rb +104 -50
- data/lib/one_apm/agent/datastore.rb +8 -0
- data/lib/one_apm/agent/datastore/metric_helper.rb +37 -6
- data/lib/one_apm/agent/synthetics_monitor.rb +1 -1
- data/lib/one_apm/collector/collector/helper.rb +5 -1
- data/lib/one_apm/collector/collector/http_connection.rb +16 -8
- data/lib/one_apm/collector/collector_service.rb +6 -4
- data/lib/one_apm/collector/containers/transaction_event_aggregator.rb +52 -75
- data/lib/one_apm/collector/containers/transaction_sampler.rb +6 -2
- data/lib/one_apm/configuration.rb +8 -4
- data/lib/one_apm/configuration/default_source.rb +24 -3
- data/lib/one_apm/configuration/server_source.rb +1 -1
- data/lib/one_apm/inst/http_clients/curb.rb +4 -1
- data/lib/one_apm/inst/http_clients/thrift.rb +57 -20
- data/lib/one_apm/inst/nosql/memcache.rb +21 -2
- data/lib/one_apm/inst/nosql/mongo2.rb +11 -8
- data/lib/one_apm/inst/nosql/redis.rb +8 -3
- data/lib/one_apm/inst/orm/active_record.rb +13 -7
- data/lib/one_apm/inst/rails4/active_record_subscriber.rb +16 -13
- data/lib/one_apm/inst/transaction_base.rb +0 -1
- data/lib/one_apm/logger/audit_logger.rb +19 -2
- data/lib/one_apm/manager.rb +1 -0
- data/lib/one_apm/probe/instance_methods.rb +0 -1
- data/lib/one_apm/rack/middleware_tracing.rb +1 -0
- data/lib/one_apm/support/event_buffer/sampled_buffer.rb +4 -0
- data/lib/one_apm/support/helper.rb +16 -0
- data/lib/one_apm/support/http_clients/curb_wrappers.rb +20 -0
- data/lib/one_apm/support/http_clients/excon_wrappers.rb +25 -0
- data/lib/one_apm/support/http_clients/httpclient_wrappers.rb +20 -0
- data/lib/one_apm/support/http_clients/net_http_wrappers.rb +20 -0
- data/lib/one_apm/support/http_clients/thrift_tracer.rb +64 -0
- data/lib/one_apm/support/http_clients/typhoeus_wrappers.rb +21 -1
- data/lib/one_apm/support/http_clients/uri_util.rb +1 -0
- data/lib/one_apm/support/ip.rb +15 -0
- data/lib/one_apm/support/rename_rules_engine.rb +39 -0
- data/lib/one_apm/support/rename_rules_engine/external_rename_rule.rb +84 -0
- data/lib/one_apm/support/rename_rules_engine/match_expression/base.rb +46 -0
- data/lib/one_apm/support/rename_rules_engine/match_expression/engine.rb +35 -0
- data/lib/one_apm/support/rename_rules_engine/match_expression/method.rb +20 -0
- data/lib/one_apm/support/rename_rules_engine/match_expression/split_object.rb +19 -0
- data/lib/one_apm/support/rename_rules_engine/match_expression/url.rb +19 -0
- data/lib/one_apm/support/rename_rules_engine/rename/base.rb +25 -0
- data/lib/one_apm/support/rename_rules_engine/rename/engine.rb +36 -0
- data/lib/one_apm/support/rename_rules_engine/rename/header.rb +17 -0
- data/lib/one_apm/support/rename_rules_engine/rename/parameter.rb +18 -0
- data/lib/one_apm/support/rename_rules_engine/rename/segment.rb +41 -0
- data/lib/one_apm/transaction.rb +11 -2
- data/lib/one_apm/transaction/class_methods.rb +3 -3
- data/lib/one_apm/transaction/event_analytic_data.rb +51 -0
- data/lib/one_apm/transaction/event_analytic_sample.rb +35 -0
- data/lib/one_apm/transaction/instance_helpers.rb +1 -1
- data/lib/one_apm/transaction/sample_buffer/cross_sample_buffer.rb +47 -0
- data/lib/one_apm/transaction/segment.rb +2 -1
- data/lib/one_apm/transaction/transaction_finish_append.rb +4 -0
- data/lib/one_apm/transaction/transaction_name.rb +1 -1
- data/lib/one_apm/transaction/transaction_sample.rb +12 -7
- data/lib/one_apm/version.rb +2 -2
- data/lib/sequel/extensions/oneapm_instrumentation.rb +16 -9
- data/lib/sequel/plugins/oneapm_instrumentation.rb +3 -2
- data/oneapm_rpm.gemspec +2 -1
- metadata +41 -21
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
ZGNhNmQ5MTE0MzRlNDAxMmU4MzhlMjM1MzVlMjNhYTA2YzA4ZDg5MQ==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 29db414eace791ea99e84e88736a5d88fd052479
|
4
|
+
data.tar.gz: 9135f6c1b0ffc0f46cf4a282df144dd5a24b7d16
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
MWU0OTBmMTYyNDI4ZGUyZWM3Njg0YjEyNmU2OTdjNTYxZjZlNTY0YTYxOGJh
|
11
|
-
ZmJiMzEyY2VhOTRlMzY3NDUwOTJkMTk4YmI3ZTI2NzI5YTA0ZDg=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
ZWU1NjhjZDU3YWU4ODRlMzliNGRmOTM3ZTljNTdhNDc1OWE3OWI4MDVkNTZl
|
14
|
-
MzU5MDZjZDY4MTUxNTg0YjhmYTgxY2FmNTU5ZmU2NjE1MmY4NzE1NmJkMzVl
|
15
|
-
NGM3NTMzZDg5M2Q1NWE0Mjk0Y2RkOTIyZWI4OTE0NzhjMjk2Yjc=
|
6
|
+
metadata.gz: 462dd17fc6fb7921d4792533fcf2b551378bf291671febc63257e22478423deb02277458ce401c1d2b37ba880256c19531b00a9c8b7e9751389006105a792628
|
7
|
+
data.tar.gz: 42f6a0d49c6333bd0dc81ae498d89de3c0ddd31bbafa1e22047ad3690fc6ec4523efaeb37e4acf257b82b732f4ca1d106f773b07d477841cc2f87299e0e46bc3
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/lib/one_apm/agent.rb
CHANGED
@@ -11,6 +11,7 @@ require 'one_apm/support/event_buffer/sampled_buffer'
|
|
11
11
|
require 'one_apm/agent/harvester'
|
12
12
|
|
13
13
|
require 'one_apm/support/hostname'
|
14
|
+
require 'one_apm/support/ip'
|
14
15
|
require 'one_apm/support/environment_report'
|
15
16
|
|
16
17
|
require 'one_apm/configuration'
|
@@ -40,6 +41,8 @@ require 'one_apm/agent/agent/container_data_manager'
|
|
40
41
|
require 'one_apm/agent/agent/forkable_dispatcher_functions'
|
41
42
|
require 'one_apm/agent/agent/restart_monitor'
|
42
43
|
require 'one_apm/agent/agent/restart'
|
44
|
+
require 'one_apm/agent/agent/cross_app_samples_sender'
|
45
|
+
require 'one_apm/agent/agent/rule_fetcher'
|
43
46
|
|
44
47
|
module OneApm
|
45
48
|
module Agent
|
@@ -50,6 +53,7 @@ module OneApm
|
|
50
53
|
include OneApm::Agent::Agent::Helpers
|
51
54
|
include OneApm::Agent::Agent::ContainerDataManager
|
52
55
|
include OneApm::Agent::Agent::ForkableDispatcherFunctions
|
56
|
+
include OneApm::Agent::Agent::RuleFetcher
|
53
57
|
|
54
58
|
attr_reader :record_sql
|
55
59
|
attr_reader :javascript_instrumentor
|
@@ -63,6 +67,7 @@ module OneApm
|
|
63
67
|
attr_reader :events
|
64
68
|
|
65
69
|
attr_reader :transaction_rules
|
70
|
+
attr_accessor :external_rename_rules
|
66
71
|
|
67
72
|
attr_reader :harvester
|
68
73
|
attr_reader :harvest_samplers
|
@@ -83,16 +88,18 @@ module OneApm
|
|
83
88
|
|
84
89
|
@events = OneApm::Support::EventListener.new
|
85
90
|
|
86
|
-
init_containers
|
91
|
+
init_containers
|
92
|
+
|
87
93
|
OneApm::Agent::SyntheticsMonitor.new @events
|
88
94
|
OneApm::Agent::RestartMonitor.new
|
89
95
|
|
90
|
-
@cross_app_monitor
|
91
|
-
@transaction_rules
|
92
|
-
@harvest_samplers
|
93
|
-
@monotonic_gc_profiler
|
94
|
-
@javascript_instrumentor
|
95
|
-
@restart
|
96
|
+
@cross_app_monitor = OneApm::Agent::CrossAppMonitor.new(@events)
|
97
|
+
@transaction_rules = OneApm::Support::RulesEngine.new
|
98
|
+
@harvest_samplers = OneApm::Collector::SamplerCollection.new(@events)
|
99
|
+
@monotonic_gc_profiler = OneApm::Support::VM::MonotonicGCProfiler.new
|
100
|
+
@javascript_instrumentor = OneApm::Agent::JavascriptInstrumentor.new(@events)
|
101
|
+
@restart = OneApm::Agent::Restart.new(@events)
|
102
|
+
@cross_app_samples_sender = OneApm::Agent::CrossAppSamplesSender.new(@events, self)
|
96
103
|
|
97
104
|
@harvester = OneApm::Agent::Harvester.new(@events)
|
98
105
|
@after_fork_lock = Mutex.new
|
@@ -140,9 +147,9 @@ module OneApm
|
|
140
147
|
|
141
148
|
def agent_should_start?
|
142
149
|
return false if already_started? || disabled? || defer_for_background_jobs?
|
143
|
-
|
144
|
-
unless app_name_configured?
|
145
|
-
OneApm::Manager.logger.error "No application name configured in #{probe.env} environment"
|
150
|
+
|
151
|
+
unless app_name_configured? && tier_name_configured?
|
152
|
+
OneApm::Manager.logger.error "No application name or tier name configured in #{probe.env} environment"
|
146
153
|
false
|
147
154
|
else
|
148
155
|
true
|
@@ -68,14 +68,16 @@ module OneApm
|
|
68
68
|
{
|
69
69
|
:pid => $$,
|
70
70
|
:host => local_host,
|
71
|
-
:
|
71
|
+
:tier_name => OneApm::Manager.config.tier_names,
|
72
|
+
:app_name => OneApm::Manager.config.app_name,
|
72
73
|
:language => 'ruby',
|
73
74
|
:labels => OneApm::Manager.config.parsed_labels,
|
74
75
|
:agent_version => OneApm::VERSION::STRING,
|
75
76
|
:environment => @environment_report,
|
76
77
|
:settings => OneApm::Manager.config.to_notified_hash,
|
77
78
|
:high_security => OneApm::Manager.config[:high_security],
|
78
|
-
:identifier => "ruby:#{local_host}"
|
79
|
+
:identifier => "ruby:#{local_host}",
|
80
|
+
:clientIP => client_ip
|
79
81
|
}
|
80
82
|
end
|
81
83
|
|
@@ -95,7 +97,6 @@ module OneApm
|
|
95
97
|
return if config_data == nil
|
96
98
|
|
97
99
|
@service.agent_id = config_data['agent_run_id'] if @service
|
98
|
-
|
99
100
|
OneApm::Manager.logger.debug "Server provided config: #{config_data.inspect}"
|
100
101
|
server_config = OneApm::Configuration::ServerSource.new(config_data, OneApm::Manager.config)
|
101
102
|
OneApm::Manager.config.update_config(server_config)
|
@@ -103,12 +104,17 @@ module OneApm
|
|
103
104
|
|
104
105
|
@transaction_rules = OneApm::Support::RulesEngine.create_transaction_rules(config_data)
|
105
106
|
@stats_engine.metric_rules = OneApm::Support::RulesEngine.create_metric_rules(config_data)
|
107
|
+
@external_rename_rules = OneApm::Support::RenameRulesEngine.create_or_update_external_rules(config_data)
|
106
108
|
end
|
107
109
|
|
108
110
|
def local_host
|
109
111
|
@local_host ||= OneApm::Agent::Hostname.get
|
110
112
|
end
|
111
113
|
|
114
|
+
def client_ip
|
115
|
+
@ip ||= OneApm::Agent::IP.get
|
116
|
+
end
|
117
|
+
|
112
118
|
def log_connection!(config_data)
|
113
119
|
OneApm::Manager.logger.debug "Connected to OneApm Service at #{@service.collector.name}"
|
114
120
|
OneApm::Manager.logger.debug "Agent Run = #{@service.agent_id}."
|
@@ -11,6 +11,7 @@ module OneApm
|
|
11
11
|
attr_reader :agent_command_router
|
12
12
|
attr_reader :error_collector
|
13
13
|
attr_reader :custom_event_aggregator
|
14
|
+
attr_reader :transaction_event_aggregator
|
14
15
|
|
15
16
|
def merge_data_for_endpoint(endpoint, data)
|
16
17
|
if data && !data.empty?
|
@@ -31,9 +32,9 @@ module OneApm
|
|
31
32
|
|
32
33
|
private
|
33
34
|
|
34
|
-
def init_containers
|
35
|
+
def init_containers
|
35
36
|
@stats_engine = OneApm::Collector::StatsEngine.new
|
36
|
-
@transaction_sampler = OneApm::Collector::TransactionSampler.new
|
37
|
+
@transaction_sampler = OneApm::Collector::TransactionSampler.new(@events)
|
37
38
|
@sql_sampler = OneApm::Collector::SqlSampler.new
|
38
39
|
@error_collector = OneApm::Collector::ErrorCollector.new
|
39
40
|
@custom_event_aggregator = OneApm::Collector::CustomEventAggregator.new
|
@@ -145,6 +146,10 @@ module OneApm
|
|
145
146
|
@events.notify(:agent_restart) if OneApm::Agent::RestartMonitor.need_restart?
|
146
147
|
end
|
147
148
|
|
149
|
+
def reset_cross_app_sampler_counter
|
150
|
+
transaction_sampler.cross_sample_buffer.reset_counter!
|
151
|
+
end
|
152
|
+
|
148
153
|
def transmit_event_data
|
149
154
|
transmit_single_data_type(:harvest_and_send_analytic_event_data, "TransactionEvent")
|
150
155
|
end
|
@@ -182,6 +187,7 @@ module OneApm
|
|
182
187
|
harvest_and_send_timeslice_data
|
183
188
|
|
184
189
|
check_for_and_handle_agent_commands
|
190
|
+
check_for_match_rules
|
185
191
|
harvest_and_send_for_agent_commands
|
186
192
|
end
|
187
193
|
ensure
|
@@ -202,12 +208,23 @@ module OneApm
|
|
202
208
|
end
|
203
209
|
end
|
204
210
|
|
211
|
+
def check_for_match_rules
|
212
|
+
begin
|
213
|
+
@agent_command_router.check_for_and_handle_agent_commands
|
214
|
+
rescue ForceRestartException, ForceDisconnectException
|
215
|
+
raise
|
216
|
+
rescue ServerConnectionException => e
|
217
|
+
log_remote_unavailable(:get_agent_commands, e)
|
218
|
+
rescue => e
|
219
|
+
OneApm::Manager.logger.info("Error during check_for_and_handle_agent_commands, will retry later: ", e)
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
205
223
|
def log_remote_unavailable(endpoint, e)
|
206
224
|
OneApm::Manager.logger.debug("Unable to send #{endpoint} data, will try again later. Error: ", e)
|
207
225
|
OneApm::Manager.record_metric("Supportability/remote_unavailable", 0.0)
|
208
226
|
OneApm::Manager.record_metric("Supportability/remote_unavailable/#{endpoint.to_s}", 0.0)
|
209
227
|
end
|
210
|
-
|
211
228
|
end
|
212
229
|
end
|
213
230
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module OneApm
|
4
|
+
module Agent
|
5
|
+
class CrossAppSamplesSender
|
6
|
+
|
7
|
+
# this class should be abandoned
|
8
|
+
def initialize(events, agent)
|
9
|
+
# @agent = agent
|
10
|
+
# events.subscribe(:cross_sample_buffer_added, &method(:send_sample))
|
11
|
+
end
|
12
|
+
|
13
|
+
def send_sample(sample)
|
14
|
+
# OneApm::Manager.logger.debug "Send Cross App samples..."
|
15
|
+
# @agent.harvest_lock.synchronize do
|
16
|
+
# @agent.service.transaction_sample_data([sample])
|
17
|
+
# end
|
18
|
+
# OneApm::Manager.logger.debug "Send Cross App samples successful."
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'one_apm/support/rename_rules_engine'
|
3
|
+
module OneApm
|
4
|
+
module Agent
|
5
|
+
class Agent
|
6
|
+
module RuleFetcher
|
7
|
+
|
8
|
+
def update_rule
|
9
|
+
OneApm::Support::RenameRulesEngine.create_or_update_external_rules(@service.fetch_config)
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -75,8 +75,14 @@ module OneApm
|
|
75
75
|
|
76
76
|
# Logs the configured application names
|
77
77
|
def app_name_configured?
|
78
|
-
|
79
|
-
return
|
78
|
+
app_name = OneApm::Manager.config.app_name
|
79
|
+
return app_name.respond_to?(:empty?) && !app_name.empty?
|
80
|
+
end
|
81
|
+
|
82
|
+
# Logs the configured application tier names
|
83
|
+
def tier_name_configured?
|
84
|
+
tier_names = OneApm::Manager.config.tier_names
|
85
|
+
return tier_names.respond_to?(:any?) && tier_names.any?
|
80
86
|
end
|
81
87
|
|
82
88
|
# Connecting in the foreground blocks further startup of the
|
@@ -181,6 +187,7 @@ module OneApm
|
|
181
187
|
log_environment
|
182
188
|
log_dispatcher
|
183
189
|
log_app_name
|
190
|
+
log_tier_name
|
184
191
|
end
|
185
192
|
|
186
193
|
# Classy logging of the agent version and the current pid,
|
@@ -210,9 +217,14 @@ module OneApm
|
|
210
217
|
end
|
211
218
|
|
212
219
|
def log_app_name
|
213
|
-
OneApm::Manager.logger.info "Application: #{Manager.config.
|
220
|
+
OneApm::Manager.logger.info "Application: #{Manager.config.app_name}"
|
214
221
|
end
|
215
222
|
|
223
|
+
def log_tier_name
|
224
|
+
OneApm::Manager.logger.info "Tiername: #{Manager.config.tier_names.join(", ")}"
|
225
|
+
end
|
226
|
+
|
227
|
+
|
216
228
|
def log_ignore_url_regexes
|
217
229
|
regexes = OneApm::Manager.config[:'rules.ignore_url_regexes']
|
218
230
|
|
@@ -41,11 +41,17 @@ module OneApm
|
|
41
41
|
@event_loop.on(:report_event_data) { transmit_event_data }
|
42
42
|
@event_loop.on(:reset_log_once_keys) { OneApm::Manager.logger.clear_already_logged }
|
43
43
|
@event_loop.on(:detect_config) { detect_config }
|
44
|
+
@event_loop.on(:reset_counter) { reset_cross_app_sampler_counter }
|
45
|
+
@event_loop.on(:update_rule) { update_rule }
|
46
|
+
|
44
47
|
|
45
48
|
@event_loop.fire_every(Manager.config[:data_report_period], :report_data)
|
46
|
-
@event_loop.fire_every(report_period_for(:analytic_event_data),
|
47
|
-
@event_loop.fire_every(OA_LOG_ONCE_KEYS_RESET_PERIOD,
|
49
|
+
@event_loop.fire_every(report_period_for(:analytic_event_data), :report_event_data)
|
50
|
+
@event_loop.fire_every(OA_LOG_ONCE_KEYS_RESET_PERIOD, :reset_log_once_keys)
|
48
51
|
@event_loop.fire_every(Manager.config[:data_report_period], :detect_config)
|
52
|
+
@event_loop.fire_every(Manager.config[:data_report_period], :reset_counter)
|
53
|
+
@event_loop.fire_every(Manager.config[:update_rule_period], :update_rule)
|
54
|
+
|
49
55
|
|
50
56
|
if OneApm::Manager.config[:collect_utilization] && !in_resque_child_process?
|
51
57
|
@event_loop.on(:report_utilization_data) { transmit_utilization_data }
|
@@ -10,14 +10,15 @@ module OneApm
|
|
10
10
|
module Agent
|
11
11
|
class CrossAppMonitor < InboundRequestMonitor
|
12
12
|
|
13
|
-
ONEAPM_ID_HEADER = 'X-
|
14
|
-
ONEAPM_TXN_HEADER = 'X-
|
15
|
-
ONEAPM_APPDATA_HEADER = 'X-
|
13
|
+
ONEAPM_ID_HEADER = 'X-BlueWare-ID'
|
14
|
+
ONEAPM_TXN_HEADER = 'X-BlueWare-Transaction'
|
15
|
+
ONEAPM_APPDATA_HEADER = 'X-BlueWare-App-Data'
|
16
16
|
|
17
|
-
ONEAPM_ID_HEADER_KEY = '
|
18
|
-
ONEAPM_TXN_HEADER_KEY = '
|
17
|
+
ONEAPM_ID_HEADER_KEY = 'HTTP_X_BLUEWARE_ID'.freeze
|
18
|
+
ONEAPM_TXN_HEADER_KEY = 'HTTP_X_BLUEWARE_TRANSACTION'.freeze
|
19
19
|
OA_CONTENT_LENGTH_HEADER_KEY = 'HTTP_CONTENT_LENGTH'.freeze
|
20
20
|
|
21
|
+
|
21
22
|
def on_finished_configuring(events)
|
22
23
|
register_event_listeners(events)
|
23
24
|
end
|
@@ -172,7 +173,7 @@ module OneApm
|
|
172
173
|
|
173
174
|
def path_hash(txn_name, seed)
|
174
175
|
rotated = ((seed << 1) | (seed >> 31)) & 0xffffffff
|
175
|
-
app_name = OneApm::Manager.config.
|
176
|
+
app_name = OneApm::Manager.config.app_name
|
176
177
|
identifier = "#{app_name};#{txn_name}"
|
177
178
|
sprintf("%08x", rotated ^ hash_transaction_name(identifier))
|
178
179
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
require 'one_apm/agent/cross_app/cross_app_tracing_message'
|
4
|
+
|
3
5
|
module OneApm
|
4
6
|
module Agent
|
5
7
|
module CrossAppTracing
|
@@ -8,16 +10,16 @@ module OneApm
|
|
8
10
|
class Error < RuntimeError; end
|
9
11
|
|
10
12
|
# The cross app response header for "outgoing" calls
|
11
|
-
OA_APPDATA_HEADER = 'X-
|
13
|
+
OA_APPDATA_HEADER = 'X-BlueWare-App-Data'
|
12
14
|
|
13
15
|
# The cross app id header for "outgoing" calls
|
14
|
-
OA_ID_HEADER = 'X-
|
16
|
+
OA_ID_HEADER = 'X-BlueWare-ID'
|
15
17
|
|
16
18
|
# The cross app transaction header for "outgoing" calls
|
17
|
-
OA_TXN_HEADER = 'X-
|
19
|
+
OA_TXN_HEADER = 'X-BlueWare-Transaction'
|
18
20
|
|
19
21
|
# The cross app synthetics header
|
20
|
-
OA_SYNTHETICS_HEADER = 'X-
|
22
|
+
OA_SYNTHETICS_HEADER = 'X-BlueWare-Synthetics'
|
21
23
|
|
22
24
|
# The index of the transaction GUID in the appdata header of responses
|
23
25
|
OA_APPDATA_TXN_GUID_INDEX = 5
|
@@ -36,6 +38,7 @@ module OneApm
|
|
36
38
|
def tl_trace_http_request(request)
|
37
39
|
state = OneApm::TransactionState.tl_get
|
38
40
|
return yield unless state.is_execution_traced?
|
41
|
+
return yield if request['_SKIP_CAT_']
|
39
42
|
|
40
43
|
# It's important to set t0 outside the ensured block, otherwise there's
|
41
44
|
# a race condition if we raise after begin but before t0's set.
|
@@ -108,7 +111,7 @@ module OneApm
|
|
108
111
|
metrics = metrics_for(request, response)
|
109
112
|
scoped_metric = metrics.pop
|
110
113
|
|
111
|
-
stats_engine.record_scoped_and_unscoped_metrics(state, scoped_metric, metrics, duration, nil, &cross_app_run_time_block(response, duration))
|
114
|
+
#stats_engine.record_scoped_and_unscoped_metrics(state, scoped_metric, metrics, duration, nil, &cross_app_run_time_block(response, duration))
|
112
115
|
|
113
116
|
# If we don't have segment, something failed during start_trace so
|
114
117
|
# the current segment isn't the HTTP call it should have been.
|
@@ -116,6 +119,23 @@ module OneApm
|
|
116
119
|
segment.name = scoped_metric
|
117
120
|
add_transaction_trace_parameters(request, response)
|
118
121
|
end
|
122
|
+
payload = {
|
123
|
+
:name => name(request) ,
|
124
|
+
:scope => state.current_transaction.frozen_name,
|
125
|
+
:apdex_perf_zone => 'S',
|
126
|
+
:guid => OneApm::Helper.generate_guid,
|
127
|
+
:duration => duration,
|
128
|
+
:referring_transaction_guid => state.current_transaction.guid,
|
129
|
+
:call_count => 1,
|
130
|
+
:start_timestamp => t0.to_f,
|
131
|
+
:request_url => request.uri,
|
132
|
+
:bytes_sent => 0,
|
133
|
+
:bytes_rec => 0,
|
134
|
+
:has_trace => 0,
|
135
|
+
:exec_time => duration,
|
136
|
+
:call_type => 0
|
137
|
+
}
|
138
|
+
transaction_event_aggregator.on_cross_app_transaction_finished(payload)
|
119
139
|
end
|
120
140
|
ensure
|
121
141
|
# If we have a segment, always pop the traced method stack to avoid
|
@@ -131,6 +151,10 @@ module OneApm
|
|
131
151
|
OneApm::Manager.logger.error "Uncaught exception while finishing an HTTP request trace", err
|
132
152
|
end
|
133
153
|
|
154
|
+
def name(request)
|
155
|
+
external_rename_rules.rename(request)
|
156
|
+
end
|
157
|
+
|
134
158
|
# Return +true+ if cross app tracing is enabled in the config.
|
135
159
|
def cross_app_enabled?
|
136
160
|
valid_cross_process_id? &&
|
@@ -165,19 +189,19 @@ module OneApm
|
|
165
189
|
def inject_request_headers(state, request)
|
166
190
|
cross_app_id = OneApm::Manager.config[:cross_process_id] or
|
167
191
|
raise OneApm::Agent::CrossAppTracing::Error, "no cross app ID configured"
|
168
|
-
|
169
192
|
state.is_cross_app_caller = true
|
170
193
|
txn_guid = state.request_guid
|
171
194
|
txn = state.current_transaction
|
172
195
|
if txn
|
173
196
|
trip_id = txn.cat_trip_id(state)
|
174
197
|
path_hash = txn.cat_path_hash(state)
|
198
|
+
request_host = request.host if request && request.respond_to?(:host)
|
175
199
|
|
176
200
|
if txn.raw_synthetics_header
|
177
201
|
request[OA_SYNTHETICS_HEADER] = txn.raw_synthetics_header
|
178
202
|
end
|
179
203
|
end
|
180
|
-
txn_data = OneApm::JSONWrapper.dump([txn_guid,
|
204
|
+
txn_data = OneApm::JSONWrapper.dump([txn_guid, true, trip_id, path_hash, request_host])
|
181
205
|
|
182
206
|
request[OA_ID_HEADER] = obfuscator.obfuscate(cross_app_id)
|
183
207
|
request[OA_TXN_HEADER] = obfuscator.obfuscate(txn_data)
|
@@ -194,7 +218,6 @@ module OneApm
|
|
194
218
|
end
|
195
219
|
end
|
196
220
|
|
197
|
-
|
198
221
|
# Extract any custom parameters from +response+ if it's cross-application and
|
199
222
|
# add them to the current TT node.
|
200
223
|
def add_cat_transaction_trace_parameters( response )
|
@@ -260,7 +283,6 @@ module OneApm
|
|
260
283
|
# +response+.
|
261
284
|
def metrics_for_crossapp_response( request, response )
|
262
285
|
xp_id, txn_name, _q_time, _r_time, _req_len, _ = extract_appdata( response )
|
263
|
-
|
264
286
|
check_crossapp_id( xp_id )
|
265
287
|
check_transaction_name( txn_name )
|
266
288
|
|
@@ -315,6 +337,14 @@ module OneApm
|
|
315
337
|
OneApm::Manager.agent.transaction_sampler
|
316
338
|
end
|
317
339
|
|
340
|
+
def transaction_event_aggregator
|
341
|
+
OneApm::Manager.agent.transaction_event_aggregator
|
342
|
+
end
|
343
|
+
|
344
|
+
def external_rename_rules
|
345
|
+
OneApm::Manager.agent.external_rename_rules
|
346
|
+
end
|
347
|
+
|
318
348
|
# Check the given +id+ to ensure it conforms to the format of a cross-application
|
319
349
|
# ID. Raises an OneApm::Agent::CrossAppTracing::Error if it doesn't.
|
320
350
|
def check_crossapp_id( id )
|
@@ -323,6 +353,12 @@ module OneApm
|
|
323
353
|
"malformed cross application ID %p" % [ id ]
|
324
354
|
end
|
325
355
|
|
356
|
+
def check_cross_tier_id( id )
|
357
|
+
id =~ /\A\d+#\d+#\d+\z/ or
|
358
|
+
raise OneApm::Agent::CrossAppTracing::Error,
|
359
|
+
"malformed cross application ID %p" % [ id ]
|
360
|
+
end
|
361
|
+
|
326
362
|
|
327
363
|
# Check the given +name+ to ensure it conforms to the format of a valid transaction
|
328
364
|
# name.
|