tingyun_rpm 1.0.7 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 21948f868b2947b4340e0c3da1981721cd469ef4
4
- data.tar.gz: 377e83899da310ca20d4491e05bd25debb888b0d
3
+ metadata.gz: 3c697d815d0c4dfa694eec1b5c600254f77c0a33
4
+ data.tar.gz: 7c0f3e329a156431014ee6ca7855ed0869059ac9
5
5
  SHA512:
6
- metadata.gz: 219f57d9cf603a41c5346142a47ed84fcd1f38e113eb715ad8e27fe8534a70a2224e6887cda71b36ac7e2056812fc1d4fa2ce7bf6f209ec28e60a4cfbe309027
7
- data.tar.gz: ee3b7d19c7f19308575837b0b76fb6202e993cfc9abb1e456c9d5d919d05dcb794cb02b8a9bc728492b54d0c9e9fa973fc9aa032a2050dd57d9ad0e137c9d1d1
6
+ metadata.gz: 32c38d249c36946077cecaa0e2483ece0b034a446da3a46ac1664d2d2c9c13a41b347caa962145140de7a6ab2630c752334d809787c6e1e35249fd8a93290da7
7
+ data.tar.gz: 406227f1aee1ae7ce1e7aa533c29624c6e41be7a1259ce036c673b99a2f3f3af41235ef7b0a0881865d3db738baf9571ffa9463d285c3cb097d6647360fd1fca
@@ -10,6 +10,9 @@ module TingYun
10
10
  module Collector
11
11
  class ErrorCollector
12
12
  ERRORS_ACTION = "Errors/Count/".freeze
13
+
14
+
15
+
13
16
  ERRORS_ALL = "Errors/Count/All".freeze
14
17
  ERRORS_ALL_WEB = "Errors/Count/AllWeb".freeze
15
18
  ERRORS_ALL_BACK_GROUND = "Errors/Count/AllBackground".freeze
@@ -61,11 +64,6 @@ module TingYun
61
64
  attr_reader :error_trace_array, :external_error_array
62
65
 
63
66
  def initialize
64
- # lookup of exception class names to ignore. Hash for fast access
65
- @ignore = {}
66
-
67
- @lock = Mutex.new
68
-
69
67
  @error_trace_array = ::TingYun::Agent::Collector::ErrorTraceArray.new(MAX_ERROR_QUEUE_LENGTH)
70
68
  @external_error_array = ::TingYun::Agent::Collector::ErrorTraceArray.new(MAX_ERROR_QUEUE_LENGTH)
71
69
  end
@@ -59,7 +59,9 @@ module TingYun
59
59
  if state.sql_recorded? && !metric_name.nil?
60
60
  if duration*1000 > TingYun::Agent.config[:'nbs.action_tracer.slow_sql_threshold']
61
61
  if duration*1000 > TingYun::Agent.config[:'nbs.action_tracer.stack_trace_threshold']
62
- backtrace = (caller.reject! { |t| t.include?('tingyun_rpm') }).join("\n")
62
+ backtrace = (caller.reject! { |t| t.include?('tingyun_rpm') })
63
+ backtrace = backtrace.first(40) if backtrace.length > 40
64
+ backtrace = backtrace.join("\n")
63
65
  else
64
66
  backtrace = ''
65
67
  end
@@ -157,7 +157,9 @@ module TingYun
157
157
  # than the specified duration
158
158
  def append_backtrace(node, duration)
159
159
  if duration*1000 >= Agent.config[:'nbs.action_tracer.stack_trace_threshold']
160
- node[:stacktrace] = caller.reject! { |t| t.include?('tingyun_rpm') }
160
+ trace = caller.reject! { |t| t.include?('tingyun_rpm') }
161
+ trace = trace.first(40) if trace.length > 40
162
+ node[:stacktrace] = trace
161
163
  end
162
164
 
163
165
  end
@@ -40,6 +40,7 @@ module TingYun
40
40
  rescue => e
41
41
  klass = "External/#{request.uri.to_s.gsub('/','%2F')}/net%2Fhttp"
42
42
  handle_error(e,klass)
43
+ raise e
43
44
  ensure
44
45
  finish_trace(state, t0, node, request, response)
45
46
  end
@@ -8,7 +8,6 @@ module TingYun
8
8
  attr_accessor :agent_attributes
9
9
  def initialize
10
10
  @agent_attributes = {}
11
- @custom_attributes = {}
12
11
  end
13
12
 
14
13
  def add_agent_attribute(key, value)
@@ -8,14 +8,11 @@ module TingYun
8
8
  class Transaction
9
9
  class Trace
10
10
 
11
- attr_accessor :node_count, :threshold, :metric_name, :uri, :guid, :attributes, :start_time, :finished, :tx_id
12
-
13
- attr_reader :root_node
11
+ attr_accessor :root_node, :node_count, :threshold, :metric_name, :uri, :guid, :attributes, :start_time, :finished, :tx_id
14
12
 
15
13
  def initialize(start_time)
16
14
  @start_time = start_time
17
15
  @node_count = 0
18
- @root_node = TingYun::Agent::Transaction::TraceNode.new(0.0, 'ROOT')
19
16
  @prepared = false
20
17
  @guid = generate_guid
21
18
  end
@@ -26,7 +23,7 @@ module TingYun
26
23
  end
27
24
 
28
25
  def duration
29
- @root_node.duration
26
+ root_node.duration
30
27
  end
31
28
 
32
29
 
@@ -38,7 +35,7 @@ module TingYun
38
35
  duration,
39
36
  request_params,
40
37
  custom_params,
41
- @root_node.to_array
38
+ root_node.to_array
42
39
  ]
43
40
  end
44
41
 
@@ -61,7 +58,7 @@ module TingYun
61
58
  collect_explain_plans!
62
59
  prepare_sql_for_transmission!
63
60
  else
64
- @root_node.each_call do |node|
61
+ root_node.each_call do |node|
65
62
  node.params.delete(:sql)
66
63
  end
67
64
  end
@@ -72,7 +69,7 @@ module TingYun
72
69
  def collect_explain_plans!
73
70
  return unless TingYun::Agent::Database.should_action_collect_explain_plans?
74
71
  threshold = TingYun::Agent.config[:'nbs.action_tracer.action_threshold']
75
- @root_node.each_call do |node|
72
+ root_node.each_call do |node|
76
73
  if node[:sql] && node.duration > threshold
77
74
  node[:explainPlan] = node.explain_sql
78
75
  end
@@ -81,7 +78,7 @@ module TingYun
81
78
 
82
79
  def prepare_sql_for_transmission!(&block)
83
80
  strategy = TingYun::Agent::Database.record_sql_method('nbs.action_tracer.record_sql')
84
- @root_node.each_call do |node|
81
+ root_node.each_call do |node|
85
82
  next unless node[:sql]
86
83
 
87
84
  case strategy
@@ -11,10 +11,15 @@ module TingYun
11
11
  def initialize(time=Time.now)
12
12
  @trace = TingYun::Agent::Transaction::Trace.new(time.to_f)
13
13
  @trace_start = time.to_f
14
- @current_node = @trace.root_node
15
14
  end
16
15
 
17
16
  def trace_entry(time)
17
+ if @trace.node_count == 0
18
+ node = @trace.create_node(time.to_f - @trace_start)
19
+ @trace.root_node = node
20
+ @current_node = node
21
+ return @current_node
22
+ end
18
23
  if @trace.node_count < node_limit
19
24
  node = @trace.create_node(time.to_f - @trace_start)
20
25
  @current_node.add_called_node(node)
@@ -631,7 +631,14 @@ module TingYun
631
631
  :public => true,
632
632
  :type => String,
633
633
  :allowed_from_server => true,
634
- :description => '跨应用追踪加密ID'
634
+ :description => 'trace ID of crossing apps'
635
+ },
636
+ :'nbs.naming.rules' => {
637
+ :default => '',
638
+ :public => true,
639
+ :type => String,
640
+ :allowed_from_server => true,
641
+ :description => 'the rule of name the webaction name containing match & split ways'
635
642
  }
636
643
  }.freeze
637
644
  end
@@ -38,6 +38,7 @@ TingYun::Support::LibraryDetection.defer do
38
38
  rescue => e
39
39
  klass = "External/#{uri_or_host.to_s.gsub('/','%2F')}/net%2Fhttp"
40
40
  ::TingYun::Instrumentation::Support::ExternalError.handle_error(e,klass)
41
+ raise e
41
42
  end
42
43
  end
43
44
  alias get_response_without_tingyun get_response
@@ -49,6 +50,7 @@ TingYun::Support::LibraryDetection.defer do
49
50
  rescue => e
50
51
  klass = "External/#{address.to_s.gsub('/','%2F')}/net%2Fhttp"
51
52
  ::TingYun::Instrumentation::Support::ExternalError.handle_error(e,klass)
53
+ raise e
52
54
  end
53
55
  end
54
56
  alias :start_without_tingyun :start
@@ -14,20 +14,15 @@ module TingYun
14
14
  if !response.nil? && response.code =~ /^[4,5][0-9][0-9]$/ && response.code!='401'
15
15
  e = TingYun::Support::Exception::InternalServerError.new("#{response.code}: #{response.message}")
16
16
  klass = "External/#{request.uri.to_s.gsub('/','%2F')}/#{type}"
17
- e.instance_variable_set(:@tingyun_klass, klass)
18
- e.instance_variable_set(:@tingyun_external, true)
17
+ set_attributes(e, klass)
19
18
  e.instance_variable_set(:@tingyun_code, response.code)
20
- e.instance_variable_set(:@tingyun_trace, caller.reject! { |t| t.include?('tingyun_rpm') })
21
19
  TingYun::Agent.notice_error(e)
22
20
  end
23
21
  end
24
22
 
25
23
  def handle_error(e,klass)
26
24
 
27
- e.instance_variable_set(:@tingyun_klass, klass)
28
- e.instance_variable_set(:@tingyun_external, true)
29
- e.instance_variable_set(:@tingyun_trace, caller.reject! { |t| t.include?('tingyun_rpm') })
30
-
25
+ set_attributes(e, klass)
31
26
  case e
32
27
  when Errno::ECONNREFUSED
33
28
  e.instance_variable_set(:@tingyun_code, 902)
@@ -42,8 +37,18 @@ module TingYun
42
37
  end
43
38
 
44
39
  TingYun::Agent.notice_error(e)
40
+ end
45
41
 
46
- raise e
42
+ def set_attributes(exception, klass)
43
+ begin
44
+ exception.instance_variable_set(:@tingyun_klass, klass)
45
+ exception.instance_variable_set(:@tingyun_external, true)
46
+ trace = caller.reject! { |t| t.include?('tingyun_rpm') }
47
+ trace = trace.first(40) if trace.length > 40
48
+ exception.instance_variable_set(:@tingyun_trace, trace)
49
+ rescue => e
50
+ TingYun::Agent.logger.warn("Failed to set attributes for : #{exception}: ", e)
51
+ end
47
52
  end
48
53
 
49
54
  end
@@ -0,0 +1,50 @@
1
+ module TingYun
2
+ module Instrumentation
3
+ module Support
4
+ module SplitController
5
+ # HTTP = {
6
+ # 'GET' => 1,
7
+ # 'POST' => 2,
8
+ # 'PUT' => 3,
9
+ # 'DELETE' => 4,
10
+ # 'HEAD' => 5
11
+ # }
12
+ #
13
+ # RULE = {
14
+ # 1=> :eql?,
15
+ # 2=> :start_with?,
16
+ # 3=> :end_with?,
17
+ # 4=> :include?
18
+ # }
19
+ #
20
+ # def match?(event)
21
+ # rules.each do |rule|
22
+ # if method_match?(event.method, rule[:match]['method'])
23
+ # if url_match?(event.path,rule[:match][:match], rule[:match]['value'])
24
+ #
25
+ # end
26
+ # end
27
+ # end
28
+ # end
29
+ #
30
+ #
31
+ #
32
+ # def rules
33
+ # TingYun::Agent.config[:'']
34
+ # end
35
+ #
36
+ # def method_match?(method, rule)
37
+ # rule[:match]['method'] == 0 || rule == HTTP[method]
38
+ # end
39
+ #
40
+ # def url_match?(url, rule, value)
41
+ # url.send(RULE[rule], value)
42
+ # end
43
+ #
44
+ # def params_match?
45
+ #
46
+ # end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'ting_yun/support/helper'
3
3
  require 'ting_yun/agent'
4
+ require 'ting_yun/instrumentation/support/external_error'
4
5
 
5
6
  module TingYun
6
7
  module Instrumentation
@@ -238,23 +239,25 @@ TingYun::Support::LibraryDetection.defer do
238
239
 
239
240
  include TingYun::Instrumentation::ThriftHelper
240
241
 
241
- def send_message_args_with_tingyun(args_class, args = {})
242
- state = TingYun::Agent::TransactionState.tl_get
243
- return unless state.execution_traced?
244
- cross_app_id = TingYun::Agent.config[:tingyunIdSecret] or
245
- raise TingYun::Agent::CrossAppTracing::Error, "no tingyunIdSecret configured"
246
- txn_guid = state.request_guid
247
- tingyun_id = "#{cross_app_id};c=1;x=#{txn_guid}"
248
-
249
- data = TingYun::Support::Serialize::JSONWrapper.dump("TingyunID" => tingyun_id)
250
- @oprot.write_field_begin("TingyunField", 11, 6)
251
- @oprot.write_string(data)
252
- @oprot.write_field_end
253
- send_message_args_without_tingyun(args_class, args)
254
- end
255
242
 
256
- alias :send_message_args_without_tingyun :send_message_args
257
- alias :send_message_args :send_message_args_with_tingyun
243
+ def send_message_args_with_tingyun(args_class, args = {})
244
+ state = TingYun::Agent::TransactionState.tl_get
245
+ return unless state.execution_traced?
246
+ cross_app_id = TingYun::Agent.config[:tingyunIdSecret] or
247
+ raise TingYun::Agent::CrossAppTracing::Error, "no tingyunIdSecret configured"
248
+ txn_guid = state.request_guid
249
+ tingyun_id = "#{cross_app_id};c=1;x=#{txn_guid}"
250
+
251
+ data = TingYun::Support::Serialize::JSONWrapper.dump("TingyunID" => tingyun_id)
252
+ @oprot.write_field_begin("TingyunField", 11, 6)
253
+ @oprot.write_string(data)
254
+ @oprot.write_field_end
255
+ send_message_args_without_tingyun(args_class, args)
256
+ end
257
+
258
+ alias :send_message_args_without_tingyun :send_message_args
259
+ alias :send_message_args :send_message_args_with_tingyun
260
+
258
261
 
259
262
  def send_message_with_tingyun(name, args_class, args = {})
260
263
 
@@ -296,11 +299,7 @@ TingYun::Support::LibraryDetection.defer do
296
299
  result = receive_message_without_tingyun(result_klass)
297
300
  if result.nil? || result.success.nil?
298
301
  e = ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, "#{operate} failed: unknown result")
299
- e.instance_variable_set(:@tingyun_klass, metrics(operate)[0])
300
- e.instance_variable_set(:@tingyun_external, true)
301
- e.instance_variable_set(:@tingyun_code, 1000)
302
- e.instance_variable_set(:@tingyun_trace, caller.reject! { |t| t.include?('tingyun_rpm') })
303
- TingYun::Agent.notice_error(e)
302
+ ::TingYun::Instrumentation::Support::ExternalError.handle_error(e,metrics(operate)[0])
304
303
  end
305
304
 
306
305
  t1 = Time.now.to_f
@@ -18,7 +18,13 @@ module TingYun
18
18
  end
19
19
 
20
20
  def collector_from_host(hostname=nil)
21
- Collector.new(hostname || TingYun::Agent.config[:host], TingYun::Agent.config[:port])
21
+ if hostname.nil?
22
+ Collector.new(TingYun::Agent.config[:host], TingYun::Agent.config[:port])
23
+ else
24
+ args = hostname.split(':')
25
+ Collector.new(args[0], args[1]||TingYun::Agent.config[:port])
26
+ end
27
+
22
28
  end
23
29
 
24
30
  end
@@ -67,7 +67,7 @@ module TingYun
67
67
  if metric_spec.scope.empty?
68
68
  general_array << TingYun::Metrics::MetricData.new(metric_spec, stats, metric_id)
69
69
  else
70
- components_array << TingYun::Metrics::MetricData.new(metric_spec, stats, metric_id)
70
+ components_array << TingYun::Metrics::MetricData.new(metric_spec, stats, metric_id) unless metric_spec.name.start_with?('External/NULL')
71
71
  end
72
72
  elsif metric_spec.name.start_with?('cross_app')
73
73
  external = metric_spec.name.split(';')
@@ -6,10 +6,8 @@ module TingYun
6
6
 
7
7
  MAJOR = 1
8
8
 
9
- MINOR = 0
10
- TINY = 7
11
-
12
-
9
+ MINOR = 1
10
+ TINY = 0
13
11
 
14
12
  STRING = [MAJOR, MINOR, TINY].compact.join('.')
15
13
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tingyun_rpm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - tingyun
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-22 00:00:00.000000000 Z
11
+ date: 2016-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -344,6 +344,7 @@ files:
344
344
  - lib/ting_yun/instrumentation/support/mongo_formatter.rb
345
345
  - lib/ting_yun/instrumentation/support/parameter_filtering.rb
346
346
  - lib/ting_yun/instrumentation/support/queue_time.rb
347
+ - lib/ting_yun/instrumentation/support/split_controller.rb
347
348
  - lib/ting_yun/instrumentation/support/transaction_namer.rb
348
349
  - lib/ting_yun/instrumentation/thrift.rb
349
350
  - lib/ting_yun/logger.rb