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.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ting_yun/agent.rb +9 -2
  3. data/lib/ting_yun/agent/agent.rb +3 -2
  4. data/lib/ting_yun/agent/collector/error_collector/noticed_error.rb +1 -1
  5. data/lib/ting_yun/agent/collector/sql_sampler.rb +2 -2
  6. data/lib/ting_yun/agent/collector/transaction_sampler.rb +2 -2
  7. data/lib/ting_yun/agent/collector/transaction_sampler/class_method.rb +22 -7
  8. data/lib/ting_yun/agent/collector/transaction_sampler/slowest_sample_buffer.rb +3 -3
  9. data/lib/ting_yun/agent/collector/transaction_sampler/transaction_sample_buffer_base.rb +15 -2
  10. data/lib/ting_yun/agent/cross_app/cross_app_monitor.rb +22 -19
  11. data/lib/ting_yun/agent/cross_app/cross_app_tracing.rb +48 -14
  12. data/lib/ting_yun/agent/database.rb +1 -1
  13. data/lib/ting_yun/agent/datastore.rb +13 -2
  14. data/lib/ting_yun/agent/datastore/metric_helper.rb +8 -7
  15. data/lib/ting_yun/agent/instance_methods/connect.rb +21 -8
  16. data/lib/ting_yun/agent/instance_methods/container_data_manager.rb +20 -8
  17. data/lib/ting_yun/agent/instance_methods/start.rb +3 -3
  18. data/lib/ting_yun/agent/instance_methods/start_worker_thread.rb +9 -4
  19. data/lib/ting_yun/agent/method_tracer_helpers.rb +29 -1
  20. data/lib/ting_yun/agent/transaction.rb +24 -6
  21. data/lib/ting_yun/agent/transaction/attributes.rb +17 -2
  22. data/lib/ting_yun/agent/transaction/class_method.rb +1 -0
  23. data/lib/ting_yun/agent/transaction/instance_method.rb +10 -4
  24. data/lib/ting_yun/agent/transaction/request_attributes.rb +42 -3
  25. data/lib/ting_yun/agent/transaction/trace.rb +53 -6
  26. data/lib/ting_yun/agent/transaction/trace_node.rb +48 -12
  27. data/lib/ting_yun/agent/transaction/traced_method_stack.rb +1 -1
  28. data/lib/ting_yun/agent/transaction/transaction_sample_builder.rb +12 -11
  29. data/lib/ting_yun/agent/transaction/transaction_state.rb +16 -5
  30. data/lib/ting_yun/agent/transaction/transaction_timings.rb +1 -1
  31. data/lib/ting_yun/configuration/default_source.rb +327 -16
  32. data/lib/ting_yun/configuration/manager.rb +0 -1
  33. data/lib/ting_yun/configuration/server_source.rb +8 -2
  34. data/lib/ting_yun/configuration/yaml_source.rb +1 -1
  35. data/lib/ting_yun/frameworks/instance_methods.rb +2 -2
  36. data/lib/ting_yun/frameworks/rails.rb +2 -2
  37. data/lib/ting_yun/http/abstract_request.rb +12 -0
  38. data/lib/ting_yun/http/curb_wrappers.rb +1 -1
  39. data/lib/ting_yun/http/excon_wrappers.rb +9 -1
  40. data/lib/ting_yun/http/http_client_request.rb +13 -2
  41. data/lib/ting_yun/http/net_http_request.rb +10 -2
  42. data/lib/ting_yun/http/typhoeus_wrappers.rb +1 -1
  43. data/lib/ting_yun/instrumentation/active_record.rb +3 -5
  44. data/lib/ting_yun/instrumentation/bunny.rb +48 -44
  45. data/lib/ting_yun/instrumentation/grape.rb +4 -2
  46. data/lib/ting_yun/instrumentation/http_client.rb +1 -1
  47. data/lib/ting_yun/instrumentation/kafka.rb +18 -15
  48. data/lib/ting_yun/instrumentation/middleware_proxy.rb +3 -2
  49. data/lib/ting_yun/instrumentation/mongo.rb +2 -2
  50. data/lib/ting_yun/instrumentation/mongo_command_log_subscriber.rb +9 -9
  51. data/lib/ting_yun/instrumentation/rails3/action_controller.rb +3 -3
  52. data/lib/ting_yun/instrumentation/rake.rb +2 -1
  53. data/lib/ting_yun/instrumentation/redis.rb +6 -0
  54. data/lib/ting_yun/instrumentation/sidekiq.rb +1 -1
  55. data/lib/ting_yun/instrumentation/sinatra/action.rb +1 -1
  56. data/lib/ting_yun/instrumentation/support/action_cable_subscriber.rb +2 -2
  57. data/lib/ting_yun/instrumentation/support/action_controller_subscriber.rb +4 -4
  58. data/lib/ting_yun/instrumentation/support/action_view_subscriber.rb +14 -1
  59. data/lib/ting_yun/instrumentation/support/active_record_helper.rb +6 -2
  60. data/lib/ting_yun/instrumentation/support/active_record_subscriber.rb +14 -7
  61. data/lib/ting_yun/instrumentation/support/event_formatter.rb +7 -2
  62. data/lib/ting_yun/instrumentation/support/external_error.rb +1 -1
  63. data/lib/ting_yun/instrumentation/support/external_helper.rb +27 -4
  64. data/lib/ting_yun/instrumentation/support/javascript_instrumentor.rb +1 -1
  65. data/lib/ting_yun/instrumentation/support/method_instrumentation.rb +6 -1
  66. data/lib/ting_yun/instrumentation/support/parameter_filtering.rb +1 -1
  67. data/lib/ting_yun/instrumentation/support/thrift_helper.rb +4 -3
  68. data/lib/ting_yun/instrumentation/thrift.rb +7 -7
  69. data/lib/ting_yun/logger/create_logger_helper.rb +1 -1
  70. data/lib/ting_yun/middleware/agent_middleware.rb +1 -1
  71. data/lib/ting_yun/middleware/browser_monitoring.rb +3 -2
  72. data/lib/ting_yun/support/collector.rb +7 -1
  73. data/lib/ting_yun/ting_yun_service.rb +38 -21
  74. data/lib/ting_yun/ting_yun_service/http.rb +5 -3
  75. data/lib/ting_yun/ting_yun_service/request.rb +32 -6
  76. data/lib/ting_yun/ting_yun_service/upload_service.rb +25 -3
  77. data/lib/ting_yun/version.rb +4 -3
  78. data/lib/tingyun_rpm.rb +0 -2
  79. data/tingyun_rpm.gemspec +1 -0
  80. metadata +2 -2
@@ -90,7 +90,6 @@ module TingYun
90
90
  @server_source = nil
91
91
  @manual_source = nil
92
92
  # @callbacks = Hash.new {|hash,key| hash[key] =[]}#存放需要merge本地和服务端配置的info'
93
-
94
93
  @configs_for_testing = []
95
94
 
96
95
  reset_cache
@@ -9,7 +9,7 @@ module TingYun
9
9
  # These keys appear *outside* of the agent_config hash in the connect
10
10
  # response, but should still be merged in as config settings to the
11
11
  # main agent configuration.
12
- TOP_LEVEL_KEYS = [
12
+ TOP_LEVEL_KEYSV2 = [
13
13
  "applicationId",
14
14
  "tingyunIdSecret",
15
15
  "enabled",
@@ -19,6 +19,13 @@ module TingYun
19
19
  "config"
20
20
  ]
21
21
 
22
+ TOP_LEVEL_KEYS = [
23
+ "appId",
24
+ "idSecret",
25
+ "sessionKey",
26
+ "config"
27
+ ]
28
+
22
29
  def self.add_top_level_keys_for_testing(add_array)
23
30
  TOP_LEVEL_KEYS.concat add_array
24
31
  end
@@ -29,7 +36,6 @@ module TingYun
29
36
 
30
37
  def initialize(connect_reply)
31
38
  merged_settings = {}
32
-
33
39
  merge_top_level_keys(merged_settings, connect_reply)
34
40
  merge_agent_config_hash(merged_settings, connect_reply)
35
41
  filter_keys(merged_settings)
@@ -25,7 +25,7 @@ module TingYun
25
25
  rescue ScriptError, StandardError => e
26
26
  log_failure("Failed to read or parse configuration file at #{path}", e)
27
27
  end
28
- booleanify_values(config, 'nbs.agent_enabled', 'enabled')
28
+ booleanify_values(config, 'agent_enabled', 'enabled')
29
29
  super(config, true)
30
30
  end
31
31
 
@@ -38,7 +38,7 @@ module TingYun
38
38
  # then it will install the real agent and start it.
39
39
  #
40
40
  # What determines whether the agent is launched is the result of
41
- # calling nbs.agent_enabled? This will indicate whether the
41
+ # calling agent_enabled? This will indicate whether the
42
42
  # instrumentation should/will be installed. If we're in a mode
43
43
  # where tracers are not installed then we should not start the
44
44
  # agent.
@@ -60,7 +60,7 @@ module TingYun
60
60
 
61
61
  TingYun::Agent.agent = TingYun::Agent::Agent.instance
62
62
 
63
- if TingYun::Agent.config[:'nbs.agent_enabled'] && !TingYun::Agent.agent.started?
63
+ if TingYun::Agent.config[:'agent_enabled'] && !TingYun::Agent.agent.started?
64
64
  start_agent
65
65
  install_instrumentation
66
66
  else
@@ -42,9 +42,9 @@ module TingYun
42
42
  end
43
43
  end
44
44
 
45
- if !Agent.config[:'nbs.agent_enabled']
45
+ if !Agent.config[:'agent_enabled']
46
46
  # Might not be running if it does not think mongrel, thin, passenger, etc
47
- # is running, if it thinks it's a rake task, or if the nbs.agent_enabled is false.
47
+ # is running, if it thinks it's a rake task, or if the agent_enabled is false.
48
48
  ::TingYun::Agent.logger.info("TingYun Agent is unable to run.")
49
49
  else
50
50
  install_browser_monitoring(rails_config)
@@ -17,6 +17,18 @@ module TingYun
17
17
  raise NotImplementedError, ERROR_MESSAGE + ':from method'
18
18
  end
19
19
 
20
+ def port
21
+ ""
22
+ end
23
+
24
+ def host
25
+ ""
26
+ end
27
+
28
+ def path
29
+ ""
30
+ end
31
+
20
32
 
21
33
  end
22
34
  end
@@ -19,7 +19,7 @@ require 'ting_yun/http/abstract_request'
19
19
  end
20
20
 
21
21
  def from
22
- "curb%2Fhttp"
22
+ "curb http"
23
23
  end
24
24
 
25
25
  def host_from_header
@@ -49,7 +49,7 @@ module TingYun
49
49
  end
50
50
 
51
51
  def from
52
- "excon%2Fhttp"
52
+ "excon http"
53
53
  end
54
54
 
55
55
  def host_from_header
@@ -63,6 +63,14 @@ module TingYun
63
63
  host_from_header || @datum[:host]
64
64
  end
65
65
 
66
+ def port
67
+ @port
68
+ end
69
+
70
+ def path
71
+ @path
72
+ end
73
+
66
74
  def [](key)
67
75
  @datum[:headers][key]
68
76
  end
@@ -11,11 +11,18 @@ module TingYun
11
11
  end
12
12
 
13
13
  def type
14
- 'HTTPClient'
14
+ @uri.scheme
15
15
  end
16
16
 
17
17
  def from
18
- "http_client%2Fhttp"
18
+ "HttpClient"
19
+ end
20
+
21
+ def host
22
+ @uri.host || @proxy.host
23
+ end
24
+ def port
25
+ @uri.port || @uri.port
19
26
  end
20
27
 
21
28
  def [](key)
@@ -31,6 +38,10 @@ module TingYun
31
38
  URI("#{@proxy.scheme.downcase}://#{@proxy.host}:#{@proxy.port}#{@uri}")
32
39
  end
33
40
 
41
+ def path
42
+ @uri
43
+ end
44
+
34
45
  def args
35
46
  return @method, @uri, @query, @body, @header
36
47
  end
@@ -8,11 +8,11 @@ module TingYun
8
8
  end
9
9
 
10
10
  def type
11
- 'Net::HTTP'
11
+ @connection.use_ssl? ? 'https' : 'http'
12
12
  end
13
13
 
14
14
  def from
15
- "net%2Fhttp"
15
+ "net http"
16
16
  end
17
17
 
18
18
  def host
@@ -23,6 +23,10 @@ module TingYun
23
23
  end
24
24
  end
25
25
 
26
+ def port
27
+ @connection.port
28
+ end
29
+
26
30
  def method
27
31
  @request.method
28
32
  end
@@ -35,6 +39,10 @@ module TingYun
35
39
  @request[key] = value
36
40
  end
37
41
 
42
+ def path
43
+ @request.path
44
+ end
45
+
38
46
  def uri
39
47
  case @request.path
40
48
  when /^https?:\/\//
@@ -49,7 +49,7 @@ module TingYun
49
49
  TYPHOEUS
50
50
  end
51
51
  def from
52
- "typhoeus%2Fhttp"
52
+ "typhoeus http"
53
53
  end
54
54
 
55
55
  LHOST = 'host'.freeze
@@ -41,17 +41,15 @@ module TingYun
41
41
  end
42
42
 
43
43
  def log_with_tingyun_instrumentation(*args, &block)
44
-
45
44
  state = TingYun::Agent::TransactionState.tl_get
46
45
  sql, name, _ = args
47
- klass_name, *metrics = ::TingYun::Instrumentation::Support::ActiveRecordHelper.metrics_for(
46
+ @config= ::TingYun::Instrumentation::Support::ActiveRecordHelper.metrics_for(
48
47
  TingYun::Helper.correctly_encoded(name),
49
48
  TingYun::Helper.correctly_encoded(sql),
50
49
  @config)
51
50
 
52
- scoped_metric = metrics.first
53
51
 
54
- TingYun::Agent::MethodTracerHelpers.trace_execution_scoped(metrics, {}, nil, klass_name) do
52
+ TingYun::Agent::MethodTracerHelpers.trace_execution_scoped(nil, {}, nil, nil) do
55
53
  t0 = Time.now
56
54
  begin
57
55
  log_without_tingyun_instrumentation(*args, &block)
@@ -60,7 +58,7 @@ module TingYun
60
58
  state.timings.sql_duration = state.timings.sql_duration + elapsed_time * 1000
61
59
 
62
60
  ::TingYun::Agent::Collector::TransactionSampler.notice_sql(sql, @config, elapsed_time, state, EXPLAINER)
63
- ::TingYun::Agent::Collector::SqlSampler.notice_sql(sql, scoped_metric, @config, elapsed_time, state, EXPLAINER)
61
+ # ::TingYun::Agent::Collector::SqlSampler.notice_sql(sql, scoped_metric, @config, elapsed_time, state, EXPLAINER)
64
62
  end
65
63
 
66
64
  end
@@ -26,24 +26,27 @@ TingYun::Support::LibraryDetection.defer do
26
26
  state = TingYun::Agent::TransactionState.tl_get
27
27
  return publish_without_tingyun(payload, opts) unless state.execution_traced?
28
28
  queue_name = opts[:routing_key]
29
-
30
- metric_name = "Message RabbitMQ/#{@channel.connection.host}:#{@channel.connection.port}%2F"
29
+ metric_name = "Message RabbitMQ/#{@channel.connection.host}:#{@channel.connection.port}/"
31
30
  if name.empty?
32
31
  if queue_name.start_with?("amq.")
33
- metric_name << "Queue%2FTemp/Produce"
32
+ metric_name << "Queue/Temp/Produce"
34
33
  elsif queue_name.include?(".")
35
- metric_name << "Topic%2F#{queue_name}/Produce"
34
+ metric_name << "Topic/#{queue_name}/Produce"
36
35
  else
37
- metric_name << "Queue%2F#{queue_name}/Produce"
36
+ metric_name << "Queue/#{queue_name}/Produce"
38
37
  end
39
38
  else
40
- metric_name << "Exchange%2F#{name}/Produce"
39
+ metric_name << "Exchange/#{name}/Produce"
41
40
  end
42
41
  summary_metrics = TingYun::Instrumentation::Support::ExternalHelper.metrics_for_message('RabbitMQ', "#{@channel.connection.host}:#{@channel.connection.port}", 'Produce')
43
- TingYun::Agent::MethodTracerHelpers.trace_execution_scoped(summary_metrics.unshift(metric_name), {}, nil, metric_name) do
42
+ TingYun::Agent::MethodTracerHelpers.trace_execution_scoped(summary_metrics.unshift(metric_name), {}, nil, "Bunny/Exchange") do
44
43
  opts[:headers] = {} unless opts[:headers]
45
- opts[:headers]["TingyunID"] = create_tingyun_id("mq") if TingYun::Agent.config[:'nbs.transaction_tracer.enabled']
46
- TingYun::Agent.record_metric("#{metric_name}%2FByte",payload.bytesize) if payload
44
+ opts[:headers]["X-Tingyun"] = create_tingyun_id if TingYun::Agent.config[:'nbs.transaction_tracer.enabled']
45
+ state.add_current_node_paramsV3(:vendor => "RabbitMQ")
46
+ state.add_current_node_paramsV3(:instance => "#{@channel.connection.host}:#{@channel.connection.port}")
47
+ state.add_current_node_paramsV3(:operation => "#{queue_name} #{self.name}",:key=> self.name)
48
+ state.add_current_node_params(:type => 'MQP',:method=>"publish")
49
+ # TingYun::Agent.record_metric("#{metric_name}/Byte",payload.bytesize) if payload
47
50
  publish_without_tingyun(payload, opts)
48
51
  end
49
52
  rescue => e
@@ -66,43 +69,46 @@ TingYun::Support::LibraryDetection.defer do
66
69
  if public_method_defined?(:call)
67
70
 
68
71
  def call_with_tingyun(*args)
69
- return call_without_tingyun(*args) unless TingYun::Agent.config[:'nbs.mq.enabled']
72
+ return call_without_tingyun(*args) unless TingYun::Agent.config[:'mq.enabled']
70
73
  begin
71
74
 
72
75
  headers = args[1][:headers].clone rescue {}
73
76
 
74
77
 
75
- tingyun_id_secret = headers["TingyunID"]
78
+ tingyun_id_secret = headers["X-Tingyun"]
76
79
 
77
80
  state = TingYun::Agent::TransactionState.tl_get
78
81
 
79
82
  if queue_name.start_with?("amq.")
80
- metric_name = "#{@channel.connection.host}:#{@channel.connection.port}%2FQueue%2FTemp/Consume"
81
- transaction_name = "WebAction/RabbitMQ/Queue%2FTemp"
83
+ metric_name = "#{@channel.connection.host}:#{@channel.connection.port}/Queue/Temp/Consume"
84
+ transaction_name = "RabbitMQ/Queue/FTemp"
82
85
  elsif queue_name.include?(".")
83
- metric_name = "#{@channel.connection.host}:#{@channel.connection.port}%2FTopic%2F#{queue_name}/Consume"
84
- transaction_name = "WebAction/RabbitMQ/Topic%2F#{queue_name}"
86
+ metric_name = "#{@channel.connection.host}:#{@channel.connection.port}/Topic/#{queue_name}/Consume"
87
+ transaction_name = "RabbitMQ/Topic/#{queue_name}"
85
88
  else
86
- metric_name = "#{@channel.connection.host}:#{@channel.connection.port}%2FQueue%2F#{queue_name}/Consume"
87
- transaction_name = "WebAction/RabbitMQ/Queue%2F#{queue_name}"
89
+ metric_name = "#{@channel.connection.host}:#{@channel.connection.port}/Queue/#{queue_name}/Consume"
90
+ transaction_name = "RabbitMQ/Queue/#{queue_name}"
88
91
  end
89
92
 
90
93
  state.save_referring_transaction_info(tingyun_id_secret.split(';')) if cross_app_enabled?(tingyun_id_secret)
91
94
 
92
95
  summary_metrics = TingYun::Instrumentation::Support::ExternalHelper.metrics_for_message('RabbitMQ', "#{@channel.connection.host}:#{@channel.connection.port}", 'Consume')
93
-
94
96
  TingYun::Agent::Transaction.wrap(state, "Message RabbitMQ/#{metric_name}" , :message, {:mq=> true}, summary_metrics) do
95
- TingYun::Agent::Transaction.set_frozen_transaction_name!(transaction_name)
96
- TingYun::Agent.record_metric("Message RabbitMQ/#{metric_name}%2FByte",args[2].bytesize) if args[2]
97
- TingYun::Agent.record_metric("Message RabbitMQ/#{metric_name}%2FWait", TingYun::Helper.time_to_millis(Time.now)-state.externel_time.to_i) rescue 0
98
- state.add_custom_params("message.byte",args[2].bytesize)
99
- state.add_custom_params("message.wait",TingYun::Helper.time_to_millis(Time.now)-state.externel_time.to_i)
97
+ TingYun::Agent::Transaction.set_frozen_transaction_name!("#{state.action_type}/#{transaction_name}")
98
+ # TingYun::Agent.record_metric("Message RabbitMQ/#{metric_name}/Byte",args[2].bytesize) if args[2]
99
+ # TingYun::Agent.record_metric("Message RabbitMQ/#{metric_name}Wait", TingYun::Helper.time_to_millis(Time.now)-state.externel_time.to_i) rescue 0
100
100
  state.add_custom_params("message.routingkey",queue_name)
101
+ state.add_current_node_params(:type => 'MQC',:method=>"call",:klass=> "Bunny/Consumer")
101
102
  state.current_transaction.attributes.add_agent_attribute(:tx_id, state.client_transaction_id)
102
- headers.delete("TingyunID")
103
+ headers.delete("X-Tingyun")
103
104
  state.merge_request_parameters(headers)
104
105
  call_without_tingyun(*args)
105
- state.current_transaction.attributes.add_agent_attribute(:entryTrace, build_payload(state)) if state.same_account? && TingYun::Agent.config[:'nbs.transaction_tracer.enabled']
106
+ tx_data = build_payload(state)
107
+ state.current_transaction.attributes.add_agent_attribute(:entryTrace,tx_data) if TingYun::Agent.config[:'nbs.transaction_tracer.enabled']
108
+ state.add_current_node_paramsV3(:vendor => "RabbitMQ",:key => queue_name)
109
+ state.add_current_node_paramsV3(:txData => TingYun::Support::Serialize::JSONWrapper.dump(tx_data))
110
+ state.add_current_node_paramsV3(:instance => "#{@channel.connection.host}:#{@channel.connection.port}")
111
+ state.add_current_node_paramsV3(:operation => "#{queue_name}",:bytes =>args[2].bytesize,:async_wait=>TingYun::Helper.time_to_millis(Time.now)-state.externel_time.to_i)
106
112
  end
107
113
  rescue => e
108
114
  TingYun::Agent.logger.error("Failed to Bunny call_with_tingyun : ", e)
@@ -116,26 +122,20 @@ TingYun::Support::LibraryDetection.defer do
116
122
  end
117
123
 
118
124
  def cross_app_enabled?(tingyun_id_secret)
119
- tingyun_id_secret && ::TingYun::Agent.config[:tingyunIdSecret] && TingYun::Agent.config[:'nbs.transaction_tracer.enabled']
125
+ tingyun_id_secret && ::TingYun::Agent.config[:idSecret] && TingYun::Agent.config[:'nbs.transaction_tracer.enabled']
120
126
  end
121
127
 
122
128
  def build_payload(state)
123
129
  timings = state.timings
130
+
124
131
  payload = {
125
- :applicationId => state.client_tingyun_id_secret.split('|')[1],
126
- :transactionId => state.client_transaction_id,
127
- :externalId => state.extenel_req_id,
128
- :time => {
129
- :duration => timings.app_time_in_millis,
130
- :qu => timings.queue_time_in_millis,
131
- :db => timings.sql_duration,
132
- :ex => timings.external_duration,
133
- :rds => timings.rds_duration,
134
- :mc => timings.mc_duration,
135
- :mon => timings.mon_duration,
136
- :code => timings.app_execute_duration
137
- }
132
+ :id => TingYun::Agent.config[:idSecret],
133
+ :tname => state.transaction_name,
134
+ :tid => state.current_transaction.guid,
135
+ :rid => state.trace_id,
136
+ :duration => timings.app_time_in_millis
138
137
  }
138
+
139
139
  payload
140
140
  end
141
141
  end
@@ -143,19 +143,23 @@ TingYun::Support::LibraryDetection.defer do
143
143
  ::Bunny::Channel.class_eval do
144
144
  if public_method_defined?(:basic_get)
145
145
  def basic_get_with_tingyun(*args)
146
- return basic_get_without_tingyun(*args) unless TingYun::Agent.config[:'nbs.mq.enabled']
146
+ return basic_get_without_tingyun(*args) unless TingYun::Agent.config[:'mq.enabled']
147
147
  begin
148
148
  state = TingYun::Agent::TransactionState.tl_get
149
- metric_name = "#{@connection.host}:#{@connection.port}%2FQueue%2F#{args[0]}/Consume"
149
+ metric_name = "#{@connection.host}:#{@connection.port}/Queue/#{args[0]}/Consume"
150
150
  summary_metrics = TingYun::Instrumentation::Support::ExternalHelper.metrics_for_message('RabbitMQ', "#{connection.host}:#{connection.port}", 'Consume')
151
- TingYun::Agent::MethodTracerHelpers.trace_execution_scoped(summary_metrics, {}, nil, "Message RabbitMQ/#{metric_name}") do
151
+ TingYun::Agent::MethodTracerHelpers.trace_execution_scoped(summary_metrics, {}, nil, "Bunny/Channel") do
152
152
  basic_get_without_tingyun(*args)
153
+ state.add_current_node_paramsV3(:vendor => "RabbitMQ")
154
+ state.add_current_node_paramsV3(:instance => "#{@connection.host}:#{@connection.port}")
155
+ state.add_current_node_paramsV3(:operation => "#{args[0]}")
156
+ state.add_current_node_params(:type => 'MQC',:method=>"basic_get")
153
157
  end
154
158
  rescue =>e
155
159
  TingYun::Agent.logger.error("Failed to Bunny basic_get_with_tingyun : ", e)
156
160
  basic_get_without_tingyun(*args)
157
- ensure
158
- TingYun::Agent::Transaction.stop(state, Time.now.to_f, summary_metrics)
161
+ # ensure
162
+ # TingYun::Agent::Transaction.stop(state, Time.now.to_f, summary_metrics)
159
163
  end
160
164
  end
161
165
 
@@ -24,8 +24,10 @@ TingYun::Support::LibraryDetection.defer do
24
24
  self.namespace.to_s.sub(%r{\A/}, ''), # removing leading slashes
25
25
  self.options[:path].first.to_s.sub(%r{\A/}, ''),
26
26
  ].compact.select{ |n| n.to_s unless n.to_s.empty? }.join("/")
27
- TingYun::Agent::Transaction.set_default_transaction_name(name, :controller)
28
- run_without_tingyun(*args)
27
+ state = TingYun::Agent::TransactionState.tl_get
28
+ TingYun::Agent::Transaction.wrap(state,name,:controller,) do
29
+ run_without_tingyun(*args)
30
+ end
29
31
  rescue => e
30
32
  TingYun::Agent.logger.info("Error getting Grape Endpoint Name. Error: #{e.message}. Options: #{self.options.inspect}")
31
33
  TingYun::Agent.notice_error(e,:type=>:exception)
@@ -41,7 +41,7 @@ TingYun::Support::LibraryDetection.defer do
41
41
  args[1] = (::Module.private_method_defined? :to_resource_url) ? to_resource_url(args[1]) : urify(args[1])
42
42
  proxy = no_proxy?(args[1]) ? nil : @proxy
43
43
  tingyun_request = TingYun::Http::HttpClientRequest.new(proxy, *args, &block)
44
- ::TingYun::Instrumentation::Support::ExternalError.handle_error(e, "External/#{tingyun_request.uri.to_s.gsub(/\/\z/,'').gsub('/','%2F')}/#{tingyun_request.from}")
44
+ ::TingYun::Instrumentation::Support::ExternalError.handle_error(e, "External/#{tingyun_request.uri.to_s.gsub(/\/\z/,'')}/#{tingyun_request.from}")
45
45
  raise e
46
46
  end
47
47
  end
@@ -65,10 +65,10 @@ TingYun::Support::LibraryDetection.defer do
65
65
  begin
66
66
  state = TingYun::Agent::TransactionState.tl_get
67
67
  ip_and_hosts = @seed_brokers.map{|a| [a.host, a.port].join(':')}.join(',') rescue TingYun::Instrumentation::Kafka::UNKNOWN
68
- metric_name = "Message Kafka/#{ip_and_hosts}%2FTopic%2F#{options[:topic]}/Produce"
68
+ metric_name = "Message Kafka/#{ip_and_hosts}/Topic/#{options[:topic]}/Produce"
69
69
  summary_metrics = TingYun::Agent::Datastore::MetricHelper.metrics_for_message('Kafka', ip_and_hosts, 'Produce')
70
70
  TingYun::Agent::Transaction.wrap(state, metric_name, :Kafka, {}, summary_metrics) do
71
- TingYun::Agent.record_metric("#{metric_name}%2FByte", args[0].bytesize) if args[0]
71
+ # TingYun::Agent.record_metric("#{metric_name}%2FByte", args[0].bytesize) if args[0]
72
72
  deliver_message_without_tingyun(*args, **options, &block)
73
73
  end
74
74
  rescue => e
@@ -87,11 +87,12 @@ TingYun::Support::LibraryDetection.defer do
87
87
  state = TingYun::Agent::TransactionState.tl_get
88
88
  state.reset
89
89
  ip_and_hosts = @seed_brokers.map{|a| [a.host, a.port].join(':')}.join(',') rescue TingYun::Instrumentation::Kafka::UNKNOWN
90
- metric_name = "#{ip_and_hosts}%2FTopic%2F#{message.topic}/Consume"
90
+ metric_name = "#{ip_and_hosts}/Topic/#{message.topic}/Consume"
91
91
  summary_metrics = TingYun::Agent::Datastore::MetricHelper.metrics_for_message('Kafka', ip_and_hosts, 'Consume')
92
- TingYun::Agent::Transaction.start(state,:message, {:transaction_name => "WebAction/Kafka/Topic%2F#{message.topic}/Consume"})
92
+ TingYun::Agent::Transaction.start(state,:message, {:transaction_name =>
93
+ "WebAction/Kafka/Topic/#{message.topic}/Consume"})
93
94
  TingYun::Agent::Transaction.wrap(state, "Message Kafka/#{metric_name}" , :Kafka, {}, summary_metrics) do
94
- TingYun::Agent.record_metric("Message Kafka/#{metric_name}%2FByte",message.value.bytesize) if message.value
95
+ # TingYun::Agent.record_metric("Message Kafka/#{metric_name}%2FByte",message.value.bytesize) if message.value
95
96
  block.call(message)
96
97
  end
97
98
  rescue => e
@@ -116,11 +117,12 @@ TingYun::Support::LibraryDetection.defer do
116
117
  state = TingYun::Agent::TransactionState.tl_get
117
118
  state.reset
118
119
  ip_and_hosts = self.cluster.seed_brokers.map{|a| [a.host, a.port].join(':')}.join(',') rescue TingYun::Instrumentation::Kafka::UNKNOWN
119
- metric_name = "#{ip_and_hosts}%2FTopic%2F#{message.topic}/Consume"
120
+ metric_name = "#{ip_and_hosts}/Topic/#{message.topic}/Consume"
120
121
  summary_metrics = TingYun::Agent::Datastore::MetricHelper.metrics_for_message('Kafka', ip_and_hosts, 'Consume')
121
- TingYun::Agent::Transaction.start(state,:message, {:transaction_name => "WebAction/Kafka/Topic%2F#{message.topic}/Consume"})
122
+ TingYun::Agent::Transaction.start(state,:message, {:transaction_name =>
123
+ "WebAction/Kafka/Topic/#{message.topic}/Consume"})
122
124
  TingYun::Agent::Transaction.wrap(state, "Message Kafka/#{metric_name}" , :Kafka, {}, summary_metrics) do
123
- TingYun::Agent.record_metric("Message Kafka/#{metric_name}%2FByte", message.value.bytesize) if message.value
125
+ # TingYun::Agent.record_metric("Message Kafka/#{metric_name}%2FByte", message.value.bytesize) if message.value
124
126
  block.call(message)
125
127
  end
126
128
  rescue => e
@@ -146,12 +148,13 @@ TingYun::Support::LibraryDetection.defer do
146
148
  state = TingYun::Agent::TransactionState.tl_get
147
149
  state.reset
148
150
  ip_and_hosts = self.cluster.seed_brokers.map{|a| [a.host, a.port].join(':')}.join(',') rescue TingYun::Instrumentation::Kafka::UNKNOWN
149
- metric_name = "#{ip_and_hosts}%2FTopic%2F#{batch.topic}/Consume"
151
+ metric_name = "#{ip_and_hosts}/Topic/#{batch.topic}/Consume"
150
152
  summary_metrics = TingYun::Agent::Datastore::MetricHelper.metrics_for_message('Kafka', ip_and_hosts, 'Consume')
151
- TingYun::Agent::Transaction.start(state,:message, {:transaction_name => "WebAction/Kafka/Topic%2F#{message.topic}/Consume"})
153
+ TingYun::Agent::Transaction.start(state,:message, {:transaction_name =>
154
+ "WebAction/Kafka/Topic/#{message.topic}/Consume"})
152
155
  TingYun::Agent::Transaction.wrap(state, "Message Kafka/#{metric_name}" , :Kafka, {}, summary_metrics) do
153
156
  bytesize = batch.messages.reduce(0){ |res, msg| res += (msg.value ? msg.value.bytesize : 0)}
154
- TingYun::Agent.record_metric("Message Kafka/#{metric_name}%2FByte", bytesize) if bytesize.to_i > 0
157
+ # TingYun::Agent.record_metric("Message Kafka/#{metric_name}%2FByte", bytesize) if bytesize.to_i > 0
155
158
  block.call(batch)
156
159
  end
157
160
  rescue => e
@@ -178,10 +181,10 @@ TingYun::Support::LibraryDetection.defer do
178
181
  state = TingYun::Agent::TransactionState.tl_get
179
182
  return produce_without_tingyun(*args, **options, &block) unless state.current_transaction
180
183
  ip_and_hosts = @cluster.seed_brokers.map{|a| [a.host, a.port].join(':')}.join(',') rescue TingYun::Instrumentation::Kafka::UNKNOWN
181
- metric_name = "Message Kafka/#{ip_and_hosts}%2FTopic%2F#{options[:topic]}/Produce"
184
+ metric_name = "Message Kafka/#{ip_and_hosts}/Topic/#{options[:topic]}/Produce"
182
185
  summary_metrics = TingYun::Agent::Datastore::MetricHelper.metrics_for_message('Kafka', ip_and_hosts, 'Produce')
183
186
  TingYun::Agent::Transaction.wrap(state, metric_name, :Kafka, {}, summary_metrics) do
184
- TingYun::Agent.record_metric("#{metric_name}%2FByte",args[0].bytesize) if args[0]
187
+ # TingYun::Agent.record_metric("#{metric_name}%2FByte",args[0].bytesize) if args[0]
185
188
  produce_without_tingyun(*args, **options, &block)
186
189
  end
187
190
  rescue => e
@@ -200,10 +203,10 @@ TingYun::Support::LibraryDetection.defer do
200
203
  begin
201
204
  state = TingYun::Agent::TransactionState.tl_get
202
205
  ip_and_hosts = @worker.producer.cluster.seed_brokers.map{|a| [a.host, a.port].join(':')}.join(',') rescue TingYun::Instrumentation::Kafka::UNKNOWN
203
- metric_name = "Message Kafka/#{ip_and_hosts}%2FTopic%2F#{options[:topic]}/Produce"
206
+ metric_name = "Message Kafka/#{ip_and_hosts}/Topic/#{options[:topic]}/Produce"
204
207
  summary_metrics = TingYun::Agent::Datastore::MetricHelper.metrics_for_message('Kafka', ip_and_hosts, 'Produce')
205
208
  TingYun::Agent::Transaction.wrap(state, metric_name, :Kafka, {}, summary_metrics) do
206
- TingYun::Agent.record_metric("#{metric_name}%2FByte",args[0].bytesize) if args[0]
209
+ # TingYun::Agent.record_metric("#{metric_name}%2FByte",args[0].bytesize) if args[0]
207
210
  produce_without_tingyun(*args, **options, &block)
208
211
  end
209
212
  rescue => e