newrelic_rpm 9.2.2 → 9.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/.build_ignore +26 -0
  3. data/CHANGELOG.md +168 -0
  4. data/README.md +8 -4
  5. data/lib/new_relic/agent/attribute_pre_filtering.rb +109 -0
  6. data/lib/new_relic/agent/configuration/default_source.rb +176 -32
  7. data/lib/new_relic/agent/configuration/environment_source.rb +1 -1
  8. data/lib/new_relic/agent/configuration/manager.rb +3 -2
  9. data/lib/new_relic/agent/configuration/yaml_source.rb +13 -0
  10. data/lib/new_relic/agent/distributed_tracing.rb +1 -1
  11. data/lib/new_relic/agent/instrumentation/action_controller_other_subscriber.rb +1 -1
  12. data/lib/new_relic/agent/instrumentation/active_record.rb +1 -1
  13. data/lib/new_relic/agent/instrumentation/active_record_notifications.rb +2 -1
  14. data/lib/new_relic/agent/instrumentation/active_support_logger/instrumentation.rb +4 -0
  15. data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +9 -0
  16. data/lib/new_relic/agent/instrumentation/concurrent_ruby/chain.rb +1 -1
  17. data/lib/new_relic/agent/instrumentation/concurrent_ruby/instrumentation.rb +3 -4
  18. data/lib/new_relic/agent/instrumentation/concurrent_ruby/prepend.rb +1 -1
  19. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +1 -2
  20. data/lib/new_relic/agent/instrumentation/curb/instrumentation.rb +4 -0
  21. data/lib/new_relic/agent/instrumentation/delayed_job/instrumentation.rb +3 -0
  22. data/lib/new_relic/agent/instrumentation/elasticsearch/instrumentation.rb +4 -1
  23. data/lib/new_relic/agent/instrumentation/excon/middleware.rb +3 -0
  24. data/lib/new_relic/agent/instrumentation/fiber/chain.rb +10 -3
  25. data/lib/new_relic/agent/instrumentation/fiber/instrumentation.rb +1 -2
  26. data/lib/new_relic/agent/instrumentation/fiber/prepend.rb +10 -3
  27. data/lib/new_relic/agent/instrumentation/grape/instrumentation.rb +4 -0
  28. data/lib/new_relic/agent/instrumentation/grpc/client/instrumentation.rb +4 -0
  29. data/lib/new_relic/agent/instrumentation/grpc/server/instrumentation.rb +4 -0
  30. data/lib/new_relic/agent/instrumentation/grpc_client.rb +1 -1
  31. data/lib/new_relic/agent/instrumentation/grpc_server.rb +1 -1
  32. data/lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb +4 -0
  33. data/lib/new_relic/agent/instrumentation/httprb/instrumentation.rb +4 -0
  34. data/lib/new_relic/agent/instrumentation/logger/instrumentation.rb +3 -0
  35. data/lib/new_relic/agent/instrumentation/memcache/instrumentation.rb +12 -3
  36. data/lib/new_relic/agent/instrumentation/memcache.rb +2 -2
  37. data/lib/new_relic/agent/instrumentation/net_http/instrumentation.rb +4 -0
  38. data/lib/new_relic/agent/instrumentation/notifications_subscriber.rb +4 -0
  39. data/lib/new_relic/agent/instrumentation/padrino/instrumentation.rb +4 -0
  40. data/lib/new_relic/agent/instrumentation/queue_time.rb +1 -1
  41. data/lib/new_relic/agent/instrumentation/rack/instrumentation.rb +6 -0
  42. data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +4 -0
  43. data/lib/new_relic/agent/instrumentation/rails_notifications/action_cable.rb +1 -1
  44. data/lib/new_relic/agent/instrumentation/rake/instrumentation.rb +4 -0
  45. data/lib/new_relic/agent/instrumentation/redis/instrumentation.rb +4 -0
  46. data/lib/new_relic/agent/instrumentation/resque/instrumentation.rb +4 -0
  47. data/lib/new_relic/agent/instrumentation/roda/chain.rb +43 -0
  48. data/lib/new_relic/agent/instrumentation/roda/instrumentation.rb +56 -0
  49. data/lib/new_relic/agent/instrumentation/roda/prepend.rb +24 -0
  50. data/lib/new_relic/agent/instrumentation/roda/roda_transaction_namer.rb +30 -0
  51. data/lib/new_relic/agent/instrumentation/roda.rb +34 -0
  52. data/lib/new_relic/agent/instrumentation/sequel.rb +1 -1
  53. data/lib/new_relic/agent/instrumentation/sidekiq/client.rb +4 -0
  54. data/lib/new_relic/agent/instrumentation/sidekiq/server.rb +26 -3
  55. data/lib/new_relic/agent/instrumentation/sidekiq.rb +2 -2
  56. data/lib/new_relic/agent/instrumentation/sinatra/instrumentation.rb +4 -0
  57. data/lib/new_relic/agent/instrumentation/stripe.rb +28 -0
  58. data/lib/new_relic/agent/instrumentation/stripe_subscriber.rb +77 -0
  59. data/lib/new_relic/agent/instrumentation/thread/chain.rb +1 -1
  60. data/lib/new_relic/agent/instrumentation/thread/instrumentation.rb +0 -1
  61. data/lib/new_relic/agent/instrumentation/thread/prepend.rb +1 -1
  62. data/lib/new_relic/agent/instrumentation/tilt/instrumentation.rb +4 -0
  63. data/lib/new_relic/agent/instrumentation/typhoeus/instrumentation.rb +5 -1
  64. data/lib/new_relic/agent/log_event_aggregator.rb +49 -2
  65. data/lib/new_relic/agent/log_event_attributes.rb +115 -0
  66. data/lib/new_relic/agent/logging.rb +4 -4
  67. data/lib/new_relic/agent/method_tracer_helpers.rb +26 -5
  68. data/lib/new_relic/agent/new_relic_service.rb +33 -17
  69. data/lib/new_relic/agent/pipe_service.rb +1 -1
  70. data/lib/new_relic/agent/tracer.rb +6 -5
  71. data/lib/new_relic/agent/transaction/abstract_segment.rb +52 -0
  72. data/lib/new_relic/agent/transaction/request_attributes.rb +45 -7
  73. data/lib/new_relic/agent/transaction.rb +5 -4
  74. data/lib/new_relic/agent/utilization/vendor.rb +5 -7
  75. data/lib/new_relic/agent.rb +50 -1
  76. data/lib/new_relic/cli/command.rb +1 -0
  77. data/lib/new_relic/control/class_methods.rb +1 -7
  78. data/lib/new_relic/control/frameworks/roda.rb +20 -0
  79. data/lib/new_relic/dependency_detection.rb +6 -0
  80. data/lib/new_relic/language_support.rb +5 -0
  81. data/lib/new_relic/latest_changes.rb +1 -1
  82. data/lib/new_relic/noticed_error.rb +5 -2
  83. data/lib/new_relic/rack/agent_hooks.rb +1 -1
  84. data/lib/new_relic/rack/agent_middleware.rb +0 -16
  85. data/lib/new_relic/rack/browser_monitoring.rb +1 -1
  86. data/lib/new_relic/supportability_helper.rb +2 -0
  87. data/lib/new_relic/traced_thread.rb +2 -3
  88. data/lib/new_relic/version.rb +2 -2
  89. data/lib/sequel/extensions/new_relic_instrumentation.rb +1 -1
  90. data/lib/tasks/bump_version.rake +21 -0
  91. data/lib/tasks/config.rake +3 -2
  92. data/lib/tasks/helpers/config.html.erb +93 -0
  93. data/lib/tasks/helpers/format.rb +11 -7
  94. data/lib/tasks/helpers/newrelicyml.rb +144 -0
  95. data/lib/tasks/helpers/version_bump.rb +62 -0
  96. data/lib/tasks/newrelicyml.rake +13 -0
  97. data/newrelic.yml +362 -265
  98. data/newrelic_rpm.gemspec +11 -7
  99. metadata +36 -25
  100. data/.gitignore +0 -43
  101. data/.project +0 -23
  102. data/.rubocop.yml +0 -1845
  103. data/.rubocop_todo.yml +0 -61
  104. data/.simplecov +0 -16
  105. data/.snyk +0 -11
  106. data/.yardopts +0 -27
  107. data/Brewfile +0 -13
  108. data/DOCKER.md +0 -167
  109. data/Dockerfile +0 -10
  110. data/Guardfile +0 -27
  111. data/config/database.yml +0 -5
  112. data/config.dot +0 -278
  113. data/docker-compose.yml +0 -107
  114. data/lefthook.yml +0 -9
  115. data/lib/tasks/helpers/removers.rb +0 -33
  116. data/lib/tasks/multiverse.rake +0 -6
  117. data/lib/tasks/multiverse.rb +0 -84
@@ -10,7 +10,7 @@ module NewRelic::Agent::Instrumentation
10
10
  def post(*args, &task)
11
11
  return super(*args, &task) unless NewRelic::Agent::Tracer.tracing_enabled?
12
12
 
13
- traced_task = add_task_tracing(*args, &task)
13
+ traced_task = add_task_tracing(&task)
14
14
  super(*args, &traced_task)
15
15
  end
16
16
  end
@@ -41,8 +41,6 @@ module NewRelic
41
41
  clazz.extend(ClassMethodsShim)
42
42
  end
43
43
 
44
- def new_relic_trace_controller_action(*args); yield; end
45
-
46
44
  def perform_action_with_newrelic_trace(*args); yield; end
47
45
  end
48
46
 
@@ -245,6 +243,7 @@ module NewRelic
245
243
  when :background then ::NewRelic::Agent::Transaction::TASK_PREFIX
246
244
  when :rack then ::NewRelic::Agent::Transaction::RACK_PREFIX
247
245
  when :uri then ::NewRelic::Agent::Transaction::CONTROLLER_PREFIX
246
+ when :roda then ::NewRelic::Agent::Transaction::RODA_PREFIX
248
247
  when :sinatra then ::NewRelic::Agent::Transaction::SINATRA_PREFIX
249
248
  when :middleware then ::NewRelic::Agent::Transaction::MIDDLEWARE_PREFIX
250
249
  when :grape then ::NewRelic::Agent::Transaction::GRAPE_PREFIX
@@ -68,6 +68,8 @@ module NewRelic
68
68
  module Multi
69
69
  include NewRelic::Agent::MethodTracer
70
70
 
71
+ INSTRUMENTATION_NAME = 'Curb'
72
+
71
73
  # Add CAT with callbacks if the request is serial
72
74
  def add_with_tracing(curl)
73
75
  if curl.respond_to?(:_nr_serial) && curl._nr_serial
@@ -81,6 +83,8 @@ module NewRelic
81
83
  def perform_with_tracing
82
84
  return yield if first_request_is_serial?
83
85
 
86
+ NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
87
+
84
88
  trace_execution_scoped('External/Multiple/Curb::Multi/perform') do
85
89
  yield
86
90
  end
@@ -31,8 +31,11 @@ module NewRelic
31
31
  include NewRelic::Agent::Instrumentation::ControllerInstrumentation
32
32
 
33
33
  NR_TRANSACTION_CATEGORY = 'OtherTransaction/DelayedJob'.freeze
34
+ INSTRUMENTATION_NAME = 'DelayedJob'
34
35
 
35
36
  def invoke_job_with_tracing
37
+ NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
38
+
36
39
  options = {
37
40
  :category => NR_TRANSACTION_CATEGORY,
38
41
  :path => ::NewRelic::Agent::Instrumentation::DelayedJob::Naming.name_from_payload(payload_object)
@@ -8,15 +8,18 @@ module NewRelic::Agent::Instrumentation
8
8
  module Elasticsearch
9
9
  PRODUCT_NAME = 'Elasticsearch'
10
10
  OPERATION = 'perform_request'
11
+ INSTRUMENTATION_NAME = NewRelic::Agent.base_name(name)
11
12
 
12
13
  def perform_request_with_tracing(method, path, params = {}, body = nil, headers = nil)
13
14
  return yield unless NewRelic::Agent::Tracer.tracing_enabled?
14
15
 
16
+ NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
17
+
15
18
  segment = NewRelic::Agent::Tracer.start_datastore_segment(
16
19
  product: PRODUCT_NAME,
17
20
  operation: nr_operation || OPERATION,
18
21
  host: nr_hosts[:host],
19
- port_path_or_id: path,
22
+ port_path_or_id: nr_hosts[:port],
20
23
  database_name: nr_cluster_name
21
24
  )
22
25
  begin
@@ -6,6 +6,7 @@ module ::Excon
6
6
  module Middleware
7
7
  class NewRelicCrossAppTracing
8
8
  TRACE_DATA_IVAR = :@newrelic_trace_data
9
+ INSTRUMENTATION_NAME = 'Excon'
9
10
 
10
11
  def initialize(stack)
11
12
  @stack = stack
@@ -18,6 +19,8 @@ module ::Excon
18
19
  # :idempotent in the options, but there will be only a single
19
20
  # accompanying response_call/error_call.
20
21
  if datum[:connection] && !datum[:connection].instance_variable_get(TRACE_DATA_IVAR)
22
+ NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
23
+
21
24
  wrapped_request = ::NewRelic::Agent::HTTPClients::ExconHTTPRequest.new(datum)
22
25
  segment = NewRelic::Agent::Tracer.start_external_request_segment(
23
26
  library: wrapped_request.type,
@@ -10,9 +10,16 @@ module NewRelic::Agent::Instrumentation
10
10
 
11
11
  alias_method(:initialize_without_new_relic, :initialize)
12
12
 
13
- def initialize(*args, &block)
14
- traced_block = add_thread_tracing(*args, &block)
15
- initialize_with_newrelic_tracing { initialize_without_new_relic(*args, &traced_block) }
13
+ if RUBY_VERSION < '2.7.0'
14
+ def initialize(*_args, &block)
15
+ traced_block = add_thread_tracing(&block)
16
+ initialize_with_newrelic_tracing { initialize_without_new_relic(&traced_block) }
17
+ end
18
+ else
19
+ def initialize(**kwargs, &block)
20
+ traced_block = add_thread_tracing(&block)
21
+ initialize_with_newrelic_tracing { initialize_without_new_relic(**kwargs, &traced_block) }
22
+ end
16
23
  end
17
24
  end
18
25
  end
@@ -11,11 +11,10 @@ module NewRelic::Agent::Instrumentation
11
11
  yield
12
12
  end
13
13
 
14
- def add_thread_tracing(*args, &block)
14
+ def add_thread_tracing(&block)
15
15
  return block if !NewRelic::Agent::Tracer.thread_tracing_enabled?
16
16
 
17
17
  NewRelic::Agent::Tracer.thread_block_with_current_transaction(
18
- *args,
19
18
  segment_name: 'Ruby/Fiber',
20
19
  &block
21
20
  )
@@ -9,9 +9,16 @@ module NewRelic::Agent::Instrumentation
9
9
  module Prepend
10
10
  include NewRelic::Agent::Instrumentation::MonitoredFiber
11
11
 
12
- def initialize(*args, &block)
13
- traced_block = add_thread_tracing(*args, &block)
14
- initialize_with_newrelic_tracing { super(*args, &traced_block) }
12
+ if RUBY_VERSION < '2.7.0'
13
+ def initialize(*_args, &block)
14
+ traced_block = add_thread_tracing(&block)
15
+ initialize_with_newrelic_tracing { super(&traced_block) }
16
+ end
17
+ else
18
+ def initialize(**kawrgs, &block)
19
+ traced_block = add_thread_tracing(&block)
20
+ initialize_with_newrelic_tracing { super(**kawrgs, &traced_block) }
21
+ end
15
22
  end
16
23
  end
17
24
  end
@@ -9,6 +9,8 @@ module NewRelic::Agent::Instrumentation
9
9
  module Instrumentation
10
10
  extend self
11
11
 
12
+ INSTRUMENTATION_NAME = NewRelic::Agent.base_name(name)
13
+
12
14
  # Since 1.2.0, the class `Grape::API` no longer refers to an API instance, rather, what used to be `Grape::API` is `Grape::API::Instance`
13
15
  # https://github.com/ruby-grape/grape/blob/c20a73ac1e3f3ba1082005ed61bf69452373ba87/UPGRADING.md#upgrading-to--120
14
16
  def instrumented_class
@@ -46,6 +48,8 @@ module NewRelic::Agent::Instrumentation
46
48
  def handle_transaction(endpoint, class_name, version)
47
49
  return unless endpoint && route = endpoint.route
48
50
 
51
+ NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
52
+
49
53
  name_transaction(route, class_name, version)
50
54
  capture_params(endpoint)
51
55
  end
@@ -12,10 +12,14 @@ module NewRelic
12
12
  module Client
13
13
  include NewRelic::Agent::Instrumentation::GRPC::Helper
14
14
 
15
+ INSTRUMENTATION_NAME = 'gRPC_Client'
16
+
15
17
  def issue_request_with_tracing(grpc_type, method, requests, marshal, unmarshal,
16
18
  deadline:, return_op:, parent:, credentials:, metadata:)
17
19
  return yield unless trace_with_newrelic?
18
20
 
21
+ NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
22
+
19
23
  segment = request_segment(method)
20
24
  request_wrapper = NewRelic::Agent::Instrumentation::GRPC::Client::RequestWrapper.new(@host)
21
25
  # do not insert CAT headers for gRPC requests https://github.com/newrelic/newrelic-ruby-agent/issues/1730
@@ -11,6 +11,8 @@ module NewRelic
11
11
  module Server
12
12
  include NewRelic::Agent::Instrumentation::GRPC::Helper
13
13
 
14
+ INSTRUMENTATION_NAME = 'gRPC_Server'
15
+
14
16
  DT_KEYS = [NewRelic::NEWRELIC_KEY, NewRelic::TRACEPARENT_KEY, NewRelic::TRACESTATE_KEY].freeze
15
17
  INSTANCE_VAR_HOST = :@host_nr
16
18
  INSTANCE_VAR_PORT = :@port_nr
@@ -23,6 +25,8 @@ module NewRelic
23
25
  def handle_with_tracing(streamer_type, active_call, mth, _inter_ctx)
24
26
  return yield unless trace_with_newrelic?
25
27
 
28
+ NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
29
+
26
30
  metadata = metadata_for_call(active_call)
27
31
  txn = NewRelic::Agent::Transaction.start_new_transaction(NewRelic::Agent::Tracer.state,
28
32
  CATEGORY,
@@ -13,7 +13,7 @@ DependencyDetection.defer do
13
13
  end
14
14
 
15
15
  executes do
16
- supportability_name = 'gRPC_Client'
16
+ supportability_name = NewRelic::Agent::Instrumentation::GRPC::Client::INSTRUMENTATION_NAME
17
17
  if use_prepend?
18
18
  prepend_instrument GRPC::ClientStub, NewRelic::Agent::Instrumentation::GRPC::Client::Prepend, supportability_name
19
19
  else
@@ -14,7 +14,7 @@ DependencyDetection.defer do
14
14
  end
15
15
 
16
16
  executes do
17
- supportability_name = 'gRPC_Server'
17
+ supportability_name = NewRelic::Agent::Instrumentation::GRPC::Client::INSTRUMENTATION_NAME
18
18
  if use_prepend?
19
19
  prepend_instrument GRPC::RpcServer, NewRelic::Agent::Instrumentation::GRPC::Server::RpcServerPrepend, supportability_name
20
20
  prepend_instrument GRPC::RpcDesc, NewRelic::Agent::Instrumentation::GRPC::Server::RpcDescPrepend, supportability_name
@@ -5,7 +5,11 @@
5
5
  module NewRelic::Agent::Instrumentation
6
6
  module HTTPClient
7
7
  module Instrumentation
8
+ INSTRUMENTATION_NAME = 'HTTPClient'
9
+
8
10
  def with_tracing(request, connection)
11
+ NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
12
+
9
13
  wrapped_request = NewRelic::Agent::HTTPClients::HTTPClientRequest.new(request)
10
14
  segment = NewRelic::Agent::Tracer.start_external_request_segment(
11
15
  library: wrapped_request.type,
@@ -4,7 +4,11 @@
4
4
 
5
5
  module NewRelic::Agent::Instrumentation
6
6
  module HTTPrb
7
+ INSTRUMENTATION_NAME = NewRelic::Agent.base_name(name)
8
+
7
9
  def with_tracing(request)
10
+ NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
11
+
8
12
  wrapped_request = ::NewRelic::Agent::HTTPClients::HTTPRequest.new(request)
9
13
 
10
14
  begin
@@ -6,6 +6,8 @@ module NewRelic
6
6
  module Agent
7
7
  module Instrumentation
8
8
  module Logger
9
+ INSTRUMENTATION_NAME = 'Logger'
10
+
9
11
  def skip_instrumenting?
10
12
  defined?(@skip_instrumenting) && @skip_instrumenting
11
13
  end
@@ -51,6 +53,7 @@ module NewRelic
51
53
  mark_skip_instrumenting
52
54
 
53
55
  unless ::NewRelic::Agent.agent.nil?
56
+ ::NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
54
57
  ::NewRelic::Agent.agent.log_event_aggregator.record(formatted_message, severity)
55
58
  formatted_message = LocalLogDecorator.decorate(formatted_message)
56
59
  end
@@ -10,9 +10,12 @@ module NewRelic::Agent::Instrumentation
10
10
  LOCALHOST = 'localhost'
11
11
  MULTIGET_METRIC_NAME = 'get_multi_request'
12
12
  MEMCACHED = 'Memcached'
13
+ INSTRUMENTATION_NAME = 'Dalli'
13
14
 
14
15
  def with_newrelic_tracing(operation, *args)
15
- segment = NewRelic::Agent::Tracer.start_datastore_segment( \
16
+ NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
17
+
18
+ segment = NewRelic::Agent::Tracer.start_datastore_segment(
16
19
  product: MEMCACHED,
17
20
  operation: operation
18
21
  )
@@ -28,6 +31,8 @@ module NewRelic::Agent::Instrumentation
28
31
  end
29
32
 
30
33
  def server_for_key_with_newrelic_tracing
34
+ NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
35
+
31
36
  yield.tap do |server|
32
37
  begin
33
38
  if txn = ::NewRelic::Agent::Tracer.current_transaction
@@ -43,7 +48,9 @@ module NewRelic::Agent::Instrumentation
43
48
  end
44
49
 
45
50
  def get_multi_with_newrelic_tracing(method_name)
46
- segment = NewRelic::Agent::Tracer.start_segment( \
51
+ NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
52
+
53
+ segment = NewRelic::Agent::Tracer.start_segment(
47
54
  name: "Ruby/Memcached/Dalli/#{method_name}"
48
55
  )
49
56
 
@@ -55,7 +62,9 @@ module NewRelic::Agent::Instrumentation
55
62
  end
56
63
 
57
64
  def send_multiget_with_newrelic_tracing(keys)
58
- segment = ::NewRelic::Agent::Tracer.start_datastore_segment( \
65
+ NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
66
+
67
+ segment = ::NewRelic::Agent::Tracer.start_datastore_segment(
59
68
  product: MEMCACHED,
60
69
  operation: MULTIGET_METRIC_NAME
61
70
  )
@@ -5,8 +5,8 @@
5
5
  # NOTE: there are multiple implementations of the Memcached client in Ruby,
6
6
  # each with slightly different APIs and semantics.
7
7
  # See:
8
- # http://www.deveiate.org/code/Ruby-MemCache/ (Gem: Ruby-MemCache)
9
- # http://seattlerb.rubyforge.org/memcache-client/ (Gem: memcache-client)
8
+ # https://rubygems.org/gems/Ruby-MemCache (Gem: Ruby-MemCache)
9
+ # https://github.com/mperham/memcache-client (Gem: memcache-client)
10
10
  # https://github.com/mperham/dalli (Gem: dalli)
11
11
 
12
12
  require_relative 'memcache/helper'
@@ -6,7 +6,11 @@ module NewRelic
6
6
  module Agent
7
7
  module Instrumentation
8
8
  module NetHTTP
9
+ INSTRUMENTATION_NAME = NewRelic::Agent.base_name(name)
10
+
9
11
  def request_with_tracing(request)
12
+ NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
13
+
10
14
  wrapped_request = NewRelic::Agent::HTTPClients::NetHTTPRequest.new(self, request)
11
15
 
12
16
  segment = NewRelic::Agent::Tracer.start_external_request_segment(
@@ -47,6 +47,10 @@ module NewRelic
47
47
  end
48
48
  end
49
49
 
50
+ # The agent doesn't use the traditional ActiveSupport::Notifications.subscribe
51
+ # pattern due to threading issues discovered on initial instrumentation.
52
+ # Instead we define a #start and #finish method, which Rails responds to.
53
+ # See: https://github.com/rails/rails/issues/12069
50
54
  def start(name, id, payload)
51
55
  return unless state.is_execution_traced?
52
56
 
@@ -4,7 +4,11 @@
4
4
 
5
5
  module NewRelic::Agent::Instrumentation
6
6
  module Padrino
7
+ INSTRUMENTATION_NAME = NewRelic::Agent.base_name(name)
8
+
7
9
  def invoke_route_with_tracing(*args)
10
+ NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
11
+
8
12
  begin
9
13
  env['newrelic.last_route'] = args[0].original_path
10
14
  rescue => e
@@ -5,7 +5,7 @@
5
5
  module NewRelic
6
6
  module Agent
7
7
  module Instrumentation
8
- # https://newrelic.com/docs/features/tracking-front-end-time
8
+ # https://docs.newrelic.com/docs/features/tracking-front-end-time
9
9
  # Record queue time metrics based on any of three headers
10
10
  # which can be set on the request.
11
11
  module QueueTime
@@ -6,6 +6,8 @@ module NewRelic
6
6
  module Agent
7
7
  module Instrumentation
8
8
  module RackBuilder
9
+ INSTRUMENTATION_NAME = 'Rack'
10
+
9
11
  def self.track_deferred_detection(builder_class)
10
12
  class << builder_class
11
13
  attr_accessor :_nr_deferred_detection_ran
@@ -51,6 +53,8 @@ module NewRelic
51
53
  def run_with_tracing(app)
52
54
  return yield(app) unless middleware_instrumentation_enabled?
53
55
 
56
+ NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
57
+
54
58
  yield(::NewRelic::Agent::Instrumentation::MiddlewareProxy.wrap(app, true))
55
59
  end
56
60
 
@@ -58,6 +62,8 @@ module NewRelic
58
62
  return if middleware_class.nil?
59
63
  return yield(middleware_class) unless middleware_instrumentation_enabled?
60
64
 
65
+ NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
66
+
61
67
  yield(::NewRelic::Agent::Instrumentation::MiddlewareProxy.for_class(middleware_class))
62
68
  end
63
69
  end
@@ -9,6 +9,8 @@ module NewRelic
9
9
  module Instrumentation
10
10
  module Rails3
11
11
  module ActionController
12
+ INSTRUMENTATION_NAME = NewRelic::Agent.base_name(name)
13
+
12
14
  # determine the path that is used in the metric name for
13
15
  # the called controller action
14
16
  def newrelic_metric_path(action_name_override = nil)
@@ -21,6 +23,8 @@ module NewRelic
21
23
  end
22
24
 
23
25
  def process_action(*args) # THREAD_LOCAL_ACCESS
26
+ NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
27
+
24
28
  munged_params = NewRelic::Agent::ParameterFiltering.filter_rails_request_parameters(request.filtered_parameters)
25
29
  perform_action_with_newrelic_trace(:category => :controller,
26
30
  :name => self.action_name,
@@ -25,7 +25,7 @@ DependencyDetection.defer do
25
25
 
26
26
  executes do
27
27
  # enumerate the specific events we want so that we do not get unexpected additions in the future
28
- ActiveSupport::Notifications.subscribe(/\A(?:perform_action|transmit|broadcast)\.action_cable\z/,
28
+ ActiveSupport::Notifications.subscribe(/\A(?:perform_action|transmit.*|broadcast)\.action_cable\z/,
29
29
  NewRelic::Agent::Instrumentation::ActionCableSubscriber.new)
30
30
 
31
31
  ActiveSupport.on_load(:action_cable) do
@@ -7,11 +7,15 @@ module NewRelic
7
7
  module Instrumentation
8
8
  module Rake
9
9
  module Tracer
10
+ INSTRUMENTATION_NAME = 'Rake'
11
+
10
12
  def invoke_with_newrelic_tracing(*args)
11
13
  unless NewRelic::Agent::Instrumentation::Rake.should_trace?(name)
12
14
  return yield
13
15
  end
14
16
 
17
+ NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
18
+
15
19
  begin
16
20
  timeout = NewRelic::Agent.config[:'rake.connect_timeout']
17
21
  NewRelic::Agent.instance.wait_on_connect(timeout)
@@ -6,6 +6,8 @@ require_relative 'constants'
6
6
 
7
7
  module NewRelic::Agent::Instrumentation
8
8
  module Redis
9
+ INSTRUMENTATION_NAME = NewRelic::Agent.base_name(name)
10
+
9
11
  def connect_with_tracing
10
12
  with_tracing(Constants::CONNECT, database: db) { yield }
11
13
  end
@@ -43,6 +45,8 @@ module NewRelic::Agent::Instrumentation
43
45
  private
44
46
 
45
47
  def with_tracing(operation, statement: nil, database: nil)
48
+ NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
49
+
46
50
  segment = NewRelic::Agent::Tracer.start_datastore_segment(
47
51
  product: Constants::PRODUCT_NAME,
48
52
  operation: operation,
@@ -6,7 +6,11 @@ module NewRelic::Agent::Instrumentation
6
6
  module Resque
7
7
  include NewRelic::Agent::Instrumentation::ControllerInstrumentation
8
8
 
9
+ INSTRUMENTATION_NAME = NewRelic::Agent.base_name(name)
10
+
9
11
  def with_tracing
12
+ NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
13
+
10
14
  begin
11
15
  perform_action_with_newrelic_trace(
12
16
  :name => 'perform',
@@ -0,0 +1,43 @@
1
+ # This file is distributed under New Relic's license terms.
2
+ # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
3
+ # frozen_string_literal: true
4
+
5
+ module NewRelic::Agent::Instrumentation
6
+ module Roda
7
+ module Chain
8
+ def self.instrument!
9
+ ::Roda.class_eval do
10
+ include ::NewRelic::Agent::Instrumentation::Roda::Tracer
11
+
12
+ alias_method(:_roda_handle_main_route_without_tracing, :_roda_handle_main_route)
13
+
14
+ def _roda_handle_main_route(*args)
15
+ _roda_handle_main_route_with_tracing(*args) do
16
+ _roda_handle_main_route_without_tracing(*args)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+
23
+ module Build
24
+ module Chain
25
+ def self.instrument!
26
+ ::Roda.class_eval do
27
+ include ::NewRelic::Agent::Instrumentation::Roda::Tracer
28
+
29
+ class << self
30
+ alias_method(:build_rack_app_without_tracing, :build_rack_app)
31
+
32
+ def build_rack_app
33
+ build_rack_app_with_tracing do
34
+ build_rack_app_without_tracing
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,56 @@
1
+ # This file is distributed under New Relic's license terms.
2
+ # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
3
+ # frozen_string_literal: true
4
+
5
+ module NewRelic::Agent::Instrumentation
6
+ module Roda
7
+ module Tracer
8
+ include ::NewRelic::Agent::Instrumentation::ControllerInstrumentation
9
+
10
+ INSTRUMENTATION_NAME = 'Roda'
11
+
12
+ def self.included(clazz)
13
+ clazz.extend(self)
14
+ end
15
+
16
+ def newrelic_middlewares
17
+ middlewares = [NewRelic::Rack::BrowserMonitoring]
18
+ if NewRelic::Rack::AgentHooks.needed?
19
+ middlewares << NewRelic::Rack::AgentHooks
20
+ end
21
+ middlewares
22
+ end
23
+
24
+ def build_rack_app_with_tracing
25
+ unless NewRelic::Agent.config[:disable_roda_auto_middleware]
26
+ newrelic_middlewares.each do |middleware_class|
27
+ self.use middleware_class
28
+ end
29
+ end
30
+ yield
31
+ end
32
+
33
+ # Roda makes use of Rack, so we can get params from the request object
34
+ def rack_request_params
35
+ begin
36
+ @_request.params
37
+ rescue => e
38
+ NewRelic::Agent.logger.debug('Failed to get params from Rack request.', e)
39
+ NewRelic::EMPTY_HASH
40
+ end
41
+ end
42
+
43
+ def _roda_handle_main_route_with_tracing(*args)
44
+ NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
45
+
46
+ perform_action_with_newrelic_trace(
47
+ category: :roda,
48
+ name: ::NewRelic::Agent::Instrumentation::Roda::TransactionNamer.transaction_name(request),
49
+ params: ::NewRelic::Agent::ParameterFiltering::apply_filters(request.env, rack_request_params)
50
+ ) do
51
+ yield
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,24 @@
1
+ # This file is distributed under New Relic's license terms.
2
+ # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
3
+ # frozen_string_literal: true
4
+
5
+ module NewRelic::Agent::Instrumentation
6
+ module Roda
7
+ module Prepend
8
+ include ::NewRelic::Agent::Instrumentation::Roda::Tracer
9
+
10
+ def _roda_handle_main_route(*args)
11
+ _roda_handle_main_route_with_tracing(*args) { super }
12
+ end
13
+ end
14
+
15
+ module Build
16
+ module Prepend
17
+ include ::NewRelic::Agent::Instrumentation::Roda::Tracer
18
+ def build_rack_app
19
+ build_rack_app_with_tracing { super }
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,30 @@
1
+ # This file is distributed under New Relic's license terms.
2
+ # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
3
+ # frozen_string_literal: true
4
+
5
+ module NewRelic
6
+ module Agent
7
+ module Instrumentation
8
+ module Roda
9
+ module TransactionNamer
10
+ extend self
11
+
12
+ ROOT = '/'.freeze
13
+ REGEX_MULTIPLE_SLASHES = %r{^[/^]*(.*?)[/$?]*$}.freeze
14
+
15
+ def transaction_name(request)
16
+ path = request.path || ::NewRelic::Agent::UNKNOWN_METRIC
17
+ name = path.gsub(REGEX_MULTIPLE_SLASHES, '\1') # remove any rogue slashes
18
+ name = ROOT if name.empty?
19
+ name = "#{request.request_method} #{name}" if request.respond_to?(:request_method)
20
+
21
+ name
22
+ rescue => e
23
+ ::NewRelic::Agent.logger.debug("#{e.class} : #{e.message} - Error encountered trying to identify Roda transaction name")
24
+ ::NewRelic::Agent::UNKNOWN_METRIC
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end