newrelic_rpm 8.16.0 → 9.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +3 -41
- data/.rubocop_todo.yml +13 -14
- data/.simplecov +1 -1
- data/CHANGELOG.md +184 -0
- data/CONTRIBUTING.md +1 -1
- data/Gemfile +1 -1
- data/Guardfile +7 -7
- data/README.md +3 -2
- data/Rakefile +8 -8
- data/Thorfile +1 -1
- data/bin/nrdebug +36 -36
- data/init.rb +1 -1
- data/lib/new_relic/agent/agent.rb +3 -16
- data/lib/new_relic/agent/agent_helpers/connect.rb +5 -10
- data/lib/new_relic/agent/agent_helpers/harvest.rb +4 -4
- data/lib/new_relic/agent/agent_helpers/shutdown.rb +5 -5
- data/lib/new_relic/agent/agent_helpers/special_startup.rb +3 -4
- data/lib/new_relic/agent/agent_helpers/start_worker_thread.rb +47 -39
- data/lib/new_relic/agent/agent_helpers/startup.rb +13 -13
- data/lib/new_relic/agent/agent_helpers/transmit.rb +6 -6
- data/lib/new_relic/agent/agent_logger.rb +9 -9
- data/lib/new_relic/agent/attribute_filter.rb +2 -4
- data/lib/new_relic/agent/attribute_processing.rb +2 -2
- data/lib/new_relic/agent/audit_logger.rb +5 -5
- data/lib/new_relic/agent/autostart.rb +1 -1
- data/lib/new_relic/agent/commands/agent_command.rb +2 -2
- data/lib/new_relic/agent/commands/agent_command_router.rb +5 -4
- data/lib/new_relic/agent/commands/thread_profiler_session.rb +8 -8
- data/lib/new_relic/agent/configuration/default_source.rb +155 -530
- data/lib/new_relic/agent/configuration/environment_source.rb +2 -2
- data/lib/new_relic/agent/configuration/high_security_source.rb +3 -5
- data/lib/new_relic/agent/configuration/manager.rb +2 -2
- data/lib/new_relic/agent/configuration/security_policy_source.rb +10 -26
- data/lib/new_relic/agent/configuration/server_source.rb +24 -24
- data/lib/new_relic/agent/configuration/yaml_source.rb +4 -4
- data/lib/new_relic/agent/connect/request_builder.rb +1 -1
- data/lib/new_relic/agent/connect/response_handler.rb +1 -1
- data/lib/new_relic/agent/custom_event_aggregator.rb +4 -4
- data/lib/new_relic/agent/database/explain_plan_helpers.rb +1 -1
- data/lib/new_relic/agent/database/obfuscation_helpers.rb +2 -2
- data/lib/new_relic/agent/database/obfuscator.rb +2 -2
- data/lib/new_relic/agent/database.rb +4 -18
- data/lib/new_relic/agent/datastores/metric_helper.rb +5 -5
- data/lib/new_relic/agent/datastores/mongo/metric_translator.rb +11 -11
- data/lib/new_relic/agent/datastores/redis.rb +6 -6
- data/lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb +8 -10
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_attributes.rb +10 -10
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_metrics.rb +7 -7
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb +1 -1
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_transport_type.rb +6 -6
- data/lib/new_relic/agent/distributed_tracing/trace_context.rb +7 -7
- data/lib/new_relic/agent/distributed_tracing/trace_context_payload.rb +4 -4
- data/lib/new_relic/agent/distributed_tracing.rb +5 -5
- data/lib/new_relic/agent/error_collector.rb +36 -8
- data/lib/new_relic/agent/error_filter.rb +5 -5
- data/lib/new_relic/agent/error_trace_aggregator.rb +5 -4
- data/lib/new_relic/agent/event_loop.rb +3 -3
- data/lib/new_relic/agent/external.rb +1 -1
- data/lib/new_relic/agent/harvester.rb +1 -3
- data/lib/new_relic/agent/heap.rb +2 -1
- data/lib/new_relic/agent/hostname.rb +1 -1
- data/lib/new_relic/agent/http_clients/abstract.rb +9 -21
- data/lib/new_relic/agent/http_clients/curb_wrappers.rb +7 -3
- data/lib/new_relic/agent/http_clients/excon_wrappers.rb +7 -5
- data/lib/new_relic/agent/http_clients/http_rb_wrappers.rb +4 -0
- data/lib/new_relic/agent/http_clients/httpclient_wrappers.rb +6 -2
- data/lib/new_relic/agent/http_clients/net_http_wrappers.rb +5 -1
- data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +8 -5
- data/lib/new_relic/agent/http_clients/uri_util.rb +2 -2
- data/lib/new_relic/agent/instrumentation/action_controller_other_subscriber.rb +5 -2
- data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +3 -2
- data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +3 -3
- data/lib/new_relic/agent/instrumentation/active_job.rb +2 -2
- data/lib/new_relic/agent/instrumentation/active_record.rb +3 -2
- data/lib/new_relic/agent/instrumentation/active_record_helper.rb +38 -35
- data/lib/new_relic/agent/instrumentation/active_record_notifications.rb +3 -3
- data/lib/new_relic/agent/instrumentation/active_record_prepend.rb +2 -2
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +3 -2
- data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +3 -3
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +6 -4
- data/lib/new_relic/agent/instrumentation/curb/chain.rb +1 -1
- data/lib/new_relic/agent/instrumentation/curb/instrumentation.rb +5 -5
- data/lib/new_relic/agent/instrumentation/curb.rb +1 -1
- data/lib/new_relic/agent/instrumentation/custom_events_subscriber.rb +2 -1
- data/lib/new_relic/agent/instrumentation/delayed_job/instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +2 -1
- data/lib/new_relic/agent/instrumentation/elasticsearch/chain.rb +1 -1
- data/lib/new_relic/agent/instrumentation/elasticsearch/instrumentation.rb +3 -3
- data/lib/new_relic/agent/instrumentation/elasticsearch.rb +1 -1
- data/lib/new_relic/agent/instrumentation/excon/middleware.rb +2 -1
- data/lib/new_relic/agent/instrumentation/excon.rb +3 -3
- data/lib/new_relic/agent/instrumentation/fiber/chain.rb +20 -0
- data/lib/new_relic/agent/instrumentation/fiber/instrumentation.rb +24 -0
- data/lib/new_relic/agent/instrumentation/fiber/prepend.rb +18 -0
- data/lib/new_relic/agent/instrumentation/fiber.rb +25 -0
- data/lib/new_relic/agent/instrumentation/grape/instrumentation.rb +4 -4
- data/lib/new_relic/agent/instrumentation/grape.rb +4 -4
- data/lib/new_relic/agent/instrumentation/grpc/client/instrumentation.rb +2 -1
- data/lib/new_relic/agent/instrumentation/grpc/server/instrumentation.rb +3 -3
- data/lib/new_relic/agent/instrumentation/httprb.rb +1 -1
- data/lib/new_relic/agent/instrumentation/ignore_actions.rb +1 -1
- data/lib/new_relic/agent/instrumentation/logger.rb +1 -1
- data/lib/new_relic/agent/instrumentation/memcache/instrumentation.rb +2 -2
- data/lib/new_relic/agent/instrumentation/memcache.rb +8 -8
- data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +3 -3
- data/lib/new_relic/agent/instrumentation/middleware_tracing.rb +1 -1
- data/lib/new_relic/agent/instrumentation/mongodb_command_subscriber.rb +5 -5
- data/lib/new_relic/agent/instrumentation/net_http.rb +2 -2
- data/lib/new_relic/agent/instrumentation/notifications_subscriber.rb +1 -1
- data/lib/new_relic/agent/instrumentation/padrino/instrumentation.rb +3 -3
- data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +2 -2
- data/lib/new_relic/agent/instrumentation/rack/instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +3 -2
- data/lib/new_relic/agent/instrumentation/rails_middleware.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rake/instrumentation.rb +8 -15
- data/lib/new_relic/agent/instrumentation/rake.rb +3 -3
- data/lib/new_relic/agent/instrumentation/redis/constants.rb +1 -1
- data/lib/new_relic/agent/instrumentation/redis/instrumentation.rb +2 -1
- data/lib/new_relic/agent/instrumentation/redis.rb +1 -1
- data/lib/new_relic/agent/instrumentation/resque/helper.rb +1 -1
- data/lib/new_relic/agent/instrumentation/resque.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sequel.rb +8 -9
- data/lib/new_relic/agent/instrumentation/sequel_helper.rb +10 -10
- data/lib/new_relic/agent/instrumentation/sidekiq/extensions/delayed_class.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sidekiq/server.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sinatra/ignorer.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sinatra/instrumentation.rb +6 -5
- data/lib/new_relic/agent/instrumentation/sinatra/transaction_namer.rb +1 -1
- data/lib/new_relic/agent/instrumentation/thread/instrumentation.rb +3 -7
- data/lib/new_relic/agent/instrumentation/tilt/instrumentation.rb +2 -1
- data/lib/new_relic/agent/instrumentation/typhoeus/instrumentation.rb +5 -5
- data/lib/new_relic/agent/javascript_instrumentor.rb +29 -24
- data/lib/new_relic/agent/linking_metadata.rb +2 -2
- data/lib/new_relic/agent/log_event_aggregator.rb +15 -15
- data/lib/new_relic/agent/logging.rb +73 -33
- data/lib/new_relic/agent/messaging.rb +7 -5
- data/lib/new_relic/agent/method_tracer.rb +6 -6
- data/lib/new_relic/agent/method_tracer_helpers.rb +1 -1
- data/lib/new_relic/agent/monitors/cross_app_monitor.rb +4 -5
- data/lib/new_relic/agent/monitors/distributed_tracing_monitor.rb +1 -1
- data/lib/new_relic/agent/new_relic_service/encoders.rb +1 -1
- data/lib/new_relic/agent/new_relic_service/json_marshaller.rb +2 -2
- data/lib/new_relic/agent/new_relic_service/security_policy_settings.rb +0 -1
- data/lib/new_relic/agent/new_relic_service.rb +15 -15
- data/lib/new_relic/agent/obfuscator.rb +1 -1
- data/lib/new_relic/agent/parameter_filtering.rb +6 -6
- data/lib/new_relic/agent/pipe_channel_manager.rb +7 -6
- data/lib/new_relic/agent/pipe_service.rb +5 -3
- data/lib/new_relic/agent/priority_sampled_buffer.rb +1 -1
- data/lib/new_relic/agent/rules_engine/segment_terms_rule.rb +0 -1
- data/lib/new_relic/agent/sampler.rb +1 -1
- data/lib/new_relic/agent/sampler_collection.rb +1 -1
- data/lib/new_relic/agent/samplers/cpu_sampler.rb +5 -5
- data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +9 -9
- data/lib/new_relic/agent/samplers/memory_sampler.rb +9 -9
- data/lib/new_relic/agent/samplers/object_sampler.rb +1 -1
- data/lib/new_relic/agent/span_event_aggregator.rb +4 -4
- data/lib/new_relic/agent/span_event_primitive.rb +2 -2
- data/lib/new_relic/agent/sql_sampler.rb +2 -2
- data/lib/new_relic/agent/stats.rb +1 -1
- data/lib/new_relic/agent/synthetics_event_aggregator.rb +1 -1
- data/lib/new_relic/agent/system_info.rb +10 -10
- data/lib/new_relic/agent/threading/agent_thread.rb +1 -1
- data/lib/new_relic/agent/threading/backtrace_node.rb +3 -3
- data/lib/new_relic/agent/threading/backtrace_service.rb +3 -7
- data/lib/new_relic/agent/threading/thread_profile.rb +5 -5
- data/lib/new_relic/agent/timestamp_sampled_buffer.rb +1 -1
- data/lib/new_relic/agent/tracer.rb +18 -8
- data/lib/new_relic/agent/transaction/abstract_segment.rb +9 -9
- data/lib/new_relic/agent/transaction/datastore_segment.rb +1 -1
- data/lib/new_relic/agent/transaction/distributed_tracer.rb +7 -6
- data/lib/new_relic/agent/transaction/distributed_tracing.rb +6 -6
- data/lib/new_relic/agent/transaction/external_request_segment.rb +11 -11
- data/lib/new_relic/agent/transaction/message_broker_segment.rb +1 -1
- data/lib/new_relic/agent/transaction/request_attributes.rb +2 -2
- data/lib/new_relic/agent/transaction/segment.rb +1 -1
- data/lib/new_relic/agent/transaction/synthetics_sample_buffer.rb +1 -1
- data/lib/new_relic/agent/transaction/trace.rb +1 -1
- data/lib/new_relic/agent/transaction/trace_context.rb +4 -4
- data/lib/new_relic/agent/transaction/trace_node.rb +8 -7
- data/lib/new_relic/agent/transaction/tracing.rb +4 -4
- data/lib/new_relic/agent/transaction/transaction_sample_buffer.rb +1 -1
- data/lib/new_relic/agent/transaction.rb +56 -52
- data/lib/new_relic/agent/transaction_error_primitive.rb +5 -5
- data/lib/new_relic/agent/transaction_event_aggregator.rb +4 -4
- data/lib/new_relic/agent/transaction_event_primitive.rb +3 -3
- data/lib/new_relic/agent/transaction_sampler.rb +3 -3
- data/lib/new_relic/agent/transaction_time_aggregator.rb +7 -3
- data/lib/new_relic/agent/utilization/aws.rb +1 -1
- data/lib/new_relic/agent/utilization/azure.rb +3 -3
- data/lib/new_relic/agent/utilization/gcp.rb +3 -3
- data/lib/new_relic/agent/utilization/pcf.rb +1 -1
- data/lib/new_relic/agent/utilization/vendor.rb +1 -1
- data/lib/new_relic/agent/vm/monotonic_gc_profiler.rb +1 -1
- data/lib/new_relic/agent/vm/mri_vm.rb +9 -8
- data/lib/new_relic/agent/worker_loop.rb +1 -1
- data/lib/new_relic/agent.rb +79 -35
- data/lib/new_relic/cli/command.rb +3 -3
- data/lib/new_relic/cli/commands/deployments.rb +26 -25
- data/lib/new_relic/cli/commands/install.rb +23 -23
- data/lib/new_relic/collection_helper.rb +2 -2
- data/lib/new_relic/constants.rb +7 -8
- data/lib/new_relic/control/class_methods.rb +3 -3
- data/lib/new_relic/control/frameworks/rails.rb +30 -18
- data/lib/new_relic/control/instance_methods.rb +6 -6
- data/lib/new_relic/control/instrumentation.rb +1 -1
- data/lib/new_relic/control/private_instance_methods.rb +1 -1
- data/lib/new_relic/dependency_detection.rb +4 -17
- data/lib/new_relic/environment_report.rb +4 -4
- data/lib/new_relic/helper.rb +2 -1
- data/lib/new_relic/language_support.rb +1 -1
- data/lib/new_relic/latest_changes.rb +5 -5
- data/lib/new_relic/local_environment.rb +0 -10
- data/lib/new_relic/noticed_error.rb +20 -18
- data/lib/new_relic/rack/browser_monitoring.rb +20 -16
- data/lib/new_relic/recipes/capistrano3.rb +1 -1
- data/lib/new_relic/recipes/capistrano_legacy.rb +6 -6
- data/lib/new_relic/recipes/helpers/send_deployment.rb +5 -5
- data/lib/new_relic/supportability_helper.rb +2 -1
- data/lib/new_relic/version.rb +2 -2
- data/lib/newrelic_rpm.rb +4 -4
- data/lib/sequel/extensions/{newrelic_instrumentation.rb → new_relic_instrumentation.rb} +5 -5
- data/lib/sequel/plugins/{newrelic_instrumentation.rb → new_relic_instrumentation.rb} +4 -4
- data/lib/tasks/config.rake +12 -12
- data/lib/tasks/coverage_report.rake +3 -3
- data/lib/tasks/helpers/format.rb +10 -10
- data/lib/tasks/helpers/removers.rb +5 -5
- data/lib/tasks/install.rake +4 -4
- data/lib/tasks/instrumentation_generator/instrumentation.thor +7 -10
- data/lib/tasks/instrumentation_generator/templates/Envfile.tt +1 -1
- data/lib/tasks/multiverse.rb +12 -6
- data/lib/tasks/tests.rake +6 -6
- data/newrelic.yml +5 -8
- data/newrelic_rpm.gemspec +29 -26
- data/test/agent_helper.rb +25 -24
- metadata +13 -14
- data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +0 -83
- data/lib/new_relic/agent/instrumentation/authlogic.rb +0 -33
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +0 -215
- data/lib/new_relic/agent/instrumentation/rainbows_instrumentation.rb +0 -36
- data/lib/new_relic/agent/instrumentation/sunspot.rb +0 -41
@@ -1,83 +0,0 @@
|
|
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
|
-
require 'new_relic/agent/database'
|
6
|
-
|
7
|
-
module NewRelic
|
8
|
-
module Instrumentation
|
9
|
-
module ActsAsSolrInstrumentation
|
10
|
-
module ParserMethodsInstrumentation
|
11
|
-
def parse_query_with_newrelic(*args)
|
12
|
-
self.class.trace_execution_scoped(["SolrClient/ActsAsSolr/query"]) do
|
13
|
-
begin
|
14
|
-
parse_query_without_newrelic(*args)
|
15
|
-
ensure
|
16
|
-
return unless txn = ::NewRelic::Agent::Tracer.current_transaction
|
17
|
-
|
18
|
-
txn.current_segment.params[:statement] = ::NewRelic::Agent::Database.truncate_query(args.first.inspect) rescue nil
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
DependencyDetection.defer do
|
28
|
-
@name = :acts_as_solr
|
29
|
-
|
30
|
-
depends_on do
|
31
|
-
defined?(ActsAsSolr)
|
32
|
-
end
|
33
|
-
|
34
|
-
depends_on do
|
35
|
-
defined?(ActsAsSolr::ParserMethods)
|
36
|
-
end
|
37
|
-
|
38
|
-
depends_on do
|
39
|
-
defined?(ActsAsSolr::ClassMethods)
|
40
|
-
end
|
41
|
-
|
42
|
-
depends_on do
|
43
|
-
defined?(ActsAsSolr::CommonMethods)
|
44
|
-
end
|
45
|
-
|
46
|
-
executes do
|
47
|
-
NewRelic::Agent.logger.info('Installing ActsAsSolr instrumentation')
|
48
|
-
deprecation_msg = 'The instrumentation for ActsAsSolr is deprecated. ' \
|
49
|
-
'It will be removed in version 9.0.0.' \
|
50
|
-
|
51
|
-
NewRelic::Agent.logger.log_once(
|
52
|
-
:warn,
|
53
|
-
:deprecated_acts_as_solr,
|
54
|
-
deprecation_msg
|
55
|
-
)
|
56
|
-
end
|
57
|
-
|
58
|
-
executes do
|
59
|
-
ActsAsSolr::ParserMethods.module_eval do
|
60
|
-
include NewRelic::Instrumentation::ActsAsSolrInstrumentation::ParserMethodsInstrumentation
|
61
|
-
alias :parse_query_without_newrelic :parse_query
|
62
|
-
alias :parse_query :parse_query_with_newrelic
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
executes do
|
67
|
-
ActsAsSolr::ClassMethods.module_eval do
|
68
|
-
%w[find_by_solr find_id_by_solr multi_solr_search count_by_solr].each do |method|
|
69
|
-
add_method_tracer method, 'SolrClient/ActsAsSolr/query'
|
70
|
-
end
|
71
|
-
add_method_tracer :rebuild_solr_index, 'SolrClient/ActsAsSolr/index'
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
executes do
|
76
|
-
ActsAsSolr::CommonMethods.module_eval do
|
77
|
-
add_method_tracer :solr_add, 'SolrClient/ActsAsSolr/add'
|
78
|
-
add_method_tracer :solr_delete, 'SolrClient/ActsAsSolr/delete'
|
79
|
-
add_method_tracer :solr_commit, 'SolrClient/ActsAsSolr/commit'
|
80
|
-
add_method_tracer :solr_optimize, 'SolrClient/ActsAsSolr/optimize'
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
@@ -1,33 +0,0 @@
|
|
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
|
-
DependencyDetection.defer do
|
6
|
-
@name = :authlogic
|
7
|
-
|
8
|
-
depends_on do
|
9
|
-
defined?(Authlogic) &&
|
10
|
-
defined?(Authlogic::Session) &&
|
11
|
-
defined?(Authlogic::Session::Base)
|
12
|
-
end
|
13
|
-
|
14
|
-
executes do
|
15
|
-
NewRelic::Agent.logger.info('Installing Authlogic instrumentation')
|
16
|
-
deprecation_msg = 'The instrumentation for Authlogic is deprecated. ' \
|
17
|
-
'It will be removed in version 9.0.0.' \
|
18
|
-
|
19
|
-
NewRelic::Agent.logger.log_once(
|
20
|
-
:warn,
|
21
|
-
:deprecated_authlogic,
|
22
|
-
deprecation_msg
|
23
|
-
)
|
24
|
-
end
|
25
|
-
|
26
|
-
executes do
|
27
|
-
Authlogic::Session::Base.class_eval do
|
28
|
-
class << self
|
29
|
-
add_method_tracer :find, 'Custom/Authlogic/find'
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,215 +0,0 @@
|
|
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
|
-
DependencyDetection.defer do
|
6
|
-
named :data_mapper
|
7
|
-
|
8
|
-
depends_on do
|
9
|
-
defined?(DataMapper) &&
|
10
|
-
defined?(DataMapper::Model) &&
|
11
|
-
defined?(DataMapper::Resource) &&
|
12
|
-
defined?(DataMapper::Collection)
|
13
|
-
end
|
14
|
-
|
15
|
-
executes do
|
16
|
-
NewRelic::Agent.logger.info('Installing DataMapper instrumentation')
|
17
|
-
require 'new_relic/agent/datastores/metric_helper'
|
18
|
-
|
19
|
-
deprecation_msg = 'The instrumentation for DataMapper is deprecated. ' \
|
20
|
-
'It will be removed in version 9.0.0.' \
|
21
|
-
'Visit https://docs.newrelic.com/docs/apm/agents/ruby-agent/getting-started/ruby-agent-requirements-supported-frameworks ' \
|
22
|
-
'to learn about supported gems.'
|
23
|
-
|
24
|
-
NewRelic::Agent.logger.log_once(
|
25
|
-
:warn,
|
26
|
-
:deprecated_datamapper,
|
27
|
-
deprecation_msg
|
28
|
-
)
|
29
|
-
end
|
30
|
-
|
31
|
-
executes do
|
32
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :get)
|
33
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :first)
|
34
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :last)
|
35
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :all)
|
36
|
-
|
37
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :create)
|
38
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :create!)
|
39
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :update)
|
40
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :update!)
|
41
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :destroy)
|
42
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :destroy!)
|
43
|
-
|
44
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :aggregate)
|
45
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :find)
|
46
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Model, :find_by_sql)
|
47
|
-
end
|
48
|
-
|
49
|
-
executes do
|
50
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Resource, :update)
|
51
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Resource, :update!)
|
52
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Resource, :save)
|
53
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Resource, :save!)
|
54
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Resource, :destroy)
|
55
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Resource, :destroy!)
|
56
|
-
end
|
57
|
-
|
58
|
-
executes do
|
59
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :get)
|
60
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :first)
|
61
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :last)
|
62
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :all)
|
63
|
-
|
64
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :lazy_load)
|
65
|
-
|
66
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :create)
|
67
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :create!)
|
68
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :update)
|
69
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :update!)
|
70
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :destroy)
|
71
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :destroy!)
|
72
|
-
|
73
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Collection, :aggregate)
|
74
|
-
end
|
75
|
-
|
76
|
-
executes do
|
77
|
-
# Catch direct SQL calls that bypass CRUD
|
78
|
-
if defined?(DataMapper::Adapters::DataObjectsAdapter)
|
79
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Adapters::DataObjectsAdapter, :select, true)
|
80
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Adapters::DataObjectsAdapter, :execute, true)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
executes do
|
85
|
-
# DM::Validations overrides Model#create, so we patch it here as well
|
86
|
-
if defined?(DataMapper::Validations::ClassMethods)
|
87
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Validations::ClassMethods, :create)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
executes do
|
92
|
-
# DM::Transaction calls commit() twice, so potentially shows up twice.
|
93
|
-
if defined?(DataMapper::Transaction)
|
94
|
-
NewRelic::Agent::DataMapperTracing.add_tracer(DataMapper::Transaction, :commit, true)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
executes do
|
99
|
-
if defined?(DataObjects::Connection)
|
100
|
-
DataObjects::Connection.class_eval do
|
101
|
-
include NewRelic::Agent::Instrumentation::DataMapperInstrumentation
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
module NewRelic
|
108
|
-
module Agent
|
109
|
-
module DataMapperTracing
|
110
|
-
def self.add_tracer(clazz, method_name, operation_only = false)
|
111
|
-
clazz.class_eval do
|
112
|
-
if method_defined?(method_name) || private_method_defined?(method_name)
|
113
|
-
define_method("#{method_name}_with_newrelic",
|
114
|
-
NewRelic::Agent::DataMapperTracing.method_body(clazz, method_name, operation_only))
|
115
|
-
|
116
|
-
alias_method("#{method_name}_without_newrelic", method_name)
|
117
|
-
alias_method(method_name, "#{method_name}_with_newrelic")
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
DATA_MAPPER = "DataMapper".freeze
|
123
|
-
PASSWORD_REGEX = /&password=.*?(&|$)/
|
124
|
-
AMPERSAND = '&'.freeze
|
125
|
-
PASSWORD_PARAM = '&password='.freeze
|
126
|
-
|
127
|
-
def self.method_body(clazz, method_name, operation_only)
|
128
|
-
use_model_name = NewRelic::Helper.instance_methods_include?(clazz, :model)
|
129
|
-
metric_operation = method_name.to_s.gsub(/[!?]/, "")
|
130
|
-
|
131
|
-
proc do |*args, &blk|
|
132
|
-
begin
|
133
|
-
if operation_only
|
134
|
-
# Used by direct SQL, like ::DataMapper::Adapters::DataObjectsAdapter#select
|
135
|
-
name = nil
|
136
|
-
elsif use_model_name
|
137
|
-
# Used by ::DataMapper::Collection to get contained model name
|
138
|
-
name = self.model.name
|
139
|
-
elsif self.is_a?(Class)
|
140
|
-
# Used by class-style access, like Model.first()
|
141
|
-
name = self.name
|
142
|
-
else
|
143
|
-
# Used by instance-style access, like model.update(attr: "new")
|
144
|
-
name = self.class.name
|
145
|
-
end
|
146
|
-
|
147
|
-
segment = NewRelic::Agent::Tracer.start_datastore_segment(
|
148
|
-
product: DATA_MAPPER,
|
149
|
-
operation: metric_operation,
|
150
|
-
collection: name
|
151
|
-
)
|
152
|
-
|
153
|
-
begin
|
154
|
-
NewRelic::Agent::Tracer.capture_segment_error(segment) do
|
155
|
-
self.send("#{method_name}_without_newrelic", *args, &blk)
|
156
|
-
end
|
157
|
-
rescue ::DataObjects::ConnectionError => e
|
158
|
-
raise
|
159
|
-
rescue ::DataObjects::SQLError => e
|
160
|
-
e.uri.gsub!(PASSWORD_REGEX, AMPERSAND) if e.uri.include?(PASSWORD_PARAM)
|
161
|
-
|
162
|
-
strategy = NewRelic::Agent::Database.record_sql_method(:slow_sql)
|
163
|
-
case strategy
|
164
|
-
when :obfuscated
|
165
|
-
adapter_name = if self.respond_to?(:options)
|
166
|
-
self.options[:adapter]
|
167
|
-
else
|
168
|
-
if self.repository.adapter.respond_to?(:options)
|
169
|
-
self.repository.adapter.options[:adapter]
|
170
|
-
else
|
171
|
-
# DataMapper < 0.10.0
|
172
|
-
self.repository.adapter.uri.scheme
|
173
|
-
end
|
174
|
-
end
|
175
|
-
statement = NewRelic::Agent::Database::Statement.new(e.query, :adapter => adapter_name)
|
176
|
-
obfuscated_sql = NewRelic::Agent::Database.obfuscate_sql(statement)
|
177
|
-
e.instance_variable_set(:@query, obfuscated_sql)
|
178
|
-
when :off
|
179
|
-
e.instance_variable_set(:@query, nil)
|
180
|
-
end
|
181
|
-
|
182
|
-
raise
|
183
|
-
ensure
|
184
|
-
::NewRelic::Agent::Transaction::Segment.finish(segment)
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
module Instrumentation
|
192
|
-
module DataMapperInstrumentation
|
193
|
-
# Unlike in AR, log is called in DM after the query actually ran,
|
194
|
-
# complete with metrics. Since DO has already calculated the
|
195
|
-
# duration, there's nothing more to measure, so just record and log.
|
196
|
-
#
|
197
|
-
# We rely on the assumption that all possible entry points have been
|
198
|
-
# hooked with tracers, ensuring that notice_sql attaches this SQL to
|
199
|
-
# the proper call scope.
|
200
|
-
def log(msg) # THREAD_LOCAL_ACCESS
|
201
|
-
state = NewRelic::Agent::Tracer.state
|
202
|
-
return unless state.is_execution_traced?
|
203
|
-
|
204
|
-
txn = state.current_transaction
|
205
|
-
|
206
|
-
if txn && txn.current_segment.respond_to?(:notice_sql)
|
207
|
-
txn.current_segment.notice_sql(msg.query)
|
208
|
-
end
|
209
|
-
ensure
|
210
|
-
super
|
211
|
-
end
|
212
|
-
end
|
213
|
-
end
|
214
|
-
end
|
215
|
-
end
|
@@ -1,36 +0,0 @@
|
|
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
|
-
DependencyDetection.defer do
|
6
|
-
@name = :rainbows
|
7
|
-
|
8
|
-
depends_on do
|
9
|
-
defined?(Rainbows) && defined?(Rainbows::HttpServer)
|
10
|
-
end
|
11
|
-
|
12
|
-
executes do
|
13
|
-
NewRelic::Agent.logger.info('Installing Rainbows instrumentation')
|
14
|
-
NewRelic::Agent.logger.info('Detected Rainbows, please see additional documentation: https://newrelic.com/docs/troubleshooting/im-using-unicorn-and-i-dont-see-any-data')
|
15
|
-
|
16
|
-
deprecation_msg = 'The dispatcher rainbows is deprecated. It will be removed ' \
|
17
|
-
'in version 9.0.0. Please use a supported dispatcher instead. ' \
|
18
|
-
'Visit https://docs.newrelic.com/docs/apm/agents/ruby-agent/getting-started/ruby-agent-requirements-supported-frameworks for options.'
|
19
|
-
|
20
|
-
NewRelic::Agent.logger.log_once(
|
21
|
-
:warn,
|
22
|
-
:deprecated_rainbows_dispatcher,
|
23
|
-
deprecation_msg
|
24
|
-
)
|
25
|
-
end
|
26
|
-
|
27
|
-
executes do
|
28
|
-
Rainbows::HttpServer.class_eval do
|
29
|
-
old_worker_loop = instance_method(:worker_loop)
|
30
|
-
define_method(:worker_loop) do |worker|
|
31
|
-
NewRelic::Agent.after_fork(:force_reconnect => true)
|
32
|
-
old_worker_loop.bind(self).call(worker)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,41 +0,0 @@
|
|
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
|
-
DependencyDetection.defer do
|
6
|
-
@name = :sunspot
|
7
|
-
|
8
|
-
depends_on do
|
9
|
-
defined?(Sunspot)
|
10
|
-
end
|
11
|
-
|
12
|
-
executes do
|
13
|
-
NewRelic::Agent.logger.info('Installing Rails Sunspot instrumentation')
|
14
|
-
deprecation_msg = 'The instrumentation for Sunspot is deprecated. ' \
|
15
|
-
'It will be removed in version 9.0.0.'
|
16
|
-
|
17
|
-
NewRelic::Agent.logger.log_once(
|
18
|
-
:warn,
|
19
|
-
:deprecated_sunspot,
|
20
|
-
deprecation_msg
|
21
|
-
)
|
22
|
-
end
|
23
|
-
|
24
|
-
executes do
|
25
|
-
Sunspot.module_eval do
|
26
|
-
class << self
|
27
|
-
%w[index index!].each do |method|
|
28
|
-
add_method_tracer method, 'SolrClient/Sunspot/index'
|
29
|
-
end
|
30
|
-
add_method_tracer :commit, 'SolrClient/Sunspot/commit'
|
31
|
-
|
32
|
-
%w[search more_like_this].each do |method|
|
33
|
-
add_method_tracer method, 'SolrClient/Sunspot/query'
|
34
|
-
end
|
35
|
-
%w[remove remove! remove_by_id remove_by_id! remove_all remove_all!].each do |method|
|
36
|
-
add_method_tracer method, 'SolrClient/Sunspot/delete'
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|