newrelic_rpm 9.0.0 → 9.2.2
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 +7 -81
- data/.rubocop_todo.yml +4 -43
- data/.simplecov +2 -1
- data/Brewfile +1 -0
- data/CHANGELOG.md +101 -2
- data/Gemfile +1 -1
- data/Guardfile +8 -7
- data/README.md +1 -2
- data/Rakefile +8 -8
- data/Thorfile +1 -1
- data/bin/newrelic +1 -0
- data/bin/newrelic_cmd +1 -0
- data/bin/nrdebug +20 -20
- data/init.rb +1 -1
- data/lib/new_relic/agent/agent.rb +3 -16
- data/lib/new_relic/agent/agent_helpers/connect.rb +4 -9
- 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 +2 -2
- 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 -2
- 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 +5 -5
- data/lib/new_relic/agent/configuration/default_source.rb +106 -118
- data/lib/new_relic/agent/configuration/environment_source.rb +2 -2
- data/lib/new_relic/agent/configuration/high_security_source.rb +3 -3
- data/lib/new_relic/agent/configuration/manager.rb +15 -2
- data/lib/new_relic/agent/configuration/security_policy_source.rb +10 -10
- 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 -4
- 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 +7 -8
- 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 +35 -7
- data/lib/new_relic/agent/error_filter.rb +2 -2
- 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 +1 -1
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +3 -3
- 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/chain.rb +1 -1
- data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +3 -3
- data/lib/new_relic/agent/instrumentation/bunny.rb +1 -1
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +5 -3
- 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/chain.rb +1 -0
- 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 +2 -2
- data/lib/new_relic/agent/instrumentation/elasticsearch/instrumentation.rb +4 -3
- data/lib/new_relic/agent/instrumentation/elasticsearch.rb +2 -2
- 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 +1 -1
- data/lib/new_relic/agent/instrumentation/fiber.rb +1 -1
- data/lib/new_relic/agent/instrumentation/grape/instrumentation.rb +4 -4
- data/lib/new_relic/agent/instrumentation/grape.rb +3 -3
- data/lib/new_relic/agent/instrumentation/grpc/client/chain.rb +1 -1
- data/lib/new_relic/agent/instrumentation/grpc/client/instrumentation.rb +3 -2
- data/lib/new_relic/agent/instrumentation/grpc/client/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/grpc/client/request_wrapper.rb +1 -1
- data/lib/new_relic/agent/instrumentation/grpc/server/instrumentation.rb +4 -4
- data/lib/new_relic/agent/instrumentation/grpc_client.rb +1 -1
- data/lib/new_relic/agent/instrumentation/grpc_server.rb +1 -1
- 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/dalli.rb +3 -1
- data/lib/new_relic/agent/instrumentation/memcache/instrumentation.rb +2 -2
- data/lib/new_relic/agent/instrumentation/memcache/prepend.rb +3 -1
- 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 +6 -6
- data/lib/new_relic/agent/instrumentation/net_http.rb +1 -1
- 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 +7 -7
- data/lib/new_relic/agent/instrumentation/rake.rb +2 -2
- 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/resque/helper.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sequel.rb +4 -4
- 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/sidekiq.rb +1 -0
- 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/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 +7 -7
- data/lib/new_relic/agent/method_tracer_helpers.rb +1 -1
- data/lib/new_relic/agent/monitors/cross_app_monitor.rb +4 -4
- 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.rb +14 -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/sampler.rb +2 -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 +9 -8
- data/lib/new_relic/agent/transaction/abstract_segment.rb +52 -46
- 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 +13 -14
- 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 +8 -2
- data/lib/new_relic/agent/transaction/transaction_sample_buffer.rb +1 -1
- data/lib/new_relic/agent/transaction.rb +43 -36
- 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 +78 -16
- 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 +14 -14
- 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 +5 -5
- data/lib/new_relic/control/instrumentation.rb +1 -15
- data/lib/new_relic/control/private_instance_methods.rb +1 -1
- data/lib/new_relic/dependency_detection.rb +14 -18
- 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/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 -0
- data/lib/new_relic/version.rb +2 -2
- data/lib/newrelic_rpm.rb +3 -3
- data/lib/sequel/extensions/new_relic_instrumentation.rb +3 -3
- data/lib/sequel/plugins/new_relic_instrumentation.rb +1 -1
- data/lib/tasks/config.rake +12 -12
- data/lib/tasks/coverage_report.rake +4 -4
- data/lib/tasks/helpers/format.rb +9 -9
- data/lib/tasks/helpers/removers.rb +5 -5
- data/lib/tasks/install.rake +4 -4
- data/lib/tasks/instrumentation_generator/instrumentation.thor +8 -8
- data/lib/tasks/instrumentation_generator/templates/chain.tt +1 -1
- data/lib/tasks/instrumentation_generator/templates/dependency_detection.tt +1 -1
- data/lib/tasks/multiverse.rb +13 -6
- data/lib/tasks/newrelic.rb +1 -0
- data/lib/tasks/tests.rake +6 -6
- data/newrelic.yml +5 -5
- data/newrelic_rpm.gemspec +13 -13
- data/test/agent_helper.rb +25 -24
- metadata +73 -4
- data/lib/new_relic/agent/range_extensions.rb +0 -27
@@ -11,12 +11,12 @@ module NewRelic
|
|
11
11
|
NewRelic::UNKNOWN,
|
12
12
|
NewRelic::HTTP,
|
13
13
|
NewRelic::HTTPS,
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
'Kafka',
|
15
|
+
'JMS',
|
16
|
+
'IronMQ',
|
17
|
+
'AMQP',
|
18
|
+
'Queue',
|
19
|
+
'Other'
|
20
20
|
].freeze
|
21
21
|
|
22
22
|
URL_SCHEMES = {
|
@@ -29,14 +29,14 @@ module NewRelic
|
|
29
29
|
TP_UNDEFINED_FIELDS = "(?<#{UNDEFINED_FIELDS_KEY}>-[a-zA-Z\\d-]*)"
|
30
30
|
TRACE_PARENT_REGEX = /\A#{TP_VERSION}-#{TP_TRACE_ID}-#{TP_PARENT_ID}-#{TP_TRACE_FLAGS}#{TP_UNDEFINED_FIELDS}?\z/
|
31
31
|
|
32
|
-
TRACE_PARENT_FORMAT_STRING =
|
32
|
+
TRACE_PARENT_FORMAT_STRING = '%02x-%s-%s-%02x'
|
33
33
|
|
34
34
|
MAX_TRACE_STATE_SIZE = 512 # bytes
|
35
35
|
MAX_TRACE_STATE_ENTRY_SIZE = 128 # bytes
|
36
36
|
|
37
|
-
SUPPORTABILITY_TRACE_PARENT_PARSE_EXCEPTION =
|
38
|
-
SUPPORTABILITY_TRACE_STATE_PARSE_EXCEPTION =
|
39
|
-
SUPPORTABILITY_TRACE_STATE_INVALID_NR_ENTRY =
|
37
|
+
SUPPORTABILITY_TRACE_PARENT_PARSE_EXCEPTION = 'Supportability/TraceContext/TraceParent/Parse/Exception'
|
38
|
+
SUPPORTABILITY_TRACE_STATE_PARSE_EXCEPTION = 'Supportability/TraceContext/TraceState/Parse/Exception'
|
39
|
+
SUPPORTABILITY_TRACE_STATE_INVALID_NR_ENTRY = 'Supportability/TraceContext/TraceState/InvalidNrEntry'
|
40
40
|
|
41
41
|
class << self
|
42
42
|
def insert(format: NewRelic::FORMAT_NON_RACK,
|
@@ -78,7 +78,7 @@ module NewRelic
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def create_trace_state_entry(entry_key, payload)
|
81
|
-
"#{entry_key}=#{payload}"
|
81
|
+
+"#{entry_key}=#{payload}"
|
82
82
|
end
|
83
83
|
|
84
84
|
private
|
@@ -138,7 +138,7 @@ module NewRelic
|
|
138
138
|
|
139
139
|
payload = nil
|
140
140
|
trace_state_size = 0
|
141
|
-
trace_state_vendors =
|
141
|
+
trace_state_vendors = +''
|
142
142
|
trace_state = header.split(COMMA).map(&:strip)
|
143
143
|
trace_state.reject! do |entry|
|
144
144
|
if entry == NewRelic::EMPTY_STR
|
@@ -223,7 +223,7 @@ module NewRelic
|
|
223
223
|
max_size = MAX_TRACE_STATE_SIZE - trace_state_entry_size
|
224
224
|
return @trace_state_entries.join(COMMA).prepend(COMMA) if @trace_state_size < max_size
|
225
225
|
|
226
|
-
joined_trace_state = ''
|
226
|
+
joined_trace_state = +''
|
227
227
|
|
228
228
|
used_size = 0
|
229
229
|
|
@@ -9,8 +9,8 @@ module NewRelic
|
|
9
9
|
class TraceContextPayload
|
10
10
|
VERSION = 0
|
11
11
|
PARENT_TYPE = 0
|
12
|
-
DELIMITER =
|
13
|
-
SUPPORTABILITY_PARSE_EXCEPTION =
|
12
|
+
DELIMITER = '-'.freeze
|
13
|
+
SUPPORTABILITY_PARSE_EXCEPTION = 'Supportability/TraceContext/Parse/Exception'.freeze
|
14
14
|
|
15
15
|
TRUE_CHAR = '1'.freeze
|
16
16
|
FALSE_CHAR = '0'.freeze
|
@@ -64,7 +64,7 @@ module NewRelic
|
|
64
64
|
def handle_invalid_payload(error: nil, message: nil)
|
65
65
|
NewRelic::Agent.increment_metric(SUPPORTABILITY_PARSE_EXCEPTION)
|
66
66
|
if error
|
67
|
-
NewRelic::Agent.logger.warn(
|
67
|
+
NewRelic::Agent.logger.warn('Error parsing trace context payload', error)
|
68
68
|
elsif message
|
69
69
|
NewRelic::Agent.logger.warn("Error parsing trace context payload: #{message}")
|
70
70
|
end
|
@@ -118,7 +118,7 @@ module NewRelic
|
|
118
118
|
result << DELIMITER << (id || NewRelic::EMPTY_STR)
|
119
119
|
result << DELIMITER << (transaction_id || NewRelic::EMPTY_STR)
|
120
120
|
result << DELIMITER << (sampled ? TRUE_CHAR : FALSE_CHAR)
|
121
|
-
result << DELIMITER << sprintf(
|
121
|
+
result << DELIMITER << sprintf('%.6f', priority)
|
122
122
|
result << DELIMITER << timestamp.to_s # required
|
123
123
|
result
|
124
124
|
end
|
@@ -45,11 +45,11 @@ module NewRelic
|
|
45
45
|
record_api_supportability_metric(:insert_distributed_trace_headers)
|
46
46
|
|
47
47
|
unless Agent.config[:'distributed_tracing.enabled']
|
48
|
-
NewRelic::Agent.logger.warn(
|
48
|
+
NewRelic::Agent.logger.warn('Not configured to insert distributed trace headers')
|
49
49
|
return nil
|
50
50
|
end
|
51
51
|
|
52
|
-
return unless valid_api_argument_class?(headers,
|
52
|
+
return unless valid_api_argument_class?(headers, 'headers', Hash)
|
53
53
|
|
54
54
|
return unless transaction = Transaction.tl_current
|
55
55
|
|
@@ -99,12 +99,12 @@ module NewRelic
|
|
99
99
|
record_api_supportability_metric(:accept_distributed_trace_headers)
|
100
100
|
|
101
101
|
unless Agent.config[:'distributed_tracing.enabled']
|
102
|
-
NewRelic::Agent.logger.warn(
|
102
|
+
NewRelic::Agent.logger.warn('Not configured to accept distributed trace headers')
|
103
103
|
return nil
|
104
104
|
end
|
105
105
|
|
106
|
-
return unless valid_api_argument_class?(headers,
|
107
|
-
return unless valid_api_argument_class?(transport_type,
|
106
|
+
return unless valid_api_argument_class?(headers, 'headers', Hash)
|
107
|
+
return unless valid_api_argument_class?(transport_type, 'transport_type', String)
|
108
108
|
|
109
109
|
return unless transaction = Transaction.tl_current
|
110
110
|
|
@@ -156,13 +156,13 @@ module NewRelic
|
|
156
156
|
end
|
157
157
|
|
158
158
|
def aggregated_metric_names(txn)
|
159
|
-
metric_names = [
|
159
|
+
metric_names = ['Errors/all']
|
160
160
|
return metric_names unless txn
|
161
161
|
|
162
162
|
if txn.recording_web_transaction?
|
163
|
-
metric_names <<
|
163
|
+
metric_names << 'Errors/allWeb'
|
164
164
|
else
|
165
|
-
metric_names <<
|
165
|
+
metric_names << 'Errors/allOther'
|
166
166
|
end
|
167
167
|
|
168
168
|
metric_names
|
@@ -227,7 +227,7 @@ module NewRelic
|
|
227
227
|
def notice_error(exception, options = {}, span_id = nil)
|
228
228
|
state = ::NewRelic::Agent::Tracer.state
|
229
229
|
transaction = state.current_transaction
|
230
|
-
status_code = transaction
|
230
|
+
status_code = transaction&.http_response_code
|
231
231
|
|
232
232
|
return if skip_notice_error?(exception, status_code)
|
233
233
|
|
@@ -242,8 +242,8 @@ module NewRelic
|
|
242
242
|
noticed_error = create_noticed_error(exception, options)
|
243
243
|
error_trace_aggregator.add_to_error_queue(noticed_error)
|
244
244
|
transaction = state.current_transaction
|
245
|
-
payload = transaction
|
246
|
-
span_id ||= transaction
|
245
|
+
payload = transaction&.payload
|
246
|
+
span_id ||= transaction&.current_segment ? transaction.current_segment.guid : nil
|
247
247
|
error_event_aggregator.record(noticed_error, payload, span_id)
|
248
248
|
exception
|
249
249
|
rescue => e
|
@@ -277,7 +277,7 @@ module NewRelic
|
|
277
277
|
noticed_error.line_number = sense_method(exception, :line_number)
|
278
278
|
noticed_error.stack_trace = truncate_trace(extract_stack_trace(exception))
|
279
279
|
|
280
|
-
noticed_error.expected = !!options.delete(:expected) || expected?(exception)
|
280
|
+
noticed_error.expected = !!options.delete(:expected) || expected?(exception) # rubocop:disable Style/DoubleNegation
|
281
281
|
|
282
282
|
noticed_error.attributes_from_notice_error = options.delete(:custom_params) || {}
|
283
283
|
|
@@ -285,6 +285,8 @@ module NewRelic
|
|
285
285
|
# get treated as custom attributes, so merge them into that hash.
|
286
286
|
noticed_error.attributes_from_notice_error.merge!(options)
|
287
287
|
|
288
|
+
update_error_group_name(noticed_error, exception, options)
|
289
|
+
|
288
290
|
noticed_error
|
289
291
|
end
|
290
292
|
|
@@ -306,6 +308,32 @@ module NewRelic
|
|
306
308
|
@error_event_aggregator.reset!
|
307
309
|
nil
|
308
310
|
end
|
311
|
+
|
312
|
+
private
|
313
|
+
|
314
|
+
def update_error_group_name(noticed_error, exception, options)
|
315
|
+
return unless error_group_callback
|
316
|
+
|
317
|
+
callback_hash = build_customer_callback_hash(noticed_error, exception, options)
|
318
|
+
result = error_group_callback.call(callback_hash)
|
319
|
+
noticed_error.error_group = result
|
320
|
+
rescue StandardError => e
|
321
|
+
NewRelic::Agent.logger.error("Failed to obtain error group from customer callback: #{e.class} - #{e.message}")
|
322
|
+
end
|
323
|
+
|
324
|
+
def build_customer_callback_hash(noticed_error, exception, options)
|
325
|
+
{error: exception,
|
326
|
+
customAttributes: noticed_error.custom_attributes,
|
327
|
+
'request.uri': noticed_error.request_uri,
|
328
|
+
'http.statusCode': noticed_error.agent_attributes[:'http.statusCode'],
|
329
|
+
'http.method': noticed_error.intrinsic_attributes[:'http.method'],
|
330
|
+
'error.expected': noticed_error.expected,
|
331
|
+
options: options}
|
332
|
+
end
|
333
|
+
|
334
|
+
def error_group_callback
|
335
|
+
NewRelic::Agent.error_group_callback
|
336
|
+
end
|
309
337
|
end
|
310
338
|
end
|
311
339
|
end
|
@@ -80,7 +80,7 @@ module NewRelic
|
|
80
80
|
@ignore_messages.update(errors)
|
81
81
|
log_filter(:ignore_messages, errors)
|
82
82
|
when String
|
83
|
-
if
|
83
|
+
if /^[\d\,\-]+$/.match?(errors)
|
84
84
|
@ignore_status_codes |= parse_status_codes(errors)
|
85
85
|
log_filter(:ignore_status_codes, errors)
|
86
86
|
else
|
@@ -104,7 +104,7 @@ module NewRelic
|
|
104
104
|
@expected_messages.update(errors)
|
105
105
|
log_filter(:expected_messages, errors)
|
106
106
|
when String
|
107
|
-
if
|
107
|
+
if /^[\d\,\-]+$/.match?(errors)
|
108
108
|
@expected_status_codes |= parse_status_codes(errors)
|
109
109
|
log_filter(:expected_status_codes, errors)
|
110
110
|
else
|
@@ -81,13 +81,14 @@ module NewRelic
|
|
81
81
|
# Already seen this class once? Bail!
|
82
82
|
return if @errors.any? { |err| err.exception_class_name == exception.class.name }
|
83
83
|
|
84
|
-
|
85
|
-
|
86
|
-
noticed_error.stack_trace =
|
84
|
+
noticed_error = NewRelic::Agent.instance.error_collector.create_noticed_error(exception,
|
85
|
+
{metric: 'NewRelic/AgentError'})
|
86
|
+
noticed_error.stack_trace = caller.dup unless exception.backtrace
|
87
|
+
|
87
88
|
@errors << noticed_error
|
88
89
|
end
|
89
90
|
rescue => e
|
90
|
-
NewRelic::Agent.logger.info(
|
91
|
+
NewRelic::Agent.logger.info('Unable to capture internal agent error due to an exception:', e)
|
91
92
|
end
|
92
93
|
|
93
94
|
def register_config_callbacks
|
@@ -96,7 +96,7 @@ module NewRelic
|
|
96
96
|
end
|
97
97
|
|
98
98
|
def run
|
99
|
-
::NewRelic::Agent.logger.debug(
|
99
|
+
::NewRelic::Agent.logger.debug('Running event loop')
|
100
100
|
while !stopped?
|
101
101
|
run_once
|
102
102
|
end
|
@@ -161,7 +161,7 @@ module NewRelic
|
|
161
161
|
end
|
162
162
|
|
163
163
|
def reschedule_timer_for_event(e)
|
164
|
-
@timers[e]
|
164
|
+
@timers[e]&.reschedule
|
165
165
|
end
|
166
166
|
|
167
167
|
def on(event, &blk)
|
@@ -187,7 +187,7 @@ module NewRelic
|
|
187
187
|
begin
|
188
188
|
@self_pipe_wr.write_nonblock('.')
|
189
189
|
rescue Errno::EAGAIN
|
190
|
-
::NewRelic::Agent.logger.debug(
|
190
|
+
::NewRelic::Agent.logger.debug('Failed to wakeup event loop')
|
191
191
|
end
|
192
192
|
end
|
193
193
|
end
|
@@ -14,9 +14,7 @@ module NewRelic
|
|
14
14
|
@starting_pid = nil
|
15
15
|
@after_forker = after_forker
|
16
16
|
|
17
|
-
|
18
|
-
events.subscribe(:start_transaction, &method(:on_transaction))
|
19
|
-
end
|
17
|
+
events&.subscribe(:start_transaction, &method(:on_transaction))
|
20
18
|
end
|
21
19
|
|
22
20
|
def on_transaction(*_)
|
data/lib/new_relic/agent/heap.rb
CHANGED
@@ -26,7 +26,8 @@ module NewRelic
|
|
26
26
|
def initialize(items = nil, &priority_fn)
|
27
27
|
@items = []
|
28
28
|
@priority_fn = priority_fn || ->(x) { x }
|
29
|
-
|
29
|
+
# the following line needs else branch coverage
|
30
|
+
items.each { |item| push(item) } if items # rubocop:disable Style/SafeNavigation
|
30
31
|
end
|
31
32
|
|
32
33
|
def [](index)
|
@@ -5,8 +5,8 @@
|
|
5
5
|
module NewRelic
|
6
6
|
module Agent
|
7
7
|
module HTTPClients
|
8
|
-
MUST_IMPLEMENT_ERROR =
|
9
|
-
WHINY_NIL_ERROR =
|
8
|
+
MUST_IMPLEMENT_ERROR = 'Subclasses of %s must implement a :%s method'
|
9
|
+
WHINY_NIL_ERROR = '%s cannot initialize with a nil wrapped_response object.'
|
10
10
|
|
11
11
|
# This class provides a public interface for wrapping HTTP requests. This
|
12
12
|
# may be used to create wrappers that are compatible with New Relic's
|
@@ -14,28 +14,16 @@ module NewRelic
|
|
14
14
|
#
|
15
15
|
# @api public
|
16
16
|
class AbstractRequest
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
def []=
|
22
|
-
raise NotImplementedError, MUST_IMPLEMENT_ERROR % [self.class, __method__]
|
23
|
-
end
|
24
|
-
|
25
|
-
def type
|
26
|
-
raise NotImplementedError, MUST_IMPLEMENT_ERROR % [self.class, __method__]
|
27
|
-
end
|
28
|
-
|
29
|
-
def host_from_header
|
30
|
-
raise NotImplementedError, MUST_IMPLEMENT_ERROR % [self.class, __method__]
|
17
|
+
%i[[] []= type host_from_header host method headers uri].each do |name|
|
18
|
+
define_method(name) do
|
19
|
+
not_implemented(name)
|
20
|
+
end
|
31
21
|
end
|
32
22
|
|
33
|
-
|
34
|
-
raise NotImplementedError, MUST_IMPLEMENT_ERROR % [self.class, __method__]
|
35
|
-
end
|
23
|
+
private
|
36
24
|
|
37
|
-
def
|
38
|
-
raise NotImplementedError, MUST_IMPLEMENT_ERROR % [self.class,
|
25
|
+
def not_implemented(method_name)
|
26
|
+
raise NotImplementedError, MUST_IMPLEMENT_ERROR % [self.class, method_name]
|
39
27
|
end
|
40
28
|
end
|
41
29
|
|
@@ -33,16 +33,20 @@ module NewRelic
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def [](key)
|
36
|
-
|
36
|
+
headers[key]
|
37
37
|
end
|
38
38
|
|
39
39
|
def []=(key, value)
|
40
|
-
|
40
|
+
headers[key] = value
|
41
41
|
end
|
42
42
|
|
43
43
|
def uri
|
44
44
|
@uri ||= URIUtil.parse_and_normalize_url(@curlobj.url)
|
45
45
|
end
|
46
|
+
|
47
|
+
def headers
|
48
|
+
@curlobj.headers
|
49
|
+
end
|
46
50
|
end
|
47
51
|
|
48
52
|
class CurbResponse < AbstractResponse
|
@@ -62,7 +66,7 @@ module NewRelic
|
|
62
66
|
def append_header_data(data)
|
63
67
|
key, value = data.split(/:\s*/, 2)
|
64
68
|
@headers[key.downcase] = value
|
65
|
-
@wrapped_response._nr_header_str ||=
|
69
|
+
@wrapped_response._nr_header_str ||= +''
|
66
70
|
@wrapped_response._nr_header_str << data
|
67
71
|
end
|
68
72
|
|
@@ -46,7 +46,7 @@ module NewRelic
|
|
46
46
|
class ExconHTTPRequest < AbstractRequest
|
47
47
|
attr_reader :method
|
48
48
|
|
49
|
-
EXCON =
|
49
|
+
EXCON = 'Excon'
|
50
50
|
LHOST = 'host'
|
51
51
|
UHOST = 'Host'
|
52
52
|
COLON = ':'
|
@@ -65,7 +65,6 @@ module NewRelic
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def host_from_header
|
68
|
-
headers = @datum[:headers]
|
69
68
|
if hostname = (headers[LHOST] || headers[UHOST])
|
70
69
|
hostname.split(COLON).first
|
71
70
|
end
|
@@ -76,18 +75,21 @@ module NewRelic
|
|
76
75
|
end
|
77
76
|
|
78
77
|
def [](key)
|
79
|
-
|
78
|
+
headers[key]
|
80
79
|
end
|
81
80
|
|
82
81
|
def []=(key, value)
|
83
|
-
|
84
|
-
@datum[:headers][key] = value
|
82
|
+
headers[key] = value
|
85
83
|
end
|
86
84
|
|
87
85
|
def uri
|
88
86
|
url = "#{@scheme}://#{host}:#{@port}#{@path}"
|
89
87
|
URIUtil.parse_and_normalize_url(url)
|
90
88
|
end
|
89
|
+
|
90
|
+
def headers
|
91
|
+
@datum[:headers]
|
92
|
+
end
|
91
93
|
end
|
92
94
|
end
|
93
95
|
end
|
@@ -25,7 +25,7 @@ module NewRelic
|
|
25
25
|
class HTTPClientRequest < AbstractRequest
|
26
26
|
attr_reader :request
|
27
27
|
|
28
|
-
HTTP_CLIENT =
|
28
|
+
HTTP_CLIENT = 'HTTPClient'.freeze
|
29
29
|
LHOST = 'host'.freeze
|
30
30
|
UHOST = 'Host'.freeze
|
31
31
|
COLON = ':'.freeze
|
@@ -57,12 +57,16 @@ module NewRelic
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def [](key)
|
60
|
-
|
60
|
+
headers[key]
|
61
61
|
end
|
62
62
|
|
63
63
|
def []=(key, value)
|
64
64
|
request.http_header[key] = value
|
65
65
|
end
|
66
|
+
|
67
|
+
def headers
|
68
|
+
request.headers
|
69
|
+
end
|
66
70
|
end
|
67
71
|
end
|
68
72
|
end
|
@@ -61,7 +61,7 @@ module NewRelic
|
|
61
61
|
::NewRelic::Agent::HTTPClients::URIUtil.parse_and_normalize_url(@request.path)
|
62
62
|
else
|
63
63
|
connection_address = @connection.address
|
64
|
-
if
|
64
|
+
if Resolv::IPv6::Regex.match?(connection_address)
|
65
65
|
connection_address = "[#{connection_address}]"
|
66
66
|
end
|
67
67
|
|
@@ -71,6 +71,10 @@ module NewRelic
|
|
71
71
|
)
|
72
72
|
end
|
73
73
|
end
|
74
|
+
|
75
|
+
def headers
|
76
|
+
@request.instance_variable_get(:@header)
|
77
|
+
end
|
74
78
|
end
|
75
79
|
end
|
76
80
|
end
|
@@ -42,7 +42,7 @@ module NewRelic
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
TYPHOEUS =
|
45
|
+
TYPHOEUS = 'Typhoeus'.freeze
|
46
46
|
|
47
47
|
def type
|
48
48
|
TYPHOEUS
|
@@ -66,14 +66,17 @@ module NewRelic
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def [](key)
|
69
|
-
return nil unless @request.options &&
|
69
|
+
return nil unless @request.options && headers
|
70
70
|
|
71
|
-
|
71
|
+
headers[key]
|
72
72
|
end
|
73
73
|
|
74
74
|
def []=(key, value)
|
75
|
-
|
76
|
-
|
75
|
+
headers[key] = value
|
76
|
+
end
|
77
|
+
|
78
|
+
def headers
|
79
|
+
@request.options[:headers] || {}
|
77
80
|
end
|
78
81
|
|
79
82
|
def uri
|
@@ -36,11 +36,11 @@ module NewRelic
|
|
36
36
|
uri = ::URI.parse(url)
|
37
37
|
end
|
38
38
|
end
|
39
|
-
uri.host
|
39
|
+
uri.host&.downcase!
|
40
40
|
uri
|
41
41
|
end
|
42
42
|
|
43
|
-
QUESTION_MARK =
|
43
|
+
QUESTION_MARK = '?'
|
44
44
|
|
45
45
|
def self.strip_query_string(fragment)
|
46
46
|
if fragment.include?(QUESTION_MARK)
|
@@ -27,11 +27,14 @@ module NewRelic
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def controller_name_for_metric(payload)
|
30
|
+
return unless payload
|
30
31
|
# redirect_to
|
31
|
-
return payload[:request].controller_class.controller_path if payload[:request] && payload[:request].controller_class
|
32
|
+
return payload[:request].controller_class.controller_path if payload[:request].respond_to?(:controller_class) && payload[:request].controller_class&.respond_to?(:controller_path)
|
32
33
|
|
33
34
|
# unpermitted_parameters
|
34
|
-
|
35
|
+
if payload[:context]&.[](:controller) && constantized_class = ::NewRelic::LanguageSupport.constantize(payload[:context][:controller])
|
36
|
+
constantized_class.respond_to?(:controller_path) ? constantized_class.controller_path : nil
|
37
|
+
end
|
35
38
|
end
|
36
39
|
end
|
37
40
|
end
|
@@ -19,7 +19,7 @@ module NewRelic
|
|
19
19
|
else
|
20
20
|
# if this transaction is ignored, make sure child
|
21
21
|
# transaction are also ignored
|
22
|
-
state.current_transaction
|
22
|
+
state.current_transaction&.ignore!
|
23
23
|
NewRelic::Agent.instance.push_trace_execution_flag(false)
|
24
24
|
end
|
25
25
|
rescue => e
|
@@ -90,7 +90,8 @@ module NewRelic
|
|
90
90
|
end
|
91
91
|
|
92
92
|
def queue_start(request)
|
93
|
-
|
93
|
+
# the following line needs else branch coverage
|
94
|
+
if request && request.respond_to?(:env) # rubocop:disable Style/SafeNavigation
|
94
95
|
QueueTime.parse_frontend_timestamp(request.env, Process.clock_gettime(Process::CLOCK_REALTIME))
|
95
96
|
end
|
96
97
|
end
|
@@ -75,7 +75,7 @@ module NewRelic
|
|
75
75
|
# so do not mistake rendering a collection for rendering a file.
|
76
76
|
if identifier.nil? && name != RENDER_COLLECTION_EVENT_NAME
|
77
77
|
'file'
|
78
|
-
elsif
|
78
|
+
elsif /template$/.match?(identifier)
|
79
79
|
identifier
|
80
80
|
elsif identifier && (parts = identifier.split('/')).size > 1
|
81
81
|
parts[-2..-1].join('/')
|
@@ -99,11 +99,11 @@ module NewRelic
|
|
99
99
|
end
|
100
100
|
|
101
101
|
def finish
|
102
|
-
@finishable
|
102
|
+
@finishable&.finish
|
103
103
|
end
|
104
104
|
|
105
105
|
def notice_error(error)
|
106
|
-
@finishable
|
106
|
+
@finishable&.notice_error(error)
|
107
107
|
end
|
108
108
|
end
|
109
109
|
end
|
@@ -57,7 +57,7 @@ module NewRelic
|
|
57
57
|
|
58
58
|
# Don't nest transactions if we're already in a web transaction.
|
59
59
|
# Probably inline processing the job if that happens, so just trace.
|
60
|
-
if txn
|
60
|
+
if txn&.recording_web_transaction?
|
61
61
|
run_in_trace(job, block, :Consume)
|
62
62
|
elsif txn && !txn.recording_web_transaction?
|
63
63
|
::NewRelic::Agent::Transaction.set_default_transaction_name(
|
@@ -27,9 +27,9 @@ DependencyDetection.defer do
|
|
27
27
|
actions = [:authorize, :purchase, :credit, :void, :capture, :recurring, :store, :unstore, :update]
|
28
28
|
actions.each do |operation|
|
29
29
|
if implemented_methods.include?(operation)
|
30
|
-
add_method_tracer operation, [->
|
31
|
-
->
|
32
|
-
->
|
30
|
+
add_method_tracer operation, [->(*) { "ActiveMerchant/gateway/#{gateway_name}/#{operation}" },
|
31
|
+
->(*) { "ActiveMerchant/gateway/#{gateway_name}" },
|
32
|
+
->(*) { "ActiveMerchant/operation/#{operation}" }]
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
@@ -13,7 +13,8 @@ module NewRelic
|
|
13
13
|
::ActiveRecord::Base.send("#{statement.config[:adapter]}_connection",
|
14
14
|
statement.config)
|
15
15
|
end
|
16
|
-
|
16
|
+
# the following line needs else branch coverage
|
17
|
+
if connection && connection.respond_to?(:execute) # rubocop:disable Style/SafeNavigation
|
17
18
|
return connection.execute("EXPLAIN #{statement.sql}")
|
18
19
|
end
|
19
20
|
end
|
@@ -43,7 +44,7 @@ module NewRelic
|
|
43
44
|
end
|
44
45
|
end
|
45
46
|
|
46
|
-
if RUBY_VERSION <
|
47
|
+
if RUBY_VERSION < '2.7.0'
|
47
48
|
def log_with_newrelic_instrumentation(*args, &block)
|
48
49
|
state = NewRelic::Agent::Tracer.state
|
49
50
|
|