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
@@ -49,9 +49,10 @@ module TingYun
|
|
49
49
|
@is_app = is_app
|
50
50
|
@category = determine_category
|
51
51
|
@target_class_name = determine_class_name
|
52
|
-
@transaction_name = "#{determine_prefix}#{@target_class_name}
|
52
|
+
@transaction_name = "#{determine_prefix}#{@target_class_name}"
|
53
53
|
@transaction_options = {
|
54
|
-
:transaction_name => @transaction_name
|
54
|
+
:transaction_name => @transaction_name,
|
55
|
+
:method => "call"
|
55
56
|
}
|
56
57
|
end
|
57
58
|
|
@@ -58,7 +58,7 @@ module TingYun
|
|
58
58
|
|
59
59
|
def instrument
|
60
60
|
::Mongo::Collection.class_eval do
|
61
|
-
def save_with_tingyun(doc, opts = {}, &block)
|
61
|
+
def save_with_tingyun(doc, opts = {}, &block) y
|
62
62
|
klass_name, *metrics = tingyun_generate_metrics(:save)
|
63
63
|
TingYun::Agent::MethodTracerHelpers.trace_execution_scoped(metrics, opts, method(:record_mongo_duration), klass_name) do
|
64
64
|
save_without_tingyun(doc, opts, &block)
|
@@ -92,7 +92,7 @@ TingYun::Support::LibraryDetection.defer do
|
|
92
92
|
end
|
93
93
|
|
94
94
|
depends_on do
|
95
|
-
defined?(::Mongo)
|
95
|
+
defined?(::Mongo) && false
|
96
96
|
end
|
97
97
|
|
98
98
|
depends_on do
|
@@ -29,13 +29,10 @@ module TingYun
|
|
29
29
|
state = TingYun::Agent::TransactionState.tl_get
|
30
30
|
state.timings.mon_duration = state.timings.mon_duration + event.duration * 1000
|
31
31
|
started_event = operations.delete(event.operation_id)
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
base, other_metrics, event.duration*1000
|
37
|
-
)
|
38
|
-
notice_nosql_statement(state, started_event, base, event.duration, klass_name)
|
32
|
+
# TingYun::Agent.instance.stats_engine.tl_record_scoped_and_unscoped_metrics(
|
33
|
+
# base, other_metrics, event.duration*1000
|
34
|
+
# )
|
35
|
+
notice_nosql_statement(state, started_event, nil, event.duration, "Mongo::Monitoring::Global")
|
39
36
|
rescue Exception => e
|
40
37
|
log_notification_error('completed', e)
|
41
38
|
end
|
@@ -76,7 +73,10 @@ module TingYun
|
|
76
73
|
TingYun::Instrumentation::Support::EventFormatter.format(
|
77
74
|
event.command_name,
|
78
75
|
event.database_name,
|
79
|
-
event.command
|
76
|
+
event.command,
|
77
|
+
event.address.host,
|
78
|
+
event.address.port,
|
79
|
+
event.inspect
|
80
80
|
)
|
81
81
|
end
|
82
82
|
|
@@ -88,7 +88,7 @@ module TingYun
|
|
88
88
|
# enter transaction trace node
|
89
89
|
frame = stack.push_frame(state, :mongo_db, end_time - duration)
|
90
90
|
|
91
|
-
transaction_sampler.notice_nosql_statement(generate_statement(event),duration*1000)
|
91
|
+
transaction_sampler.notice_nosql_statement(generate_statement(event),duration*1000,:nosql)
|
92
92
|
|
93
93
|
# exit transaction trace node
|
94
94
|
stack.pop_frame(state, frame, metric, end_time, true, klass_name)
|
@@ -17,13 +17,13 @@ module TingYun
|
|
17
17
|
if TingYun::Agent.config[:'naming.rules_enabled'] && find_rule(request.request_method.upcase, request.path, request.env, request.filtered_parameters)
|
18
18
|
return "Rails/#{namespace}/#{name(request.path.slice(1..-1), request.env, request.filtered_parameters, request.cookies)}"
|
19
19
|
else
|
20
|
-
return "URL/#{self.env["PATH_INFO"]
|
20
|
+
return "URL/#{self.env["PATH_INFO"]}" unless TingYun::Agent.config[:'auto_action_naming']
|
21
21
|
|
22
22
|
action = action_name_override || action_name
|
23
23
|
if action_name_override || self.class.action_methods.include?(action)
|
24
|
-
"Rails/#{self.class.controller_path}
|
24
|
+
"Rails/#{self.class.controller_path}/#{action}"
|
25
25
|
else
|
26
|
-
"Rails/#{self.class.controller_path}
|
26
|
+
"Rails/#{self.class.controller_path}/(other)"
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -28,7 +28,7 @@ TingYun::Support::LibraryDetection.defer do
|
|
28
28
|
TingYun::Agent::Instrumentation::RakeInstrumentation.before_invoke_transaction(self)
|
29
29
|
|
30
30
|
state = TingYun::Agent::TransactionState.tl_get
|
31
|
-
TingYun::Agent::Transaction.wrap(state, "
|
31
|
+
TingYun::Agent::Transaction.wrap(state, "TaskAction/Rake/invoke/#{name}", :rake) do
|
32
32
|
invoke_without_tingyun(*args)
|
33
33
|
end
|
34
34
|
end
|
@@ -59,6 +59,7 @@ module TingYun
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def self.should_trace? name
|
62
|
+
|
62
63
|
return ::TingYun::Agent.config[:'rake.tasks'].include?(name) if ::TingYun::Agent.config[:'rake.tasks'].any?
|
63
64
|
return !TingYun::Agent.config[:'rake.black.tasks'].include?(name) if ::TingYun::Agent.config[:'rake.black.tasks'].any?
|
64
65
|
return false
|
@@ -34,6 +34,8 @@ TingYun::Support::LibraryDetection.defer do
|
|
34
34
|
operation = args[0].is_a?(Array) ? args[0][0] : args[0]
|
35
35
|
|
36
36
|
TingYun::Agent::Datastore.wrap("Redis", operation, db, host, port, nil, method(:record_redis_duration)) do
|
37
|
+
state = TingYun::Agent::TransactionState.tl_get
|
38
|
+
state.add_current_node_params(:method=>"call_method",:klass=> "Redis/Client")
|
37
39
|
call_without_tingyun_trace(*args, &blk)
|
38
40
|
end
|
39
41
|
end
|
@@ -48,6 +50,8 @@ TingYun::Support::LibraryDetection.defer do
|
|
48
50
|
operation = pipeline.is_a?(::Redis::Pipeline::Multi) ? 'multi' : 'pipeline'
|
49
51
|
|
50
52
|
TingYun::Agent::Datastore.wrap("Redis", operation, db, host, port, nil, method(:record_redis_duration)) do
|
53
|
+
state = TingYun::Agent::TransactionState.tl_get
|
54
|
+
state.add_current_node_params(:method=>"call_pipelined",:klass=> "Redis/Client")
|
51
55
|
call_pipelined_without_tingyun_trace(*args, &block)
|
52
56
|
end
|
53
57
|
end
|
@@ -62,6 +66,8 @@ TingYun::Support::LibraryDetection.defer do
|
|
62
66
|
|
63
67
|
def connect(*args, &block)
|
64
68
|
TingYun::Agent::Datastore.wrap("Redis", "connect", db, host, port, nil, method(:record_redis_duration)) do
|
69
|
+
state = TingYun::Agent::TransactionState.tl_get
|
70
|
+
state.add_current_node_params(:method=>"connect",:klass=> "Redis/Client")
|
65
71
|
connect_without_tingyun(*args, &block)
|
66
72
|
end
|
67
73
|
end
|
@@ -13,7 +13,7 @@ module TingYun
|
|
13
13
|
if find_rule(request.request_method.upcase, path, request.env, request.params)
|
14
14
|
return "Sinatra/#{current_class}/#{namespace}/#{name(path.slice(1..-1), request.env, request.params, request.cookies)}"
|
15
15
|
else
|
16
|
-
return self.env["PATH_INFO"] unless TingYun::Agent.config[:'
|
16
|
+
return self.env["PATH_INFO"] unless TingYun::Agent.config[:'auto_action_naming']
|
17
17
|
"Sinatra/#{current_class}/#{path}(#{request.request_method.upcase})".squeeze("/")
|
18
18
|
end
|
19
19
|
end
|
@@ -60,11 +60,11 @@ module TingYun
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def transaction_name_from_event event
|
63
|
-
"WebAction/ActionCable/#{event.payload[:channel_class]}
|
63
|
+
"WebAction/ActionCable/#{event.payload[:channel_class]}/#{event.payload[:action]}"
|
64
64
|
end
|
65
65
|
|
66
66
|
def metric_name_from_event event
|
67
|
-
"ActionCable/#{event.payload[:channel_class]}
|
67
|
+
"ActionCable/#{event.payload[:channel_class]}/#{action_name_from_event(event)}"
|
68
68
|
end
|
69
69
|
|
70
70
|
DOT_ACTION_CABLE = ".action_cable".freeze
|
@@ -75,12 +75,12 @@ module TingYun
|
|
75
75
|
|
76
76
|
def metric_name
|
77
77
|
if TingYun::Agent.config[:'naming.rules_enabled'] && find_rule(method, uri, request.header, params)
|
78
|
-
@metric_name = "
|
78
|
+
@metric_name = "#{namespace}/#{name(uri, request.header, params, request.cookie)}"
|
79
79
|
else
|
80
|
-
if TingYun::Agent.config[:'
|
81
|
-
@metric_name ||= "
|
80
|
+
if TingYun::Agent.config[:'auto_action_naming']
|
81
|
+
@metric_name ||= "Rails/#{metric_path}/#{metric_action}"
|
82
82
|
else
|
83
|
-
"
|
83
|
+
"URI/#{uri}"
|
84
84
|
end
|
85
85
|
end
|
86
86
|
end
|
@@ -24,7 +24,7 @@ module TingYun
|
|
24
24
|
log_notification_error(e, name, 'start')
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
27
|
+
def finishV2(name, id, payload) #THREAD_LOCAL_ACCESS
|
28
28
|
event = pop_event(id)
|
29
29
|
|
30
30
|
state = TingYun::Agent::TransactionState.tl_get
|
@@ -38,6 +38,19 @@ module TingYun
|
|
38
38
|
log_notification_error(e, name, 'finish')
|
39
39
|
end
|
40
40
|
|
41
|
+
def finish(name, id, payload) #THREAD_LOCAL_ACCESS
|
42
|
+
event = pop_event(id)
|
43
|
+
|
44
|
+
state = TingYun::Agent::TransactionState.tl_get
|
45
|
+
|
46
|
+
if event.recordable?
|
47
|
+
stack = state.traced_method_stack
|
48
|
+
stack.pop_frame(state, event.frame, event.metric_name, event.end.to_f)
|
49
|
+
end
|
50
|
+
rescue => e
|
51
|
+
log_notification_error(e, name, 'finish')
|
52
|
+
end
|
53
|
+
|
41
54
|
def record_metrics(event, frame)
|
42
55
|
exclusive = event.duration - frame.children_time
|
43
56
|
TingYun::Agent.instance.stats_engine.tl_record_scoped_and_unscoped_metrics(
|
@@ -75,8 +75,12 @@ module TingYun
|
|
75
75
|
splits = split_name(name)
|
76
76
|
model = model_from_splits(splits) || product
|
77
77
|
operation = operation_from_splits(splits, sql)
|
78
|
-
|
79
|
-
|
78
|
+
config[:operation] = operation
|
79
|
+
config[:product] = product
|
80
|
+
config[:model] = model
|
81
|
+
config[:type] = "Database"
|
82
|
+
config
|
83
|
+
# TingYun::Agent::Datastore::MetricHelper.metrics_for(product, operation, config[:host], config[:port], config[:database], model, ACTIVE_RECORD)
|
80
84
|
end
|
81
85
|
|
82
86
|
def metrics_for_data_mapper(name, sql, config, model=nil)
|
@@ -26,7 +26,6 @@ module TingYun
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def start(name, id, payload) #THREAD_LOCAL_ACCESS
|
29
|
-
|
30
29
|
return if payload[:name] == CACHED_QUERY_NAME
|
31
30
|
super
|
32
31
|
rescue => e
|
@@ -38,8 +37,8 @@ module TingYun
|
|
38
37
|
state = TingYun::Agent::TransactionState.tl_get
|
39
38
|
event = pop_event(id)
|
40
39
|
config = active_record_config_for_event(event)
|
41
|
-
|
42
|
-
notice_sql(state, event, config,
|
40
|
+
config = record_metrics(event, config)
|
41
|
+
notice_sql(state, event, config, nil, nil)
|
43
42
|
rescue Exception => e
|
44
43
|
log_notification_error(e, name, 'finish')
|
45
44
|
end
|
@@ -51,9 +50,9 @@ module TingYun
|
|
51
50
|
# enter transaction trace node
|
52
51
|
frame = stack.push_frame(state, :active_record, event.time.to_f)
|
53
52
|
|
54
|
-
sql_sampler.notice_sql(event.payload[:sql], base, config,
|
55
|
-
|
56
|
-
|
53
|
+
# sql_sampler.notice_sql(event.payload[:sql], base, config,
|
54
|
+
# TingYun::Helper.milliseconds_to_seconds(event.duration),
|
55
|
+
# state, @explainer, event.payload[:binds], event.payload[:name])
|
57
56
|
|
58
57
|
transaction_sampler.notice_sql(event.payload[:sql], config, event.duration,
|
59
58
|
state, @explainer, event.payload[:binds], event.payload[:name])
|
@@ -61,7 +60,7 @@ module TingYun
|
|
61
60
|
stack.pop_frame(state, frame, base, event.end.to_f, true, metric)
|
62
61
|
end
|
63
62
|
|
64
|
-
def
|
63
|
+
def record_metricsV2(event, config)
|
65
64
|
metric, base, *other_metrics = TingYun::Instrumentation::Support::ActiveRecordHelper.metrics_for(event.payload[:name],
|
66
65
|
TingYun::Helper.correctly_encoded(event.payload[:sql]),
|
67
66
|
config)
|
@@ -72,6 +71,14 @@ module TingYun
|
|
72
71
|
end
|
73
72
|
|
74
73
|
|
74
|
+
def record_metrics(event, config)
|
75
|
+
TingYun::Instrumentation::Support::ActiveRecordHelper.metrics_for(event.payload[:name],
|
76
|
+
TingYun::Helper.correctly_encoded(event.payload[:sql]),
|
77
|
+
config)
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
|
75
82
|
def active_record_config_for_event(event)
|
76
83
|
return unless event.payload[:connection_id]
|
77
84
|
|
@@ -4,12 +4,17 @@ module TingYun
|
|
4
4
|
module Instrumentation
|
5
5
|
module Support
|
6
6
|
module EventFormatter
|
7
|
-
def self.format(command_name, database_name, command)
|
7
|
+
def self.format(command_name, database_name, command,host="localhost",port="27017", nosql="")
|
8
8
|
result = {
|
9
9
|
:operation => command_name,
|
10
10
|
:database => database_name,
|
11
11
|
:collection => command.values.first,
|
12
|
-
:term => command.values.last
|
12
|
+
:term => command.values.last,
|
13
|
+
:product => "Mongo",
|
14
|
+
:type=>"Mongo",
|
15
|
+
:host => host,
|
16
|
+
:port => port,
|
17
|
+
:nosql => nosql
|
13
18
|
}
|
14
19
|
result
|
15
20
|
end
|
@@ -16,7 +16,7 @@ module TingYun
|
|
16
16
|
def capture_exception(response,request)
|
17
17
|
if response && response.code.to_s =~ /^[4,5][0-9][0-9]$/ && response.code.to_s!='401'
|
18
18
|
e = TingYun::Support::Exception::InternalServerError.new("#{response.code}: #{response.message}")
|
19
|
-
klass = "External/#{request.uri.to_s.gsub(/\/\z/,'')
|
19
|
+
klass = "External/#{request.uri.to_s.gsub(/\/\z/,'')}/#{request.from}"
|
20
20
|
set_attributes(e, klass, response.code)
|
21
21
|
|
22
22
|
TingYun::Agent.notice_error(e,:type=>:exception)
|
@@ -1,20 +1,43 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
require 'digest'
|
3
4
|
|
4
5
|
module TingYun
|
5
6
|
module Instrumentation
|
6
7
|
module Support
|
7
8
|
module ExternalHelper
|
8
|
-
def
|
9
|
+
def create_tingyun_idV2(protocol)
|
9
10
|
state = TingYun::Agent::TransactionState.tl_get
|
10
11
|
externel_guid = tingyun_externel_guid
|
11
12
|
state.extenel_req_id = externel_guid
|
12
|
-
cross_app_id = TingYun::Agent.config[:
|
13
|
-
raise TingYun::Agent::CrossAppTracing::Error, "no
|
14
|
-
state.add_current_node_params(:
|
13
|
+
cross_app_id = TingYun::Agent.config[:idSecret] or
|
14
|
+
raise TingYun::Agent::CrossAppTracing::Error, "no idSecret configured"
|
15
|
+
state.add_current_node_params(:tx_id=>state.request_guid, :externalId=>state.extenel_req_id)
|
15
16
|
"#{cross_app_id};c=1;x=#{state.request_guid};e=#{externel_guid};s=#{TingYun::Helper.time_to_millis(Time.now)};p=#{protocol}"
|
16
17
|
end
|
17
18
|
|
19
|
+
def create_tingyun_id(protocol=nil,vendor=nil,request=nil)
|
20
|
+
state = TingYun::Agent::TransactionState.tl_get
|
21
|
+
if state.transaction_name_md5.nil?
|
22
|
+
tmd5 = Digest::MD5.hexdigest(state.current_transaction.best_name)
|
23
|
+
else
|
24
|
+
tmd5 = state.transaction_name_md5
|
25
|
+
end
|
26
|
+
externel_guid = tingyun_externel_guid
|
27
|
+
state.add_current_node_paramsV3(:externalId => externel_guid)
|
28
|
+
unless request.nil?
|
29
|
+
state.add_current_node_paramsV3(:protocol=> request.type)
|
30
|
+
state.add_current_node_paramsV3(:instance=> "#{request.host}:#{request.port}")
|
31
|
+
state.add_current_node_paramsV3(:operation=> request.path)
|
32
|
+
state.add_current_node_paramsV3(:vendor => request.from)
|
33
|
+
else
|
34
|
+
state.add_current_node_paramsV3(:protocol => protocol) unless protocol.nil?
|
35
|
+
state.add_current_node_paramsV3(:vendor => vendor) unless vendor.nil?
|
36
|
+
end
|
37
|
+
state.add_current_node_params(:type=> "External")
|
38
|
+
"c=S|#{state.client_tingyun_id_secret};x=#{state.request_guid};e=#{externel_guid};n=#{tmd5}"
|
39
|
+
end
|
40
|
+
|
18
41
|
# generate a random 64 bit uuid
|
19
42
|
def tingyun_externel_guid
|
20
43
|
guid = ''
|
@@ -44,7 +44,7 @@ module TingYun
|
|
44
44
|
timings = state.timings
|
45
45
|
|
46
46
|
data = {
|
47
|
-
:id => TingYun::Agent.config[:
|
47
|
+
:id => TingYun::Agent.config[:idSecret],
|
48
48
|
:n => state.transaction_name ,
|
49
49
|
:a => timings.app_time_in_millis,
|
50
50
|
:q => timings.queue_time_in_millis,
|
@@ -75,7 +75,7 @@ module TingYun
|
|
75
75
|
exists
|
76
76
|
end
|
77
77
|
|
78
|
-
def
|
78
|
+
def tingyun_evalV2(method_name, metric_name, options)
|
79
79
|
options = validate_options(method_name, options)
|
80
80
|
if options[:scope]
|
81
81
|
define_method_with_scope(method_name, metric_name, options)
|
@@ -84,6 +84,11 @@ module TingYun
|
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
|
+
def tingyun_eval(method_name, metric_name, options)
|
88
|
+
options = validate_options(method_name, options)
|
89
|
+
define_method_with_scope(method_name, metric_name, options)
|
90
|
+
end
|
91
|
+
|
87
92
|
DEFAULT_SETTINGS = {:scope => true, :metric => true, :before_code => "", :after_code => "" }.freeze
|
88
93
|
|
89
94
|
def validate_options(method_name, options)
|
@@ -16,7 +16,7 @@ module TingYun
|
|
16
16
|
result.delete("commit")
|
17
17
|
result.delete("authenticity_token")
|
18
18
|
result.delete_if{|_,v| !v.is_a? String}
|
19
|
-
TingYun::Agent.config["
|
19
|
+
TingYun::Agent.config["action_tracer.ignored_params"].split(',').each{|key| result.delete(key)}
|
20
20
|
result
|
21
21
|
end
|
22
22
|
|
@@ -44,9 +44,9 @@ module TingYun
|
|
44
44
|
|
45
45
|
def metrics operate
|
46
46
|
metrics = if tingyun_host.nil?
|
47
|
-
["External/thrift
|
47
|
+
["External/thrift://#{operate}/thrift"]
|
48
48
|
else
|
49
|
-
["External/thrift
|
49
|
+
["External/thrift://#{tingyun_host}:#{tingyun_port}/#{operate}/thrift"]
|
50
50
|
end
|
51
51
|
metrics << "External/NULL/ALL"
|
52
52
|
|
@@ -61,7 +61,8 @@ module TingYun
|
|
61
61
|
def metrics_for_cross_app(operate,my_data)
|
62
62
|
metrics = ["ExternalTransaction/NULL/#{my_data["id"]}",
|
63
63
|
"ExternalTransaction/thrift/#{my_data["id"]}",
|
64
|
-
"ExternalTransaction/thrift
|
64
|
+
"ExternalTransaction/thrift://#{tingyun_host}:#{tingyun_port}/#{operate}/#{my_data["id"]}/
|
65
|
+
#{my_data["action"].to_s.gsub(/\/\z/,'')}"]
|
65
66
|
return metrics
|
66
67
|
end
|
67
68
|
|
@@ -6,7 +6,7 @@ TingYun::Support::LibraryDetection.defer do
|
|
6
6
|
named :thrift
|
7
7
|
|
8
8
|
depends_on do
|
9
|
-
defined?(::Thrift) && defined?(::Thrift::Client) && defined?(::Thrift::BaseProtocol)
|
9
|
+
defined?(::Thrift) && defined?(::Thrift::Client) && defined?(::Thrift::BaseProtocol) && false
|
10
10
|
end
|
11
11
|
|
12
12
|
|
@@ -51,7 +51,7 @@ TingYun::Support::LibraryDetection.defer do
|
|
51
51
|
state = TingYun::Agent::TransactionState.tl_get
|
52
52
|
return unless state.execution_traced?
|
53
53
|
|
54
|
-
data = TingYun::Support::Serialize::JSONWrapper.dump("TingyunID" => create_tingyun_id("thrift"))
|
54
|
+
data = TingYun::Support::Serialize::JSONWrapper.dump("TingyunID" => create_tingyun_id("Thrift","thrift"))
|
55
55
|
TingYun::Agent.logger.info("thift will send TingyunID : ", data)
|
56
56
|
@oprot.write_field_begin("TingyunField", 11, 40000)
|
57
57
|
@oprot.write_string(data)
|
@@ -96,7 +96,7 @@ TingYun::Support::LibraryDetection.defer do
|
|
96
96
|
base, *other_metrics = metrics(tag)
|
97
97
|
result = send_oneway_message_without_tingyun(name, args_class, args)
|
98
98
|
duration = (Time.now.to_f - op_started)*1000
|
99
|
-
TingYun::Agent.instance.stats_engine.tl_record_scoped_and_unscoped_metrics(base, other_metrics, duration)
|
99
|
+
# TingYun::Agent.instance.stats_engine.tl_record_scoped_and_unscoped_metrics(base, other_metrics, duration)
|
100
100
|
result
|
101
101
|
rescue => e
|
102
102
|
TingYun::Agent.logger.debug("Failed to thrift send_oneway_message_with_tingyun : ", e)
|
@@ -128,14 +128,14 @@ TingYun::Support::LibraryDetection.defer do
|
|
128
128
|
my_data = state.thrift_return_data || {}
|
129
129
|
# net_block_duration = my_data["time"]? duration - my_data["time"]["duration"]- my_data["time"]["qu"] : duration
|
130
130
|
# net_block_duration = duration if net_block_duration < 0
|
131
|
-
TingYun::Agent.instance.stats_engine.tl_record_scoped_and_unscoped_metrics(
|
132
|
-
|
133
|
-
)
|
131
|
+
# TingYun::Agent.instance.stats_engine.tl_record_scoped_and_unscoped_metrics(
|
132
|
+
# node_name, other_metrics, duration
|
133
|
+
# )
|
134
134
|
|
135
135
|
if my_data["time"]
|
136
136
|
metrics_cross_app = metrics_for_cross_app(operate, my_data)
|
137
137
|
_duration = my_data["time"]["duration"] + my_data["time"]["qu"] + 0.1
|
138
|
-
::TingYun::Agent.instance.stats_engine.record_scoped_and_unscoped_metrics(state, metrics_cross_app.pop, metrics_cross_app, duration, _duration)
|
138
|
+
# ::TingYun::Agent.instance.stats_engine.record_scoped_and_unscoped_metrics(state, metrics_cross_app.pop, metrics_cross_app, duration, _duration)
|
139
139
|
end
|
140
140
|
if node
|
141
141
|
node.name = node_name
|