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
@@ -19,7 +19,7 @@ module OneApm
|
|
19
19
|
OA_PROTOCOL_VERSION = 1
|
20
20
|
|
21
21
|
attr_accessor :request_timeout, :agent_id
|
22
|
-
attr_reader :collector
|
22
|
+
attr_reader :collector, :marshaller, :metric_id_cache
|
23
23
|
|
24
24
|
def initialize(license_key = nil, collector = nil)
|
25
25
|
@license_key = license_key || OneApm::Manager.config[:license_key]
|
@@ -67,13 +67,11 @@ module OneApm
|
|
67
67
|
timeslice_end = stats_hash.harvested_at || Time.now
|
68
68
|
|
69
69
|
metric_data_array = build_metric_data_array(stats_hash)
|
70
|
-
|
71
70
|
result = invoke_remote(
|
72
71
|
:metric_data,
|
73
72
|
[@agent_id, timeslice_start.to_f, timeslice_end.to_f, metric_data_array],
|
74
73
|
:item_count => metric_data_array.size
|
75
74
|
)
|
76
|
-
|
77
75
|
fill_metric_id_cache(result)
|
78
76
|
result
|
79
77
|
end
|
@@ -107,7 +105,7 @@ module OneApm
|
|
107
105
|
end
|
108
106
|
|
109
107
|
def analytic_event_data(data)
|
110
|
-
invoke_remote(:analytic_event_data,
|
108
|
+
invoke_remote(:analytic_event_data, data, :item_count => data.size)
|
111
109
|
end
|
112
110
|
|
113
111
|
def custom_event_data(data)
|
@@ -118,6 +116,10 @@ module OneApm
|
|
118
116
|
invoke_remote(:utilization_data, data)
|
119
117
|
end
|
120
118
|
|
119
|
+
def fetch_config
|
120
|
+
invoke_remote(:get_external_rule,[],{},:hash_value=>0)
|
121
|
+
end
|
122
|
+
|
121
123
|
end
|
122
124
|
end
|
123
125
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require 'monitor'
|
4
|
+
require 'one_apm/transaction/event_analytic_sample'
|
5
|
+
require 'one_apm/transaction/event_analytic_data'
|
4
6
|
|
5
7
|
class OneApm::Collector::TransactionEventAggregator
|
6
8
|
include OneApm::Coerce, MonitorMixin
|
@@ -69,6 +71,7 @@ class OneApm::Collector::TransactionEventAggregator
|
|
69
71
|
old_samples, sample_count, request_count, synthetics_dropped = reset!
|
70
72
|
record_sampling_rate(request_count, sample_count) if @enabled
|
71
73
|
record_dropped_synthetics(synthetics_dropped)
|
74
|
+
# return old_samples.map(&:to_collector_array) if old_samples.respond_to?(:to_collector_array)
|
72
75
|
old_samples
|
73
76
|
end
|
74
77
|
|
@@ -76,7 +79,13 @@ class OneApm::Collector::TransactionEventAggregator
|
|
76
79
|
# transmission to the collector. (Synchronized)
|
77
80
|
def merge!(old_samples)
|
78
81
|
self.synchronize do
|
79
|
-
old_samples.each
|
82
|
+
old_samples.each do |s|
|
83
|
+
if s.respond_to?(:spec_name)
|
84
|
+
append_event(s)
|
85
|
+
else
|
86
|
+
@samples.append_event(s)
|
87
|
+
end
|
88
|
+
end
|
80
89
|
end
|
81
90
|
end
|
82
91
|
|
@@ -130,94 +139,62 @@ class OneApm::Collector::TransactionEventAggregator
|
|
130
139
|
# Event handler for the :transaction_finished event.
|
131
140
|
def on_transaction_finished(payload)
|
132
141
|
return unless @enabled
|
133
|
-
|
134
142
|
main_event = create_main_event(payload)
|
135
143
|
custom_params = create_custom_parameters(payload)
|
136
|
-
|
137
|
-
self.synchronize
|
144
|
+
sub_events = create_sub_events(main_event, payload)
|
145
|
+
self.synchronize do
|
146
|
+
[main_event].concat(sub_events).each do |event|
|
147
|
+
append_event(event)
|
148
|
+
end
|
149
|
+
end
|
138
150
|
notify_full if !@notified_full && @samples.full?
|
139
151
|
end
|
140
152
|
|
141
|
-
def append_event(event)
|
142
|
-
main_event, _ = event
|
143
|
-
|
144
|
-
if main_event.include?(OA_SYNTHETICS_RESOURCE_ID_KEY)
|
145
|
-
# Try adding to synthetics buffer. If anything is rejected, give it a
|
146
|
-
# shot in the main transaction events (where it may get sampled)
|
147
|
-
result, rejected = @synthetics_samples.append_with_reject(event)
|
148
153
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
+
# Event handler for the :transaction_finished event.
|
155
|
+
def on_cross_app_transaction_finished(payload)
|
156
|
+
return unless @enabled
|
157
|
+
main_event = create_main_event(payload)
|
158
|
+
self.synchronize do
|
159
|
+
append_event(main_event)
|
154
160
|
end
|
161
|
+
notify_full if !@notified_full && @samples.full?
|
155
162
|
end
|
156
163
|
|
157
|
-
def
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
mappings.merge!(to_add)
|
162
|
-
|
163
|
-
OA_OVERVIEW_SPECS[metric_name] = mappings
|
164
|
+
def append_event(event)
|
165
|
+
same_spec_for_sample = @samples.select{|sample| sample.spec_name == event.spec_name}.first
|
166
|
+
return @samples.append(event) if same_spec_for_sample.nil?
|
167
|
+
same_spec_for_sample.event_analytic_data.concat event.event_analytic_data
|
164
168
|
end
|
165
169
|
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
def append_metrics(txn_metrics, sample)
|
189
|
-
if txn_metrics
|
190
|
-
OA_OVERVIEW_SPECS.each do |(name, extracted_values)|
|
191
|
-
if txn_metrics.has_key?(name)
|
192
|
-
stat = txn_metrics[name]
|
193
|
-
extracted_values.each do |value_name, key_name|
|
194
|
-
sample[key_name] = stat.send(value_name)
|
195
|
-
end
|
196
|
-
end
|
197
|
-
end
|
170
|
+
# see http://wiki.oneapm.me/display/SAAS/Ai-+Entrance
|
171
|
+
def create_main_event(payload)
|
172
|
+
OneApm::EventAnalyticSample.new(payload)
|
173
|
+
end
|
174
|
+
|
175
|
+
def create_sub_events main_event, payload
|
176
|
+
payload = payload.dup
|
177
|
+
payload[:scope] = payload[:name]
|
178
|
+
payload[:referring_transaction_guid] = main_event.guid
|
179
|
+
payload[:request_url] = ''
|
180
|
+
|
181
|
+
sub_event_samples = []
|
182
|
+
return sub_event_samples unless payload[:metrics]
|
183
|
+
payload[:metrics].each_scoped do |metric_name, status|
|
184
|
+
next if metric_name =~ /^Nested|View|External/
|
185
|
+
payload[:name] = metric_name
|
186
|
+
payload[:guid] = OneApm::Helper.generate_guid
|
187
|
+
payload[:call_count] = status.call_count
|
188
|
+
payload[:duration] = status.total_call_time
|
189
|
+
sample = OneApm::EventAnalyticSample.new(payload)
|
190
|
+
sub_event_samples << sample
|
198
191
|
end
|
192
|
+
sub_event_samples
|
199
193
|
end
|
200
194
|
|
201
|
-
def
|
202
|
-
|
203
|
-
|
204
|
-
OA_NAME_KEY => string(payload[:name]),
|
205
|
-
OA_DURATION_KEY => float(payload[:duration]),
|
206
|
-
OA_TYPE_KEY => OA_SAMPLE_TYPE,
|
207
|
-
}
|
208
|
-
append_metrics(payload[:metrics], sample)
|
209
|
-
optionally_append(OA_GUID_KEY, :guid, sample, payload)
|
210
|
-
optionally_append(OA_REFERRING_TRANSACTION_GUID_KEY, :referring_transaction_guid, sample, payload)
|
211
|
-
optionally_append(OA_CAT_TRIP_ID_KEY, :cat_trip_id, sample, payload)
|
212
|
-
optionally_append(OA_CAT_PATH_HASH_KEY, :cat_path_hash, sample, payload)
|
213
|
-
optionally_append(OA_CAT_REFERRING_PATH_HASH_KEY, :cat_referring_path_hash, sample, payload)
|
214
|
-
optionally_append(OA_APDEX_PERF_ZONE_KEY, :apdex_perf_zone, sample, payload)
|
215
|
-
optionally_append(OA_SYNTHETICS_RESOURCE_ID_KEY, :synthetics_resource_id, sample, payload)
|
216
|
-
optionally_append(OA_SYNTHETICS_JOB_ID_KEY, :synthetics_job_id, sample, payload)
|
217
|
-
optionally_append(OA_SYNTHETICS_MONITOR_ID_KEY, :synthetics_monitor_id, sample, payload)
|
218
|
-
append_http_response_code(sample, payload)
|
219
|
-
append_cat_alternate_path_hashes(sample, payload)
|
220
|
-
sample
|
195
|
+
def error_times(txn_metrics)
|
196
|
+
return txn_metrics[OA_ERROR_ALL_KEY].call_count if txn_metrics.has_key?(OA_ERROR_ALL_KEY) rescue 0
|
197
|
+
return 0
|
221
198
|
end
|
222
199
|
|
223
200
|
def append_http_response_code(sample, payload)
|
@@ -6,6 +6,7 @@ require 'one_apm/transaction/sample_buffer/slowest_sample_buffer'
|
|
6
6
|
require 'one_apm/transaction/sample_buffer/synthetics_sample_buffer'
|
7
7
|
require 'one_apm/transaction/sample_buffer/xray_sample_buffer'
|
8
8
|
require 'one_apm/transaction/sample_buffer/developer_mode_sample_buffer'
|
9
|
+
require 'one_apm/transaction/sample_buffer/cross_sample_buffer'
|
9
10
|
|
10
11
|
module OneApm
|
11
12
|
module Collector
|
@@ -28,13 +29,15 @@ module OneApm
|
|
28
29
|
def on_finishing_transaction(*args); end
|
29
30
|
end
|
30
31
|
|
31
|
-
attr_reader :last_sample, :xray_sample_buffer, :dev_mode_sample_buffer
|
32
|
+
attr_reader :last_sample, :xray_sample_buffer, :dev_mode_sample_buffer, :cross_sample_buffer
|
32
33
|
|
33
|
-
def initialize
|
34
|
+
def initialize(events = OneApm::Manager.agent.events)
|
34
35
|
@xray_sample_buffer = OneApm::Transaction::XraySampleBuffer.new
|
35
36
|
@dev_mode_sample_buffer = OneApm::Transaction::DeveloperModeSampleBuffer.new
|
37
|
+
@cross_sample_buffer = OneApm::Transaction::CrossSampleBuffer.new(events)
|
36
38
|
|
37
39
|
@sample_buffers = []
|
40
|
+
@sample_buffers << @cross_sample_buffer
|
38
41
|
@sample_buffers << @xray_sample_buffer
|
39
42
|
@sample_buffers << @dev_mode_sample_buffer
|
40
43
|
@sample_buffers << OneApm::Transaction::SlowestSampleBuffer.new
|
@@ -127,6 +130,7 @@ module OneApm
|
|
127
130
|
last_sample = last_builder.sample
|
128
131
|
last_sample.guid = txn.guid
|
129
132
|
last_sample.set_custom_param(:gc_time, gc_time) if gc_time
|
133
|
+
last_sample.force_persist = txn.apdex_bucket(time - txn.apdex_start) != :apdex_s
|
130
134
|
|
131
135
|
if state.is_cross_app?
|
132
136
|
last_sample.set_custom_param(:'bw.trip_id', txn.cat_trip_id(state))
|
@@ -266,10 +266,14 @@ module OneApm
|
|
266
266
|
end
|
267
267
|
end
|
268
268
|
|
269
|
-
def
|
270
|
-
|
271
|
-
|
272
|
-
|
269
|
+
def app_name
|
270
|
+
OneApm::Manager.config[:app_name]
|
271
|
+
end
|
272
|
+
|
273
|
+
def tier_names
|
274
|
+
case OneApm::Manager.config[:tier_name]
|
275
|
+
when Array then OneApm::Manager.config[:tier_name]
|
276
|
+
when String then OneApm::Manager.config[:tier_name].split(';')
|
273
277
|
else []
|
274
278
|
end
|
275
279
|
end
|
@@ -235,7 +235,7 @@ module OneApm
|
|
235
235
|
:public => true,
|
236
236
|
:type => String,
|
237
237
|
:notified => true,
|
238
|
-
:description => '
|
238
|
+
:description => 'Naming your application.'
|
239
239
|
},
|
240
240
|
:monitor_mode => {
|
241
241
|
:default => value_of(:enabled),
|
@@ -379,7 +379,7 @@ module OneApm
|
|
379
379
|
:description => 'Defines a comma-delimited list of exceptions from which the agent will not strip messages when strip_exception_messages is enabled (such as \'ImportantException, PreserveMessageException\').'
|
380
380
|
},
|
381
381
|
:host => {
|
382
|
-
:default => '
|
382
|
+
:default => 'app.collector.oneapm.com',
|
383
383
|
:public => false,
|
384
384
|
:type => String,
|
385
385
|
:notified => false,
|
@@ -463,6 +463,13 @@ module OneApm
|
|
463
463
|
:notified => false,
|
464
464
|
:description => 'Number of seconds between connections to the OneApm data collection service for sending transaction event data.'
|
465
465
|
},
|
466
|
+
:update_rule_period => {
|
467
|
+
:default => 60,
|
468
|
+
:public => false,
|
469
|
+
:type => Fixnum,
|
470
|
+
:notified => false,
|
471
|
+
:description => 'Number of seconds fetch btm config from the OneApm service.'
|
472
|
+
},
|
466
473
|
:keep_retrying => {
|
467
474
|
:default => true,
|
468
475
|
:public => false,
|
@@ -758,7 +765,7 @@ module OneApm
|
|
758
765
|
:default => true,
|
759
766
|
:public => true,
|
760
767
|
:type => Boolean,
|
761
|
-
:notified =>
|
768
|
+
:notified => true,
|
762
769
|
:description => 'Enable or disable recording of traced errors and error count metrics.'
|
763
770
|
},
|
764
771
|
:'error_collector.capture_attributes' => {
|
@@ -1224,6 +1231,20 @@ module OneApm
|
|
1224
1231
|
:type => Boolean,
|
1225
1232
|
:notified => false,
|
1226
1233
|
:description => 'Enable or Disable custom notified angent config data to OneAPM server.'
|
1234
|
+
},
|
1235
|
+
:tier_name => {
|
1236
|
+
:default => 'Tier Name',
|
1237
|
+
:public => true,
|
1238
|
+
:type => String,
|
1239
|
+
:notified => true,
|
1240
|
+
:description => 'Semicolon-delimited list of Tier Names.'
|
1241
|
+
},
|
1242
|
+
:cross_sampler_count => {
|
1243
|
+
:default => 5,
|
1244
|
+
:public => true,
|
1245
|
+
:type => Fixnum,
|
1246
|
+
:notified => true,
|
1247
|
+
:description => 'Cross Application traces limit per minute.'
|
1227
1248
|
}
|
1228
1249
|
}.freeze
|
1229
1250
|
end
|
@@ -15,7 +15,7 @@ module OneApm
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
if hash['browser_monitoring'] && hash['browser_monitoring']
|
18
|
+
if !hash['browser_monitoring'].nil? && hash['browser_monitoring'].has_key?('transform')
|
19
19
|
hash['browser_monitoring']['auto_instrument'] = hash['browser_monitoring']['transform']
|
20
20
|
end
|
21
21
|
|
@@ -24,7 +24,8 @@ LibraryDetection.defer do
|
|
24
24
|
:_oa_header_str,
|
25
25
|
:_oa_original_on_header,
|
26
26
|
:_oa_original_on_complete,
|
27
|
-
:_oa_serial
|
27
|
+
:_oa_serial,
|
28
|
+
:_oa_http_params
|
28
29
|
|
29
30
|
# We have to hook these three methods separately, as they don't use
|
30
31
|
# Curl::Easy#http
|
@@ -37,6 +38,7 @@ LibraryDetection.defer do
|
|
37
38
|
|
38
39
|
def http_post_with_oneapm(*args, &blk)
|
39
40
|
self._oa_http_verb = :POST
|
41
|
+
self._oa_http_params = args.first
|
40
42
|
http_post_without_oneapm(*args, &blk)
|
41
43
|
end
|
42
44
|
alias_method :http_post_without_oneapm, :http_post
|
@@ -44,6 +46,7 @@ LibraryDetection.defer do
|
|
44
46
|
|
45
47
|
def http_put_with_oneapm(*args, &blk)
|
46
48
|
self._oa_http_verb = :PUT
|
49
|
+
self._oa_http_params = args.first
|
47
50
|
http_put_without_oneapm(*args, &blk)
|
48
51
|
end
|
49
52
|
alias_method :http_put_without_oneapm, :http_put
|
@@ -5,6 +5,21 @@ module OneApm
|
|
5
5
|
module Instrumentation
|
6
6
|
module ThriftHelper
|
7
7
|
|
8
|
+
attr_accessor :segment
|
9
|
+
|
10
|
+
def rpc_request
|
11
|
+
@rpc_request || {}
|
12
|
+
end
|
13
|
+
|
14
|
+
def rpc_request=(rpc_request)
|
15
|
+
@rpc_request = rpc_request
|
16
|
+
end
|
17
|
+
|
18
|
+
def rpc_reset!
|
19
|
+
@rpc_request = nil
|
20
|
+
@segment = nil
|
21
|
+
end
|
22
|
+
|
8
23
|
def operator result_klass
|
9
24
|
namespaces = result_klass.to_s.split('::')
|
10
25
|
operator_name = 'unknown'
|
@@ -24,14 +39,10 @@ module OneApm
|
|
24
39
|
metrics = if thost.nil?
|
25
40
|
["External/Thrift/#{operator_name}"]
|
26
41
|
else
|
27
|
-
|
42
|
+
#changed from */host/Thrift to */Thrift/host
|
43
|
+
["External/Thrift/#{thost}/#{operator_name}", "External/#{thost}/all"]
|
28
44
|
end
|
29
45
|
metrics << "External/all"
|
30
|
-
if OneApm::Transaction.recording_web_transaction?
|
31
|
-
metrics << "External/allWeb"
|
32
|
-
else
|
33
|
-
metrics << "External/allOther"
|
34
|
-
end
|
35
46
|
metrics
|
36
47
|
end
|
37
48
|
|
@@ -60,39 +71,65 @@ LibraryDetection.defer do
|
|
60
71
|
end
|
61
72
|
|
62
73
|
executes do
|
74
|
+
require 'one_apm/agent/cross_app/cross_app_tracing_message'
|
75
|
+
|
63
76
|
::Thrift::Client.module_eval do
|
64
77
|
include OneApm::Agent::Instrumentation::ThriftHelper
|
65
78
|
|
66
79
|
def send_message_with_oneapm(name, args_class, args = {})
|
67
|
-
|
80
|
+
state = OneApm::TransactionState.tl_get
|
81
|
+
t0 = Time.now
|
82
|
+
self.segment = OneApm::Agent::CrossAppTracingMessage.start_trace(state, t0, rpc_request)
|
83
|
+
operations[name] = { :started_time => t0 }
|
68
84
|
send_message_without_oneapm(name, args_class, args)
|
69
85
|
end
|
70
86
|
alias :send_message_without_oneapm :send_message
|
71
87
|
alias :send_message :send_message_with_oneapm
|
72
88
|
|
73
89
|
def send_oneway_message_with_oneapm(name, args_class, args = {})
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
90
|
+
begin
|
91
|
+
state = OneApm::TransactionState.tl_get
|
92
|
+
t0 = Time.now
|
93
|
+
segment = OneApm::Agent::CrossAppTracingMessage.start_trace(state, t0, rpc_request)
|
94
|
+
result = send_oneway_message_without_oneapm(name, args_class, args)
|
95
|
+
OneApm::Agent::CrossAppTracingMessage.finish_trace(state, t0, segment, rpc_request, metrics(name))
|
96
|
+
result
|
97
|
+
rescue => e
|
98
|
+
OneApm::Manager.logger.error "Thrift receive_message error: #{e}"
|
99
|
+
ensure
|
100
|
+
rpc_reset!
|
101
|
+
result
|
102
|
+
end
|
80
103
|
end
|
81
104
|
alias :send_oneway_message_without_oneapm :send_oneway_message
|
82
105
|
alias :send_oneway_message :send_oneway_message_with_oneapm
|
83
106
|
|
84
107
|
def receive_message_with_oneapm(result_klass)
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
108
|
+
begin
|
109
|
+
op = operator(result_klass)
|
110
|
+
op_started = started_time(op)
|
111
|
+
result = receive_message_without_oneapm(result_klass)
|
112
|
+
|
113
|
+
state = OneApm::TransactionState.tl_get
|
114
|
+
|
115
|
+
OneApm::Agent::CrossAppTracingMessage.finish_trace(state, op_started, segment, rpc_request, metrics(op))
|
116
|
+
result
|
117
|
+
rescue => e
|
118
|
+
OneApm::Manager.logger.error "Thrift receive_message error: #{e}"
|
119
|
+
ensure
|
120
|
+
rpc_reset!
|
121
|
+
result
|
122
|
+
end
|
92
123
|
end
|
93
124
|
|
94
125
|
alias :receive_message_without_oneapm :receive_message
|
95
126
|
alias :receive_message :receive_message_with_oneapm
|
96
127
|
end
|
97
128
|
end
|
129
|
+
executes do
|
130
|
+
require 'one_apm/support/http_clients/thrift_tracer'
|
131
|
+
[::Thrift::BinaryProtocol, ::Thrift::CompactProtocol, ::Thrift::JsonProtocol].each do |protocol_classs|
|
132
|
+
protocol_classs.send :include, OneApm::Support::HTTPClients::ThriftTracer
|
133
|
+
end
|
134
|
+
end
|
98
135
|
end
|