tingyun_rpm 1.6.1 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ting_yun/agent.rb +9 -2
- data/lib/ting_yun/agent/agent.rb +3 -2
- data/lib/ting_yun/agent/collector/error_collector/noticed_error.rb +1 -1
- data/lib/ting_yun/agent/collector/sql_sampler.rb +2 -2
- data/lib/ting_yun/agent/collector/transaction_sampler.rb +2 -2
- data/lib/ting_yun/agent/collector/transaction_sampler/class_method.rb +22 -7
- data/lib/ting_yun/agent/collector/transaction_sampler/slowest_sample_buffer.rb +3 -3
- data/lib/ting_yun/agent/collector/transaction_sampler/transaction_sample_buffer_base.rb +15 -2
- data/lib/ting_yun/agent/cross_app/cross_app_monitor.rb +22 -19
- data/lib/ting_yun/agent/cross_app/cross_app_tracing.rb +48 -14
- data/lib/ting_yun/agent/database.rb +1 -1
- data/lib/ting_yun/agent/datastore.rb +13 -2
- data/lib/ting_yun/agent/datastore/metric_helper.rb +8 -7
- data/lib/ting_yun/agent/instance_methods/connect.rb +21 -8
- data/lib/ting_yun/agent/instance_methods/container_data_manager.rb +20 -8
- data/lib/ting_yun/agent/instance_methods/start.rb +3 -3
- data/lib/ting_yun/agent/instance_methods/start_worker_thread.rb +9 -4
- data/lib/ting_yun/agent/method_tracer_helpers.rb +29 -1
- data/lib/ting_yun/agent/transaction.rb +24 -6
- data/lib/ting_yun/agent/transaction/attributes.rb +17 -2
- data/lib/ting_yun/agent/transaction/class_method.rb +1 -0
- data/lib/ting_yun/agent/transaction/instance_method.rb +10 -4
- data/lib/ting_yun/agent/transaction/request_attributes.rb +42 -3
- data/lib/ting_yun/agent/transaction/trace.rb +53 -6
- data/lib/ting_yun/agent/transaction/trace_node.rb +48 -12
- data/lib/ting_yun/agent/transaction/traced_method_stack.rb +1 -1
- data/lib/ting_yun/agent/transaction/transaction_sample_builder.rb +12 -11
- data/lib/ting_yun/agent/transaction/transaction_state.rb +16 -5
- data/lib/ting_yun/agent/transaction/transaction_timings.rb +1 -1
- data/lib/ting_yun/configuration/default_source.rb +327 -16
- data/lib/ting_yun/configuration/manager.rb +0 -1
- data/lib/ting_yun/configuration/server_source.rb +8 -2
- data/lib/ting_yun/configuration/yaml_source.rb +1 -1
- data/lib/ting_yun/frameworks/instance_methods.rb +2 -2
- data/lib/ting_yun/frameworks/rails.rb +2 -2
- data/lib/ting_yun/http/abstract_request.rb +12 -0
- data/lib/ting_yun/http/curb_wrappers.rb +1 -1
- data/lib/ting_yun/http/excon_wrappers.rb +9 -1
- data/lib/ting_yun/http/http_client_request.rb +13 -2
- data/lib/ting_yun/http/net_http_request.rb +10 -2
- data/lib/ting_yun/http/typhoeus_wrappers.rb +1 -1
- data/lib/ting_yun/instrumentation/active_record.rb +3 -5
- data/lib/ting_yun/instrumentation/bunny.rb +48 -44
- data/lib/ting_yun/instrumentation/grape.rb +4 -2
- data/lib/ting_yun/instrumentation/http_client.rb +1 -1
- data/lib/ting_yun/instrumentation/kafka.rb +18 -15
- data/lib/ting_yun/instrumentation/middleware_proxy.rb +3 -2
- data/lib/ting_yun/instrumentation/mongo.rb +2 -2
- data/lib/ting_yun/instrumentation/mongo_command_log_subscriber.rb +9 -9
- data/lib/ting_yun/instrumentation/rails3/action_controller.rb +3 -3
- data/lib/ting_yun/instrumentation/rake.rb +2 -1
- data/lib/ting_yun/instrumentation/redis.rb +6 -0
- data/lib/ting_yun/instrumentation/sidekiq.rb +1 -1
- data/lib/ting_yun/instrumentation/sinatra/action.rb +1 -1
- data/lib/ting_yun/instrumentation/support/action_cable_subscriber.rb +2 -2
- data/lib/ting_yun/instrumentation/support/action_controller_subscriber.rb +4 -4
- data/lib/ting_yun/instrumentation/support/action_view_subscriber.rb +14 -1
- data/lib/ting_yun/instrumentation/support/active_record_helper.rb +6 -2
- data/lib/ting_yun/instrumentation/support/active_record_subscriber.rb +14 -7
- data/lib/ting_yun/instrumentation/support/event_formatter.rb +7 -2
- data/lib/ting_yun/instrumentation/support/external_error.rb +1 -1
- data/lib/ting_yun/instrumentation/support/external_helper.rb +27 -4
- data/lib/ting_yun/instrumentation/support/javascript_instrumentor.rb +1 -1
- data/lib/ting_yun/instrumentation/support/method_instrumentation.rb +6 -1
- data/lib/ting_yun/instrumentation/support/parameter_filtering.rb +1 -1
- data/lib/ting_yun/instrumentation/support/thrift_helper.rb +4 -3
- data/lib/ting_yun/instrumentation/thrift.rb +7 -7
- data/lib/ting_yun/logger/create_logger_helper.rb +1 -1
- data/lib/ting_yun/middleware/agent_middleware.rb +1 -1
- data/lib/ting_yun/middleware/browser_monitoring.rb +3 -2
- data/lib/ting_yun/support/collector.rb +7 -1
- data/lib/ting_yun/ting_yun_service.rb +38 -21
- data/lib/ting_yun/ting_yun_service/http.rb +5 -3
- data/lib/ting_yun/ting_yun_service/request.rb +32 -6
- data/lib/ting_yun/ting_yun_service/upload_service.rb +25 -3
- data/lib/ting_yun/version.rb +4 -3
- data/lib/tingyun_rpm.rb +0 -2
- data/tingyun_rpm.gemspec +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: abc0dca8754928314bff5a8b5d2fc180b6b53390
|
4
|
+
data.tar.gz: 53015247182d5fada5c509200b25c2d773a80057
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae165e0439b4709fdb24783966d24ca6c932af82fc1d3cd240ae4c3725b243771f5ab4fff9fb35e80c82b305424deec6288d2cef21eafdef3b3a8350a70fa66a
|
7
|
+
data.tar.gz: 49c9a80f11cc20db3541750b89916ad5b0596f4ab74816513eec3aadf90ffb3bf0834ebb5e1d1e3e67a0164997465fe5084f34b77001e4322a1c685093b9bc3c
|
data/lib/ting_yun/agent.rb
CHANGED
@@ -63,7 +63,7 @@ module TingYun
|
|
63
63
|
# This method is safe to use from any thread.
|
64
64
|
#
|
65
65
|
# @api public
|
66
|
-
def
|
66
|
+
def record_metricV2(metric_name, value, is_scoped=false ) #THREAD_LOCAL_ACCESS
|
67
67
|
return unless agent
|
68
68
|
stats = TingYun::Metrics::Stats.create_from_hash(value) if value.is_a?(Hash)
|
69
69
|
if is_scoped
|
@@ -73,6 +73,9 @@ module TingYun
|
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
|
+
def record_metric(metric_name, value, is_scoped=false ) #THREAD_LOCAL_ACCESS
|
77
|
+
end
|
78
|
+
|
76
79
|
# Manual agent configuration and startup/shutdown
|
77
80
|
|
78
81
|
# Call this to manually start the Agent in situations where the Agent does
|
@@ -94,7 +97,7 @@ module TingYun
|
|
94
97
|
#
|
95
98
|
def manual_start(options={})
|
96
99
|
raise "Options must be a hash" unless Hash === options
|
97
|
-
TingYun::Frameworks.init_start({ :'
|
100
|
+
TingYun::Frameworks.init_start({ :'agent_enabled' => true, :sync_startup => true }.merge(options))
|
98
101
|
end
|
99
102
|
|
100
103
|
# Yield to a block that is run with a database metric name context. This means
|
@@ -206,5 +209,9 @@ module TingYun
|
|
206
209
|
TingYun::Agent::TransactionState.tl_get.execution_traced?
|
207
210
|
end
|
208
211
|
|
212
|
+
def upload
|
213
|
+
agent.transmit_data
|
214
|
+
end
|
215
|
+
|
209
216
|
end
|
210
217
|
end
|
data/lib/ting_yun/agent/agent.rb
CHANGED
@@ -37,7 +37,7 @@ module TingYun
|
|
37
37
|
@started = false
|
38
38
|
@environment_report = nil
|
39
39
|
@service = TingYunService.new
|
40
|
-
@connect_state = :
|
40
|
+
@connect_state = :first #[:first, :pending, :connected, :disconnected]
|
41
41
|
@events = TingYun::Agent::Event::EventListener.new
|
42
42
|
@after_fork_lock = Mutex.new
|
43
43
|
@dispatcher = TingYun::Agent::Dispatcher.new(@events)
|
@@ -89,8 +89,9 @@ module TingYun
|
|
89
89
|
rescue Exception => error
|
90
90
|
::TingYun::Agent.logger.error "Exception of unexpected type during Agent#connect! :", error
|
91
91
|
log_error(error)
|
92
|
+
raise
|
92
93
|
if opts[:keep_retrying]
|
93
|
-
::TingYun::Agent.logger.info "Will re-attempt in
|
94
|
+
::TingYun::Agent.logger.info "Will re-attempt in 30 seconds"
|
94
95
|
raise
|
95
96
|
end
|
96
97
|
end
|
@@ -48,9 +48,9 @@ module TingYun
|
|
48
48
|
data = state.sql_sampler_transaction_data
|
49
49
|
return unless data
|
50
50
|
threshold = duration*1000
|
51
|
-
if threshold > TingYun::Agent.config[:'
|
51
|
+
if threshold > TingYun::Agent.config[:'action_tracer.slow_sql_threshold'] && state.sql_recorded?
|
52
52
|
backtrace = ''
|
53
|
-
if threshold > TingYun::Agent.config[:'
|
53
|
+
if threshold > TingYun::Agent.config[:'action_tracer.stack_trace_threshold']
|
54
54
|
backtrace = caller.reject! { |t| t.include?('tingyun_rpm') }
|
55
55
|
backtrace = backtrace.first(20).join("\n")
|
56
56
|
end
|
@@ -23,7 +23,7 @@ module TingYun
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def harvest!
|
26
|
-
return [] unless TingYun::Agent.config[:'
|
26
|
+
return [] unless TingYun::Agent.config[:'action_tracer.enabled']
|
27
27
|
|
28
28
|
samples = @lock.synchronize do
|
29
29
|
@last_sample = nil
|
@@ -65,7 +65,7 @@ module TingYun
|
|
65
65
|
def on_finishing_transaction(state, txn, time=Time.now.to_f, exceptions)
|
66
66
|
|
67
67
|
last_builder = state.transaction_sample_builder
|
68
|
-
return unless last_builder && TingYun::Agent.config[:'
|
68
|
+
return unless last_builder && TingYun::Agent.config[:'action_tracer.enabled']
|
69
69
|
|
70
70
|
last_builder.finish_trace(time)
|
71
71
|
|
@@ -22,7 +22,7 @@ module TingYun
|
|
22
22
|
|
23
23
|
|
24
24
|
def on_start_transaction(state, time)
|
25
|
-
if TingYun::Agent.config[:'
|
25
|
+
if TingYun::Agent.config[:'action_tracer.enabled']
|
26
26
|
state.transaction_sample_builder ||= TingYun::Agent::TransactionSampleBuilder.new(time)
|
27
27
|
else
|
28
28
|
state.transaction_sample_builder = nil
|
@@ -48,15 +48,15 @@ module TingYun
|
|
48
48
|
end
|
49
49
|
|
50
50
|
# duration{:type => sec}
|
51
|
-
def notice_nosql(
|
51
|
+
def notice_nosql(config, duration,key) #THREAD_LOCAL_ACCESS
|
52
52
|
builder = tl_builder
|
53
|
-
action_tracer_segment(builder,
|
53
|
+
action_tracer_segment(builder, config, duration, key)
|
54
54
|
end
|
55
55
|
|
56
56
|
# duration{:type => sec}
|
57
|
-
def notice_nosql_statement(statement, duration) #THREAD_LOCAL_ACCESS
|
57
|
+
def notice_nosql_statement(statement, duration,key =:statement) #THREAD_LOCAL_ACCESS
|
58
58
|
builder = tl_builder
|
59
|
-
action_tracer_segment(builder, statement, duration,
|
59
|
+
action_tracer_segment(builder, statement, duration,key )
|
60
60
|
end
|
61
61
|
|
62
62
|
|
@@ -79,9 +79,24 @@ module TingYun
|
|
79
79
|
statement.sql = truncate_message(statement.sql + "\n#{message.sql}") if statement.sql.length <= MAX_DATA_LENGTH
|
80
80
|
else
|
81
81
|
# message is expected to have been pre-truncated by notice_sql
|
82
|
+
node.klass = message.config[:product]
|
83
|
+
node.method = message.config[:operation]
|
84
|
+
node.type = message.config[:type]
|
85
|
+
node.params_data.merge!(:vendor => message.config[:product],
|
86
|
+
:instance=>"#{message.config[:host]}:#{message.config[:port]}/#{message.config[:database]}",
|
87
|
+
:operation => message.sql)
|
82
88
|
node[:sql] = message
|
83
89
|
end
|
90
|
+
elsif key == :nosql
|
91
|
+
# message is expected to have been pre-truncated by notice_sql
|
92
|
+
node.klass = message[:product]
|
93
|
+
node[:method] = message[:operation]
|
94
|
+
node.type = message[:type]
|
95
|
+
node.params_data.merge!(:vendor => message[:product],
|
96
|
+
:instance=>"#{message[:host]}:#{message[:port]}/#{message[:database]}",
|
97
|
+
:operation => message[:nosql])
|
84
98
|
else
|
99
|
+
|
85
100
|
node[key] = truncate_message(message)
|
86
101
|
end
|
87
102
|
append_backtrace(node, duration)
|
@@ -105,10 +120,10 @@ module TingYun
|
|
105
120
|
# Appends a backtrace to a node if that node took longer
|
106
121
|
# than the specified duration
|
107
122
|
def append_backtrace(node, duration)
|
108
|
-
if duration*1000 >= Agent.config[:'
|
123
|
+
if duration*1000 >= Agent.config[:'action_tracer.stack_trace_threshold']
|
109
124
|
trace = caller.reject! { |t| t.include?('tingyun_rpm') }
|
110
125
|
trace = trace.first(20)
|
111
|
-
node
|
126
|
+
node.backtrace = trace
|
112
127
|
end
|
113
128
|
end
|
114
129
|
|
@@ -34,7 +34,7 @@ module TingYun
|
|
34
34
|
reset!
|
35
35
|
end
|
36
36
|
|
37
|
-
def
|
37
|
+
def storeV2(sample)
|
38
38
|
return unless enabled?
|
39
39
|
if allow_sample?(sample)
|
40
40
|
add_sample(sample)
|
@@ -42,7 +42,12 @@ module TingYun
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
def
|
45
|
+
def store(sample)
|
46
|
+
return unless enabled?
|
47
|
+
add_sample(sample)
|
48
|
+
end
|
49
|
+
|
50
|
+
def store_previousV2(previous_samples)
|
46
51
|
return unless enabled?
|
47
52
|
previous_samples.each do |sample|
|
48
53
|
add_sample(sample) if allow_sample?(sample)
|
@@ -50,6 +55,14 @@ module TingYun
|
|
50
55
|
truncate_samples_if_needed
|
51
56
|
end
|
52
57
|
|
58
|
+
def store_previous(previous_samples)
|
59
|
+
return unless enabled?
|
60
|
+
previous_samples.each do |sample|
|
61
|
+
add_sample(sample)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
|
53
66
|
def truncate_samples_if_needed
|
54
67
|
truncate_samples if full?
|
55
68
|
end
|
@@ -11,8 +11,8 @@ module TingYun
|
|
11
11
|
class CrossAppMonitor < TingYun::Agent::InboundRequestMonitor
|
12
12
|
|
13
13
|
|
14
|
-
TY_ID_HEADER = '
|
15
|
-
TY_DATA_HEADER = 'X-Tingyun-
|
14
|
+
TY_ID_HEADER = 'HTTP_X_TINGYUN'.freeze
|
15
|
+
TY_DATA_HEADER = 'X-Tingyun-Data'.freeze
|
16
16
|
|
17
17
|
|
18
18
|
def on_finished_configuring(events)
|
@@ -29,7 +29,9 @@ module TingYun
|
|
29
29
|
events.subscribe(:cross_app_before_call) do |env| #THREAD_LOCAL_ACCESS
|
30
30
|
if TingYun::Agent::CrossAppTracing.cross_app_enabled?
|
31
31
|
state = TingYun::Agent::TransactionState.tl_get
|
32
|
-
|
32
|
+
if env[TY_ID_HEADER]
|
33
|
+
state.save_referring_transaction_info(env[TY_ID_HEADER].split(';'))
|
34
|
+
end
|
33
35
|
end
|
34
36
|
end
|
35
37
|
|
@@ -40,7 +42,7 @@ module TingYun
|
|
40
42
|
end
|
41
43
|
|
42
44
|
|
43
|
-
def
|
45
|
+
def insert_response_headerV2(response_headers)
|
44
46
|
state = TingYun::Agent::TransactionState.tl_get
|
45
47
|
if state.same_account?
|
46
48
|
txn = state.current_transaction
|
@@ -52,27 +54,28 @@ module TingYun
|
|
52
54
|
end
|
53
55
|
end
|
54
56
|
|
57
|
+
def insert_response_header(response_headers)
|
58
|
+
state = TingYun::Agent::TransactionState.tl_get
|
59
|
+
txn = state.current_transaction
|
60
|
+
if txn
|
61
|
+
# set_response_headers
|
62
|
+
response_headers[TY_DATA_HEADER] = TingYun::Support::Serialize::JSONWrapper.dump build_payload(state)
|
63
|
+
TingYun::Agent.logger.debug("now,cross app will send response_headers #{response_headers[TY_DATA_HEADER]}")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
55
67
|
|
56
68
|
def build_payload(state)
|
57
69
|
timings = state.timings
|
58
70
|
|
59
71
|
payload = {
|
60
|
-
:id => TingYun::Agent.config[:
|
61
|
-
:
|
62
|
-
:
|
63
|
-
:
|
64
|
-
|
65
|
-
:qu => timings.queue_time_in_millis,
|
66
|
-
:db => timings.sql_duration,
|
67
|
-
:ex => timings.external_duration,
|
68
|
-
:rds => timings.rds_duration,
|
69
|
-
:mc => timings.mc_duration,
|
70
|
-
:mon => timings.mon_duration,
|
71
|
-
:code => timings.app_execute_duration
|
72
|
-
}
|
72
|
+
:id => TingYun::Agent.config[:idSecret],
|
73
|
+
:tname => state.transaction_name,
|
74
|
+
:tid => state.current_transaction.guid,
|
75
|
+
:rid => state.trace_id,
|
76
|
+
:duration => timings.app_time_in_millis
|
73
77
|
}
|
74
|
-
|
75
|
-
payload[:r] = state.client_req_id unless state.client_req_id.nil?
|
78
|
+
|
76
79
|
payload
|
77
80
|
end
|
78
81
|
|
@@ -6,6 +6,7 @@ require 'ting_yun/support/http_clients/uri_util'
|
|
6
6
|
require 'ting_yun/support/serialize/json_wrapper'
|
7
7
|
require 'ting_yun/instrumentation/support/external_error'
|
8
8
|
require 'ting_yun/agent/collector/transaction_sampler'
|
9
|
+
require 'ting_yun/instrumentation/support/external_helper'
|
9
10
|
|
10
11
|
|
11
12
|
module TingYun
|
@@ -13,14 +14,15 @@ module TingYun
|
|
13
14
|
module CrossAppTracing
|
14
15
|
|
15
16
|
extend ::TingYun::Instrumentation::Support::ExternalError
|
17
|
+
extend ::TingYun::Instrumentation::Support::ExternalHelper
|
16
18
|
|
17
19
|
# Exception raised if there is a problem with cross app transactions.
|
18
20
|
class Error < RuntimeError; end
|
19
21
|
|
20
22
|
# The cross app id header for "outgoing" calls
|
21
23
|
|
22
|
-
TY_ID_HEADER = 'X-Tingyun
|
23
|
-
TY_DATA_HEADER = 'X-Tingyun-
|
24
|
+
TY_ID_HEADER = 'X-Tingyun'.freeze
|
25
|
+
TY_DATA_HEADER = 'X-Tingyun-Data'.freeze
|
24
26
|
|
25
27
|
|
26
28
|
module_function
|
@@ -30,7 +32,6 @@ module TingYun
|
|
30
32
|
state = TingYun::Agent::TransactionState.tl_get
|
31
33
|
return yield unless state.execution_traced?
|
32
34
|
return yield unless state.current_transaction #如果还没有创建Transaction,就发生跨应用,就直接先跳过跟踪。
|
33
|
-
|
34
35
|
t0 = Time.now.to_f
|
35
36
|
begin
|
36
37
|
node = start_trace(state, t0, request)
|
@@ -43,14 +44,13 @@ module TingYun
|
|
43
44
|
end
|
44
45
|
|
45
46
|
def start_trace(state, t0, request)
|
46
|
-
inject_request_headers(state, request) if cross_app_enabled?
|
47
47
|
stack = state.traced_method_stack
|
48
48
|
node = stack.push_frame(state, :http_request, t0)
|
49
|
-
|
49
|
+
inject_request_headers(state, request) if cross_app_enabled?
|
50
50
|
return node
|
51
51
|
end
|
52
52
|
|
53
|
-
def
|
53
|
+
def finish_traceV2(state, t0, node, request, response)
|
54
54
|
|
55
55
|
t1 = Time.now.to_f
|
56
56
|
duration = (t1- t0) * 1000
|
@@ -65,7 +65,7 @@ module TingYun
|
|
65
65
|
tx_data = TingYun::Support::Serialize::JSONWrapper.load(get_ty_data_header(response).gsub("'",'"')) || {}
|
66
66
|
# net_block_duration = tx_data["time"]? duration - tx_data["time"]["duration"]- tx_data["time"]["qu"] : duration
|
67
67
|
# net_block_duration = duration if net_block_duration < 0
|
68
|
-
::TingYun::Agent.instance.stats_engine.record_scoped_and_unscoped_metrics(state, node_name, metrics, duration)
|
68
|
+
# ::TingYun::Agent.instance.stats_engine.record_scoped_and_unscoped_metrics(state, node_name, metrics, duration)
|
69
69
|
if cross_app
|
70
70
|
_duration = tx_data["time"]["duration"] + tx_data["time"]["qu"] + 0.1
|
71
71
|
metrics_cross_app = metrics_for_cross_app(request, response)
|
@@ -89,11 +89,46 @@ module TingYun
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
+
def finish_trace(state, t0, node, request, response)
|
93
|
+
|
94
|
+
t1 = Time.now.to_f
|
95
|
+
duration = (t1- t0) * 1000
|
96
|
+
state.timings.external_duration = duration
|
97
|
+
|
98
|
+
begin
|
99
|
+
if request
|
100
|
+
cross_app = response_is_cross_app?(response)
|
101
|
+
tx_data = TingYun::Support::Serialize::JSONWrapper.load(get_ty_data_header(response).gsub("'",'"')) || {}
|
102
|
+
# net_block_duration = tx_data["time"]? duration - tx_data["time"]["duration"]- tx_data["time"]["qu"] : duration
|
103
|
+
# net_block_duration = duration if net_block_duration < 0
|
104
|
+
# ::TingYun::Agent.instance.stats_engine.record_scoped_and_unscoped_metrics(state, node_name, metrics, duration)
|
105
|
+
# if cross_app
|
106
|
+
# _duration = tx_data["time"]["duration"] + tx_data["time"]["qu"] + 0.1
|
107
|
+
# metrics_for_cross_app(request, response)
|
108
|
+
# # txn = state.current_transaction
|
109
|
+
# # txn.metrics.record_scoped(metrics_cross_app.pop, duration, _duration)
|
110
|
+
# # txn.metrics.record_unscoped(metrics_cross_app, _duration)
|
111
|
+
# end
|
112
|
+
if node
|
113
|
+
node.name ="#{request.from}/#{request.uri.to_s}"
|
114
|
+
add_transaction_trace_info(request, response, cross_app, tx_data)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
rescue => err
|
118
|
+
TingYun::Agent.logger.error "Uncaught exception while finishing an HTTP request trace", err
|
119
|
+
ensure
|
120
|
+
if node
|
121
|
+
stack = state.traced_method_stack
|
122
|
+
stack.pop_frame(state, node, node.name, t1)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
92
126
|
|
93
127
|
def add_transaction_trace_info(request, response, cross_app, tx_data)
|
94
128
|
state = TingYun::Agent::TransactionState.tl_get
|
95
129
|
::TingYun::Agent::Collector::TransactionSampler.add_node_info(:uri => TingYun::Agent::HTTPClients::URIUtil.filter_uri(request.uri))
|
96
130
|
if cross_app
|
131
|
+
state.add_current_node_paramsV3(:txData=> TingYun::Support::Serialize::JSONWrapper.dump(tx_data))
|
97
132
|
::TingYun::Agent::Collector::TransactionSampler.tl_builder.set_txId_and_txData(state.client_transaction_id || state.request_guid, tx_data)
|
98
133
|
end
|
99
134
|
end
|
@@ -103,7 +138,8 @@ module TingYun
|
|
103
138
|
my_data = TingYun::Support::Serialize::JSONWrapper.load get_ty_data_header(response).gsub("'",'"')
|
104
139
|
metrics = ["ExternalTransaction/NULL/#{my_data["id"]}",
|
105
140
|
"ExternalTransaction/http/#{my_data["id"]}"]
|
106
|
-
metrics << "ExternalTransaction/#{request.uri.to_s.gsub(/\/\z/,'')
|
141
|
+
metrics << "ExternalTransaction/#{request.uri.to_s.gsub(/\/\z/,'')}/#{my_data["id"]}/#{my_data["action"].to_s
|
142
|
+
.gsub(/\/\z/,'')}"
|
107
143
|
end
|
108
144
|
|
109
145
|
def metrics_for(request)
|
@@ -113,23 +149,21 @@ module TingYun
|
|
113
149
|
else
|
114
150
|
metrics << "External/NULL/AllBackground"
|
115
151
|
end
|
116
|
-
metrics << "External/#{request.uri.to_s.gsub(/\/\z/,'')
|
152
|
+
metrics << "External/#{request.uri.to_s.gsub(/\/\z/,'')}/#{request.from}"
|
117
153
|
return metrics
|
118
154
|
end
|
119
155
|
|
120
156
|
|
121
157
|
|
122
158
|
def cross_app_enabled?
|
123
|
-
TingYun::Agent.config[:
|
124
|
-
TingYun::Agent.config[:'
|
159
|
+
TingYun::Agent.config[:idSecret] && TingYun::Agent.config[:idSecret].size > 0 &&
|
160
|
+
TingYun::Agent.config[:'action_tracer.enabled'] &&
|
125
161
|
TingYun::Agent.config[:'nbs.transaction_tracer.enabled']
|
126
162
|
end
|
127
163
|
|
128
164
|
# Inject the X-Process header into the outgoing +request+.
|
129
165
|
def inject_request_headers(state, request)
|
130
|
-
|
131
|
-
|
132
|
-
request[TY_ID_HEADER] = "#{cross_app_id};c=1;x=#{state.request_guid}"
|
166
|
+
request[TY_ID_HEADER] = create_tingyun_id(nil,nil,request)
|
133
167
|
end
|
134
168
|
|
135
169
|
# Returns +true+ if Cross Application Tracing is enabled, and the given +response+
|