newrelic_rpm 8.2.0 → 8.5.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 -1
- data/.rubocop.yml +1938 -0
- data/Brewfile +10 -0
- data/CHANGELOG.md +80 -2
- data/CONTRIBUTING.md +19 -3
- data/DOCKER.md +167 -0
- data/Dockerfile +10 -0
- data/Guardfile +8 -8
- data/Rakefile +14 -9
- data/bin/mongrel_rpm +8 -9
- data/bin/newrelic +1 -1
- data/bin/nrdebug +14 -14
- data/docker-compose.yml +85 -0
- data/init.rb +0 -2
- data/lefthook.yml +9 -0
- data/lib/new_relic/agent/adaptive_sampler.rb +7 -3
- data/lib/new_relic/agent/agent.rb +38 -40
- data/lib/new_relic/agent/agent_logger.rb +8 -9
- data/lib/new_relic/agent/attribute_filter.rb +31 -31
- data/lib/new_relic/agent/attributes.rb +2 -2
- data/lib/new_relic/agent/autostart.rb +6 -7
- data/lib/new_relic/agent/commands/agent_command.rb +2 -2
- data/lib/new_relic/agent/commands/agent_command_router.rb +6 -5
- data/lib/new_relic/agent/commands/thread_profiler_session.rb +0 -3
- data/lib/new_relic/agent/configuration/default_source.rb +347 -330
- data/lib/new_relic/agent/configuration/dotted_hash.rb +3 -3
- data/lib/new_relic/agent/configuration/environment_source.rb +3 -4
- data/lib/new_relic/agent/configuration/event_harvest_config.rb +11 -6
- data/lib/new_relic/agent/configuration/high_security_source.rb +7 -7
- data/lib/new_relic/agent/configuration/manager.rb +74 -63
- data/lib/new_relic/agent/configuration/mask_defaults.rb +1 -1
- data/lib/new_relic/agent/configuration/security_policy_source.rb +73 -73
- data/lib/new_relic/agent/configuration/server_source.rb +11 -11
- data/lib/new_relic/agent/configuration/yaml_source.rb +9 -9
- data/lib/new_relic/agent/connect/request_builder.rb +13 -16
- data/lib/new_relic/agent/connect/response_handler.rb +0 -3
- data/lib/new_relic/agent/custom_event_aggregator.rb +9 -10
- data/lib/new_relic/agent/database/explain_plan_helpers.rb +3 -4
- data/lib/new_relic/agent/database/obfuscation_helpers.rb +12 -12
- data/lib/new_relic/agent/database/postgres_explain_obfuscator.rb +2 -2
- data/lib/new_relic/agent/database.rb +20 -24
- data/lib/new_relic/agent/datastores/metric_helper.rb +10 -10
- data/lib/new_relic/agent/datastores/mongo/event_formatter.rb +2 -3
- data/lib/new_relic/agent/datastores/mongo/metric_translator.rb +3 -5
- data/lib/new_relic/agent/datastores/mongo/obfuscator.rb +1 -2
- data/lib/new_relic/agent/datastores/redis.rb +2 -4
- data/lib/new_relic/agent/datastores.rb +1 -3
- data/lib/new_relic/agent/distributed_tracing/cross_app_payload.rb +5 -5
- data/lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb +11 -10
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_attributes.rb +10 -11
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb +41 -42
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_transport_type.rb +3 -3
- data/lib/new_relic/agent/distributed_tracing/trace_context.rb +41 -43
- data/lib/new_relic/agent/distributed_tracing/trace_context_payload.rb +23 -23
- data/lib/new_relic/agent/distributed_tracing.rb +17 -18
- data/lib/new_relic/agent/encoding_normalizer.rb +1 -1
- data/lib/new_relic/agent/error_collector.rb +17 -17
- data/lib/new_relic/agent/error_event_aggregator.rb +1 -1
- data/lib/new_relic/agent/error_filter.rb +6 -8
- data/lib/new_relic/agent/error_trace_aggregator.rb +1 -1
- data/lib/new_relic/agent/event_aggregator.rb +1 -1
- data/lib/new_relic/agent/event_buffer.rb +6 -7
- data/lib/new_relic/agent/event_listener.rb +0 -1
- data/lib/new_relic/agent/event_loop.rb +10 -10
- data/lib/new_relic/agent/external.rb +1 -2
- data/lib/new_relic/agent/guid_generator.rb +2 -9
- data/lib/new_relic/agent/harvester.rb +3 -4
- data/lib/new_relic/agent/heap.rb +1 -3
- data/lib/new_relic/agent/hostname.rb +3 -3
- data/lib/new_relic/agent/http_clients/abstract.rb +5 -7
- data/lib/new_relic/agent/http_clients/curb_wrappers.rb +1 -5
- data/lib/new_relic/agent/http_clients/excon_wrappers.rb +4 -4
- data/lib/new_relic/agent/http_clients/http_rb_wrappers.rb +3 -3
- data/lib/new_relic/agent/http_clients/httpclient_wrappers.rb +1 -2
- data/lib/new_relic/agent/http_clients/net_http_wrappers.rb +2 -3
- data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +2 -3
- data/lib/new_relic/agent/http_clients/uri_util.rb +0 -1
- data/lib/new_relic/agent/instrumentation/action_cable_subscriber.rb +2 -3
- data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +9 -10
- data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +5 -7
- data/lib/new_relic/agent/instrumentation/active_job.rb +4 -4
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +2 -2
- data/lib/new_relic/agent/instrumentation/active_record.rb +20 -18
- data/lib/new_relic/agent/instrumentation/active_record_helper.rb +36 -42
- data/lib/new_relic/agent/instrumentation/active_record_notifications.rb +28 -25
- data/lib/new_relic/agent/instrumentation/active_record_prepend.rb +3 -3
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +5 -6
- data/lib/new_relic/agent/instrumentation/active_storage.rb +1 -1
- data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +8 -9
- data/lib/new_relic/agent/instrumentation/bunny/chain.rb +1 -1
- data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +7 -8
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +41 -41
- data/lib/new_relic/agent/instrumentation/curb/chain.rb +19 -20
- data/lib/new_relic/agent/instrumentation/curb/instrumentation.rb +34 -38
- data/lib/new_relic/agent/instrumentation/curb/prepend.rb +9 -10
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +10 -10
- data/lib/new_relic/agent/instrumentation/delayed_job/chain.rb +5 -7
- data/lib/new_relic/agent/instrumentation/delayed_job/instrumentation.rb +2 -6
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +4 -4
- data/lib/new_relic/agent/instrumentation/excon/middleware.rb +2 -2
- data/lib/new_relic/agent/instrumentation/excon.rb +0 -1
- data/lib/new_relic/agent/instrumentation/grape/chain.rb +1 -2
- data/lib/new_relic/agent/instrumentation/grape/instrumentation.rb +6 -7
- data/lib/new_relic/agent/instrumentation/grape.rb +2 -3
- data/lib/new_relic/agent/instrumentation/httpclient/chain.rb +2 -3
- data/lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb +0 -1
- data/lib/new_relic/agent/instrumentation/httpclient/prepend.rb +0 -2
- data/lib/new_relic/agent/instrumentation/httprb/chain.rb +2 -2
- data/lib/new_relic/agent/instrumentation/httprb/instrumentation.rb +6 -6
- data/lib/new_relic/agent/instrumentation/httprb/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/ignore_actions.rb +2 -3
- data/lib/new_relic/agent/instrumentation/logger/instrumentation.rb +0 -1
- data/lib/new_relic/agent/instrumentation/logger.rb +1 -1
- data/lib/new_relic/agent/instrumentation/memcache/dalli.rb +2 -1
- data/lib/new_relic/agent/instrumentation/memcache/helper.rb +0 -1
- data/lib/new_relic/agent/instrumentation/memcache/prepend.rb +1 -0
- data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +9 -10
- data/lib/new_relic/agent/instrumentation/middleware_tracing.rb +5 -6
- data/lib/new_relic/agent/instrumentation/mongodb_command_subscriber.rb +4 -4
- data/lib/new_relic/agent/instrumentation/net_http/chain.rb +3 -4
- data/lib/new_relic/agent/instrumentation/net_http/instrumentation.rb +5 -5
- data/lib/new_relic/agent/instrumentation/net_http/prepend.rb +4 -4
- data/lib/new_relic/agent/instrumentation/net_http.rb +1 -1
- data/lib/new_relic/agent/instrumentation/notifications_subscriber.rb +2 -3
- data/lib/new_relic/agent/instrumentation/padrino/instrumentation.rb +3 -2
- data/lib/new_relic/agent/instrumentation/padrino/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/padrino.rb +0 -5
- data/lib/new_relic/agent/instrumentation/queue_time.rb +5 -5
- data/lib/new_relic/agent/instrumentation/rack/chain.rb +5 -5
- data/lib/new_relic/agent/instrumentation/rack/helpers.rb +0 -1
- data/lib/new_relic/agent/instrumentation/rack/instrumentation.rb +4 -5
- data/lib/new_relic/agent/instrumentation/rack/prepend.rb +0 -1
- data/lib/new_relic/agent/instrumentation/rack.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +6 -6
- data/lib/new_relic/agent/instrumentation/rails_notifications/action_cable.rb +2 -2
- data/lib/new_relic/agent/instrumentation/rails_notifications/action_controller.rb +0 -1
- data/lib/new_relic/agent/instrumentation/rake/chain.rb +0 -5
- data/lib/new_relic/agent/instrumentation/rake/instrumentation.rb +6 -6
- data/lib/new_relic/agent/instrumentation/rake.rb +1 -1
- data/lib/new_relic/agent/instrumentation/redis/chain.rb +6 -6
- data/lib/new_relic/agent/instrumentation/redis/instrumentation.rb +2 -2
- data/lib/new_relic/agent/instrumentation/redis/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/redis.rb +1 -1
- data/lib/new_relic/agent/instrumentation/resque/chain.rb +2 -3
- data/lib/new_relic/agent/instrumentation/resque/helper.rb +1 -1
- data/lib/new_relic/agent/instrumentation/resque/instrumentation.rb +4 -4
- data/lib/new_relic/agent/instrumentation/resque/prepend.rb +1 -2
- data/lib/new_relic/agent/instrumentation/resque.rb +7 -7
- data/lib/new_relic/agent/instrumentation/sequel.rb +7 -9
- data/lib/new_relic/agent/instrumentation/sequel_helper.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sidekiq.rb +5 -4
- data/lib/new_relic/agent/instrumentation/sinatra/ignorer.rb +0 -1
- data/lib/new_relic/agent/instrumentation/sinatra/instrumentation.rb +4 -3
- data/lib/new_relic/agent/instrumentation/sunspot.rb +1 -1
- data/lib/new_relic/agent/instrumentation/tilt/instrumentation.rb +0 -1
- data/lib/new_relic/agent/instrumentation/typhoeus/chain.rb +4 -4
- data/lib/new_relic/agent/instrumentation/typhoeus/instrumentation.rb +3 -5
- data/lib/new_relic/agent/instrumentation/typhoeus/prepend.rb +1 -1
- data/lib/new_relic/agent/internal_agent_error.rb +1 -1
- data/lib/new_relic/agent/javascript_instrumentor.rb +28 -28
- data/lib/new_relic/agent/logging.rb +8 -4
- data/lib/new_relic/agent/memory_logger.rb +1 -1
- data/lib/new_relic/agent/messaging.rb +42 -44
- data/lib/new_relic/agent/method_tracer.rb +11 -14
- data/lib/new_relic/agent/method_tracer_helpers.rb +2 -2
- data/lib/new_relic/agent/monitors/cross_app_monitor.rb +13 -12
- data/lib/new_relic/agent/monitors/distributed_tracing_monitor.rb +2 -2
- data/lib/new_relic/agent/monitors/inbound_request_monitor.rb +0 -1
- data/lib/new_relic/agent/monitors/synthetics_monitor.rb +4 -7
- data/lib/new_relic/agent/monitors.rb +1 -2
- data/lib/new_relic/agent/new_relic_service/encoders.rb +4 -4
- data/lib/new_relic/agent/new_relic_service/json_marshaller.rb +1 -1
- data/lib/new_relic/agent/new_relic_service/marshaller.rb +1 -1
- data/lib/new_relic/agent/new_relic_service/security_policy_settings.rb +4 -3
- data/lib/new_relic/agent/new_relic_service.rb +20 -20
- data/lib/new_relic/agent/noticible_error.rb +0 -2
- data/lib/new_relic/agent/null_logger.rb +6 -2
- data/lib/new_relic/agent/obfuscator.rb +6 -8
- data/lib/new_relic/agent/parameter_filtering.rb +16 -8
- data/lib/new_relic/agent/payload_metric_mapping.rb +8 -9
- data/lib/new_relic/agent/pipe_channel_manager.rb +5 -6
- data/lib/new_relic/agent/pipe_service.rb +1 -1
- data/lib/new_relic/agent/priority_sampled_buffer.rb +4 -7
- data/lib/new_relic/agent/rules_engine/replacement_rule.rb +9 -9
- data/lib/new_relic/agent/rules_engine/segment_terms_rule.rb +12 -12
- data/lib/new_relic/agent/rules_engine.rb +2 -2
- data/lib/new_relic/agent/sampler.rb +2 -3
- data/lib/new_relic/agent/sampler_collection.rb +2 -3
- data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +3 -3
- data/lib/new_relic/agent/samplers/memory_sampler.rb +4 -3
- data/lib/new_relic/agent/samplers/vm_sampler.rb +18 -18
- data/lib/new_relic/agent/span_event_aggregator.rb +8 -8
- data/lib/new_relic/agent/span_event_primitive.rb +39 -39
- data/lib/new_relic/agent/sql_sampler.rb +9 -9
- data/lib/new_relic/agent/stats.rb +16 -16
- data/lib/new_relic/agent/stats_engine/gc_profiler.rb +7 -9
- data/lib/new_relic/agent/stats_engine/stats_hash.rb +8 -9
- data/lib/new_relic/agent/stats_engine.rb +6 -6
- data/lib/new_relic/agent/synthetics_event_aggregator.rb +1 -2
- data/lib/new_relic/agent/system_info.rb +22 -20
- data/lib/new_relic/agent/threading/agent_thread.rb +4 -5
- data/lib/new_relic/agent/threading/backtrace_node.rb +6 -9
- data/lib/new_relic/agent/threading/backtrace_service.rb +8 -8
- data/lib/new_relic/agent/threading/thread_profile.rb +15 -18
- data/lib/new_relic/agent/tracer.rb +37 -43
- data/lib/new_relic/agent/transaction/abstract_segment.rb +6 -6
- data/lib/new_relic/agent/transaction/datastore_segment.rb +5 -7
- data/lib/new_relic/agent/transaction/distributed_tracer.rb +7 -9
- data/lib/new_relic/agent/transaction/distributed_tracing.rb +21 -22
- data/lib/new_relic/agent/transaction/external_request_segment.rb +3 -5
- data/lib/new_relic/agent/transaction/message_broker_segment.rb +23 -23
- data/lib/new_relic/agent/transaction/request_attributes.rb +7 -7
- data/lib/new_relic/agent/transaction/segment.rb +3 -3
- data/lib/new_relic/agent/transaction/slowest_sample_buffer.rb +0 -2
- data/lib/new_relic/agent/transaction/trace.rb +8 -8
- data/lib/new_relic/agent/transaction/trace_context.rb +14 -16
- data/lib/new_relic/agent/transaction/trace_node.rb +16 -16
- data/lib/new_relic/agent/transaction/tracing.rb +1 -3
- data/lib/new_relic/agent/transaction/transaction_sample_buffer.rb +1 -2
- data/lib/new_relic/agent/transaction.rb +79 -81
- data/lib/new_relic/agent/transaction_error_primitive.rb +16 -16
- data/lib/new_relic/agent/transaction_event_aggregator.rb +7 -8
- data/lib/new_relic/agent/transaction_event_primitive.rb +29 -29
- data/lib/new_relic/agent/transaction_event_recorder.rb +1 -1
- data/lib/new_relic/agent/transaction_metrics.rb +3 -3
- data/lib/new_relic/agent/transaction_sampler.rb +0 -1
- data/lib/new_relic/agent/transaction_time_aggregator.rb +6 -6
- data/lib/new_relic/agent/utilization/aws.rb +32 -2
- data/lib/new_relic/agent/utilization/azure.rb +1 -1
- data/lib/new_relic/agent/utilization/vendor.rb +15 -2
- data/lib/new_relic/agent/utilization_data.rb +3 -4
- data/lib/new_relic/agent/vm/monotonic_gc_profiler.rb +1 -1
- data/lib/new_relic/agent/vm/snapshot.rb +3 -3
- data/lib/new_relic/agent/worker_loop.rb +3 -5
- data/lib/new_relic/agent.rb +22 -22
- data/lib/new_relic/cli/command.rb +15 -17
- data/lib/new_relic/cli/commands/deployments.rb +20 -22
- data/lib/new_relic/cli/commands/install.rb +6 -10
- data/lib/new_relic/coerce.rb +5 -8
- data/lib/new_relic/collection_helper.rb +48 -47
- data/lib/new_relic/control/class_methods.rb +2 -2
- data/lib/new_relic/control/frameworks/external.rb +1 -1
- data/lib/new_relic/control/frameworks/rails.rb +5 -6
- data/lib/new_relic/control/frameworks/rails3.rb +2 -3
- data/lib/new_relic/control/frameworks/ruby.rb +2 -2
- data/lib/new_relic/control/frameworks/sinatra.rb +6 -0
- data/lib/new_relic/control/instance_methods.rb +4 -5
- data/lib/new_relic/control/instrumentation.rb +4 -5
- data/lib/new_relic/control/server_methods.rb +2 -3
- data/lib/new_relic/control.rb +0 -1
- data/lib/new_relic/dependency_detection.rb +6 -8
- data/lib/new_relic/environment_report.rb +16 -18
- data/lib/new_relic/helper.rb +5 -5
- data/lib/new_relic/language_support.rb +3 -2
- data/lib/new_relic/latest_changes.rb +2 -2
- data/lib/new_relic/local_environment.rb +7 -7
- data/lib/new_relic/metric_data.rb +6 -7
- data/lib/new_relic/metric_spec.rb +3 -3
- data/lib/new_relic/noticed_error.rb +14 -15
- data/lib/new_relic/rack/agent_middleware.rb +2 -2
- data/lib/new_relic/rack/browser_monitoring.rb +9 -9
- data/lib/new_relic/recipes/capistrano3.rb +11 -13
- data/lib/new_relic/recipes/capistrano_legacy.rb +11 -14
- data/lib/new_relic/supportability_helper.rb +1 -2
- data/lib/new_relic/version.rb +4 -15
- data/lib/sequel/extensions/newrelic_instrumentation.rb +4 -7
- data/lib/sequel/plugins/newrelic_instrumentation.rb +3 -9
- data/lib/tasks/all.rb +1 -1
- data/lib/tasks/config.rake +21 -21
- data/lib/tasks/multiverse.rb +4 -6
- data/lib/tasks/tests.rake +3 -7
- data/newrelic.yml +3 -3
- data/newrelic_rpm.gemspec +13 -12
- data/recipes/newrelic.rb +1 -1
- data/test/agent_helper.rb +55 -55
- metadata +38 -4
@@ -24,10 +24,10 @@ module NewRelic
|
|
24
24
|
|
25
25
|
@error_filter = NewRelic::Agent::ErrorFilter.new
|
26
26
|
|
27
|
-
%w
|
27
|
+
%w[
|
28
28
|
ignore_errors ignore_classes ignore_messages ignore_status_codes
|
29
29
|
expected_classes expected_messages expected_status_codes
|
30
|
-
|
30
|
+
].each do |w|
|
31
31
|
Agent.config.register_callback(:"error_collector.#{w}") do |value|
|
32
32
|
@error_filter.load_from_config(w, value)
|
33
33
|
end
|
@@ -165,10 +165,10 @@ module NewRelic
|
|
165
165
|
end
|
166
166
|
|
167
167
|
# Increments a statistic that tracks total error rate
|
168
|
-
def increment_error_count!(state, exception, options={})
|
168
|
+
def increment_error_count!(state, exception, options = {})
|
169
169
|
txn = state.current_transaction
|
170
170
|
|
171
|
-
metric_names
|
171
|
+
metric_names = aggregated_metric_names(txn)
|
172
172
|
blamed_metric = blamed_metric_name(txn, options)
|
173
173
|
metric_names << blamed_metric if blamed_metric
|
174
174
|
|
@@ -187,9 +187,9 @@ module NewRelic
|
|
187
187
|
|
188
188
|
def skip_notice_error?(exception, status_code = nil)
|
189
189
|
disabled? ||
|
190
|
-
|
191
|
-
|
192
|
-
|
190
|
+
exception.nil? ||
|
191
|
+
exception_tagged_with?(EXCEPTION_TAG_IVAR, exception) ||
|
192
|
+
error_is_ignored?(exception, status_code)
|
193
193
|
end
|
194
194
|
|
195
195
|
# calls a method on an object, if it responds to it - used for
|
@@ -202,14 +202,14 @@ module NewRelic
|
|
202
202
|
# extracts a stack trace from the exception for debugging purposes
|
203
203
|
def extract_stack_trace(exception)
|
204
204
|
actual_exception = if defined?(Rails::VERSION::MAJOR) && Rails::VERSION::MAJOR < 5
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
205
|
+
sense_method(exception, :original_exception) || exception
|
206
|
+
else
|
207
|
+
exception
|
208
|
+
end
|
209
209
|
sense_method(actual_exception, :backtrace) || '<no stack trace>'
|
210
210
|
end
|
211
211
|
|
212
|
-
def notice_segment_error(segment, exception, options={})
|
212
|
+
def notice_segment_error(segment, exception, options = {})
|
213
213
|
return if skip_notice_error?(exception)
|
214
214
|
|
215
215
|
segment.set_noticed_error create_noticed_error(exception, options)
|
@@ -220,7 +220,7 @@ module NewRelic
|
|
220
220
|
end
|
221
221
|
|
222
222
|
# See NewRelic::Agent.notice_error for options and commentary
|
223
|
-
def notice_error(exception, options={}, span_id=nil)
|
223
|
+
def notice_error(exception, options = {}, span_id = nil)
|
224
224
|
state = ::NewRelic::Agent::Tracer.state
|
225
225
|
transaction = state.current_transaction
|
226
226
|
status_code = transaction ? transaction.http_response_code : nil
|
@@ -239,7 +239,7 @@ module NewRelic
|
|
239
239
|
error_trace_aggregator.add_to_error_queue(noticed_error)
|
240
240
|
transaction = state.current_transaction
|
241
241
|
payload = transaction ? transaction.payload : nil
|
242
|
-
span_id ||=
|
242
|
+
span_id ||= transaction && transaction.current_segment ? transaction.current_segment.guid : nil
|
243
243
|
error_event_aggregator.record(noticed_error, payload, span_id)
|
244
244
|
exception
|
245
245
|
rescue => e
|
@@ -247,7 +247,7 @@ module NewRelic
|
|
247
247
|
nil
|
248
248
|
end
|
249
249
|
|
250
|
-
def truncate_trace(trace, keep_frames=nil)
|
250
|
+
def truncate_trace(trace, keep_frames = nil)
|
251
251
|
keep_frames ||= Agent.config[:'error_collector.max_backtrace_frames']
|
252
252
|
return trace if !keep_frames || trace.length < keep_frames || trace.length == 0
|
253
253
|
|
@@ -267,9 +267,9 @@ module NewRelic
|
|
267
267
|
noticed_error = NewRelic::NoticedError.new(error_metric, exception)
|
268
268
|
noticed_error.request_uri = options.delete(:uri) || NewRelic::EMPTY_STR
|
269
269
|
noticed_error.request_port = options.delete(:port)
|
270
|
-
noticed_error.attributes
|
270
|
+
noticed_error.attributes = options.delete(:attributes)
|
271
271
|
|
272
|
-
noticed_error.file_name
|
272
|
+
noticed_error.file_name = sense_method(exception, :file_name)
|
273
273
|
noticed_error.line_number = sense_method(exception, :line_number)
|
274
274
|
noticed_error.stack_trace = truncate_trace(extract_stack_trace(exception))
|
275
275
|
|
@@ -16,7 +16,7 @@ module NewRelic
|
|
16
16
|
named :ErrorEventAggregator
|
17
17
|
capacity_key :'error_collector.max_event_samples_stored'
|
18
18
|
enabled_keys :'error_collector.enabled',
|
19
|
-
|
19
|
+
:'error_collector.capture_events'
|
20
20
|
buffer_class PrioritySampledBuffer
|
21
21
|
|
22
22
|
def record noticed_error, transaction_payload = nil, span_id = nil
|
@@ -4,11 +4,9 @@
|
|
4
4
|
|
5
5
|
module NewRelic
|
6
6
|
module Agent
|
7
|
-
|
8
7
|
# Handles loading of ignored and expected errors from the agent configuration, and
|
9
8
|
# determining at runtime whether an exception is ignored or expected.
|
10
9
|
class ErrorFilter
|
11
|
-
|
12
10
|
def initialize
|
13
11
|
reset
|
14
12
|
end
|
@@ -20,10 +18,10 @@ module NewRelic
|
|
20
18
|
end
|
21
19
|
|
22
20
|
def load_all
|
23
|
-
%i
|
21
|
+
%i[
|
24
22
|
ignore_errors ignore_classes ignore_messages ignore_status_codes
|
25
23
|
expected_classes expected_messages expected_status_codes
|
26
|
-
|
24
|
+
].each { |setting| load_from_config(setting) }
|
27
25
|
end
|
28
26
|
|
29
27
|
def load_from_config(setting, value = nil)
|
@@ -127,7 +125,7 @@ module NewRelic
|
|
127
125
|
::NewRelic::Agent.logger.debug("Ignoring errors of type '#{error}'")
|
128
126
|
end
|
129
127
|
when :ignore_messages
|
130
|
-
errors.each do |error,messages|
|
128
|
+
errors.each do |error, messages|
|
131
129
|
::NewRelic::Agent.logger.debug("Ignoring errors of type '#{error}' with messages: #{messages.join(',')}")
|
132
130
|
end
|
133
131
|
when :ignore_status_codes
|
@@ -137,7 +135,7 @@ module NewRelic
|
|
137
135
|
::NewRelic::Agent.logger.debug("Expecting errors of type '#{error}'")
|
138
136
|
end
|
139
137
|
when :expected_messages
|
140
|
-
errors.each do |error,messages|
|
138
|
+
errors.each do |error, messages|
|
141
139
|
::NewRelic::Agent.logger.debug("Expecting errors of type '#{error}' with messages: #{messages.join(',')}")
|
142
140
|
end
|
143
141
|
when :expected_status_codes
|
@@ -153,7 +151,7 @@ module NewRelic
|
|
153
151
|
[codes]
|
154
152
|
else
|
155
153
|
codes
|
156
|
-
|
154
|
+
end
|
157
155
|
result = []
|
158
156
|
code_list.each do |code|
|
159
157
|
result << code && next if code.is_a?(Integer)
|
@@ -172,4 +170,4 @@ module NewRelic
|
|
172
170
|
end
|
173
171
|
end
|
174
172
|
end
|
175
|
-
end
|
173
|
+
end
|
@@ -54,7 +54,7 @@ module NewRelic
|
|
54
54
|
# checks the size of the error queue to make sure we are under
|
55
55
|
# the maximum limit, and logs a warning if we are over the limit.
|
56
56
|
def over_queue_limit?(message)
|
57
|
-
over_limit = (@errors.reject{|err| err.is_internal}.length >= @capacity)
|
57
|
+
over_limit = (@errors.reject { |err| err.is_internal }.length >= @capacity)
|
58
58
|
if over_limit
|
59
59
|
::NewRelic::Agent.logger.warn("The error reporting queue has reached #{@capacity}. The error detail for this and subsequent errors will not be transmitted to New Relic until the queued errors have been sent: #{message}")
|
60
60
|
end
|
@@ -22,22 +22,22 @@ module NewRelic
|
|
22
22
|
|
23
23
|
def initialize(capacity)
|
24
24
|
@capacity = capacity
|
25
|
-
@items
|
26
|
-
@seen
|
25
|
+
@items = []
|
26
|
+
@seen = 0
|
27
27
|
end
|
28
28
|
|
29
29
|
def reset!
|
30
30
|
@items = []
|
31
|
-
@seen
|
31
|
+
@seen = 0
|
32
32
|
end
|
33
33
|
|
34
34
|
def capacity=(new_capacity)
|
35
35
|
@capacity = new_capacity
|
36
36
|
old_items = @items
|
37
|
-
@items
|
38
|
-
old_seen
|
37
|
+
@items = []
|
38
|
+
old_seen = @seen
|
39
39
|
old_items.each { |i| append(i) }
|
40
|
-
@seen
|
40
|
+
@seen = old_seen
|
41
41
|
end
|
42
42
|
|
43
43
|
def append(x)
|
@@ -88,4 +88,3 @@ module NewRelic
|
|
88
88
|
end
|
89
89
|
end
|
90
90
|
end
|
91
|
-
|
@@ -10,11 +10,11 @@ module NewRelic
|
|
10
10
|
class Timer
|
11
11
|
attr_reader :next_fire_time, :event, :interval, :last_fired_at
|
12
12
|
|
13
|
-
def initialize(interval, event, repeat=false)
|
14
|
-
@interval
|
15
|
-
@event
|
16
|
-
@repeat
|
17
|
-
@started_at
|
13
|
+
def initialize(interval, event, repeat = false)
|
14
|
+
@interval = interval
|
15
|
+
@event = event
|
16
|
+
@repeat = repeat
|
17
|
+
@started_at = Process.clock_gettime(Process::CLOCK_REALTIME)
|
18
18
|
@last_fired_at = nil
|
19
19
|
reschedule
|
20
20
|
end
|
@@ -45,7 +45,7 @@ module NewRelic
|
|
45
45
|
@last_fired_at = Process.clock_gettime(Process::CLOCK_REALTIME)
|
46
46
|
end
|
47
47
|
|
48
|
-
def due?(now=Process.clock_gettime(Process::CLOCK_REALTIME))
|
48
|
+
def due?(now = Process.clock_gettime(Process::CLOCK_REALTIME))
|
49
49
|
now >= @next_fire_time
|
50
50
|
end
|
51
51
|
|
@@ -57,10 +57,10 @@ module NewRelic
|
|
57
57
|
def initialize
|
58
58
|
@self_pipe_rd, @self_pipe_wr = IO.pipe
|
59
59
|
@event_queue = Queue.new
|
60
|
-
@stopped
|
61
|
-
@timers
|
60
|
+
@stopped = false
|
61
|
+
@timers = {}
|
62
62
|
|
63
|
-
@subscriptions = Hash.new { |h,k| h[k] = [] }
|
63
|
+
@subscriptions = Hash.new { |h, k| h[k] = [] }
|
64
64
|
@subscriptions[:__add_timer] << Proc.new { |t| set_timer(t) }
|
65
65
|
@subscriptions[:__add_event] << Proc.new { |e, blk| @subscriptions[e] << blk }
|
66
66
|
end
|
@@ -100,7 +100,7 @@ module NewRelic
|
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
|
-
def run_once(nonblock=false)
|
103
|
+
def run_once(nonblock = false)
|
104
104
|
wait_to_run(nonblock)
|
105
105
|
|
106
106
|
prune_timers
|
@@ -18,7 +18,7 @@ module NewRelic
|
|
18
18
|
module External
|
19
19
|
extend self
|
20
20
|
|
21
|
-
NON_HTTP_CAT_ID_HEADER
|
21
|
+
NON_HTTP_CAT_ID_HEADER = 'NewRelicID'.freeze
|
22
22
|
NON_HTTP_CAT_TXN_HEADER = 'NewRelicTransaction'.freeze
|
23
23
|
NON_HTTP_CAT_SYNTHETICS_HEADER = 'NewRelicSynthetics'.freeze
|
24
24
|
NON_HTTP_CAT_CONTENT_LENGTH = -1
|
@@ -105,7 +105,6 @@ module NewRelic
|
|
105
105
|
def obfuscator
|
106
106
|
CrossAppTracing.obfuscator
|
107
107
|
end
|
108
|
-
|
109
108
|
end
|
110
109
|
end
|
111
110
|
end
|
@@ -5,9 +5,6 @@
|
|
5
5
|
module NewRelic
|
6
6
|
module Agent
|
7
7
|
module GuidGenerator
|
8
|
-
|
9
|
-
HEX_DIGITS = (0..15).map{|i| i.to_s(16)}
|
10
|
-
|
11
8
|
module_function
|
12
9
|
|
13
10
|
# This method intentionally does not use SecureRandom, because it relies
|
@@ -16,13 +13,9 @@ module NewRelic
|
|
16
13
|
# The guids generated by this method may not be _secure_, but they are
|
17
14
|
# random enough for our purposes.
|
18
15
|
def generate_guid length = 16
|
19
|
-
guid =
|
20
|
-
length.
|
21
|
-
guid << HEX_DIGITS[rand(16)]
|
22
|
-
end
|
23
|
-
guid
|
16
|
+
guid = rand(16**length).to_s(16)
|
17
|
+
guid.length < length ? guid.rjust(length, "0") : guid
|
24
18
|
end
|
25
|
-
|
26
19
|
end
|
27
20
|
end
|
28
21
|
end
|
@@ -5,11 +5,10 @@
|
|
5
5
|
module NewRelic
|
6
6
|
module Agent
|
7
7
|
class Harvester
|
8
|
-
|
9
8
|
attr_accessor :starting_pid
|
10
9
|
|
11
10
|
# Inject target for after_fork call to avoid spawning thread in tests
|
12
|
-
def initialize(events, after_forker=NewRelic::Agent)
|
11
|
+
def initialize(events, after_forker = NewRelic::Agent)
|
13
12
|
# We intentionally don't set our pid as started at this point.
|
14
13
|
# Startup routines must call mark_started when they consider us set!
|
15
14
|
@starting_pid = nil
|
@@ -22,8 +21,8 @@ module NewRelic
|
|
22
21
|
|
23
22
|
def on_transaction(*_)
|
24
23
|
return unless restart_in_children_enabled? &&
|
25
|
-
|
26
|
-
|
24
|
+
needs_restart? &&
|
25
|
+
harvest_thread_enabled?
|
27
26
|
|
28
27
|
restart_harvest_thread
|
29
28
|
end
|
data/lib/new_relic/agent/heap.rb
CHANGED
@@ -18,7 +18,6 @@ module NewRelic
|
|
18
18
|
#
|
19
19
|
|
20
20
|
class Heap
|
21
|
-
|
22
21
|
# @param [Array] items an optional array of items to intialize the heap
|
23
22
|
#
|
24
23
|
# @param [Callable] priority_fn an optional priority function used to
|
@@ -27,7 +26,7 @@ module NewRelic
|
|
27
26
|
def initialize(items = nil, &priority_fn)
|
28
27
|
@items = []
|
29
28
|
@priority_fn = priority_fn || ->(x) { x }
|
30
|
-
items.each{ |item| push(item) } if items
|
29
|
+
items.each { |item| push(item) } if items
|
31
30
|
end
|
32
31
|
|
33
32
|
def [](index)
|
@@ -135,6 +134,5 @@ module NewRelic
|
|
135
134
|
@items[i], @items[j] = @items[j], @items[i]
|
136
135
|
end
|
137
136
|
end
|
138
|
-
|
139
137
|
end
|
140
138
|
end
|
@@ -19,11 +19,11 @@ module NewRelic
|
|
19
19
|
|
20
20
|
# calling hostname with -f on some OS's (NetBSD, FreeBSD, Solaris)
|
21
21
|
# produces invalid option error, but doesn't raise exception. Instead,
|
22
|
-
# we get back empty string. So, solution here is to check for non-zero
|
22
|
+
# we get back empty string. So, solution here is to check for non-zero
|
23
23
|
# exit status and retry the command without the -f flag.
|
24
24
|
def self.get_fqdn
|
25
|
-
fqdn = %x
|
26
|
-
fqdn = %x
|
25
|
+
fqdn = %x(hostname -f 2>/dev/null).chomp!
|
26
|
+
fqdn = %x(hostname).chomp! unless $?.exitstatus.zero?
|
27
27
|
fqdn
|
28
28
|
rescue => e
|
29
29
|
NewRelic::Agent.logger.debug "Unable to determine fqdn #{e}"
|
@@ -15,7 +15,6 @@ module NewRelic
|
|
15
15
|
#
|
16
16
|
# @api public
|
17
17
|
class AbstractRequest
|
18
|
-
|
19
18
|
def []
|
20
19
|
raise NotImplementedError, MUST_IMPLEMENT_ERROR % [self.class, __method__]
|
21
20
|
end
|
@@ -41,13 +40,12 @@ module NewRelic
|
|
41
40
|
end
|
42
41
|
end
|
43
42
|
|
44
|
-
# This class implements the adaptor pattern and is used internally provide
|
43
|
+
# This class implements the adaptor pattern and is used internally provide
|
45
44
|
# uniform access to the underlying HTTP Client's response object
|
46
45
|
# NOTE: response_object should be non-nil!
|
47
46
|
class AbstractResponse # :nodoc:
|
48
|
-
|
49
47
|
def initialize(wrapped_response)
|
50
|
-
if wrapped_response.nil?
|
48
|
+
if wrapped_response.nil?
|
51
49
|
raise ArgumentError, WHINY_NIL_ERROR % self.class
|
52
50
|
end
|
53
51
|
@wrapped_response = wrapped_response
|
@@ -57,13 +55,13 @@ module NewRelic
|
|
57
55
|
!!status_code
|
58
56
|
end
|
59
57
|
|
60
|
-
# most HTTP client libraries report the HTTP status code as an integer, so
|
58
|
+
# most HTTP client libraries report the HTTP status code as an integer, so
|
61
59
|
# we expect status_code to be set only if a non-zero value is present
|
62
60
|
def status_code
|
63
61
|
@status_code ||= get_status_code
|
64
62
|
end
|
65
63
|
|
66
|
-
private
|
64
|
+
private
|
67
65
|
|
68
66
|
def get_status_code_using(method_name)
|
69
67
|
return unless @wrapped_response.respond_to?(method_name)
|
@@ -71,7 +69,7 @@ module NewRelic
|
|
71
69
|
code == 0 ? nil : code
|
72
70
|
end
|
73
71
|
|
74
|
-
# Override this method to memoize a non-zero Integer representation
|
72
|
+
# Override this method to memoize a non-zero Integer representation
|
75
73
|
# of HTTP status code from the response object
|
76
74
|
def get_status_code
|
77
75
|
get_status_code_using :code
|
@@ -8,7 +8,6 @@ require_relative 'abstract'
|
|
8
8
|
module NewRelic
|
9
9
|
module Agent
|
10
10
|
module HTTPClients
|
11
|
-
|
12
11
|
class CurbRequest
|
13
12
|
CURB = 'Curb'
|
14
13
|
LHOST = 'host'
|
@@ -34,7 +33,7 @@ module NewRelic
|
|
34
33
|
@curlobj._nr_http_verb
|
35
34
|
end
|
36
35
|
|
37
|
-
def [](
|
36
|
+
def [](key)
|
38
37
|
@curlobj.headers[key]
|
39
38
|
end
|
40
39
|
|
@@ -48,7 +47,6 @@ module NewRelic
|
|
48
47
|
end
|
49
48
|
|
50
49
|
class CurbResponse < AbstractResponse
|
51
|
-
|
52
50
|
def initialize wrapped_response
|
53
51
|
super wrapped_response
|
54
52
|
@headers = {}
|
@@ -75,8 +73,6 @@ module NewRelic
|
|
75
73
|
get_status_code_using :response_code
|
76
74
|
end
|
77
75
|
end
|
78
|
-
|
79
76
|
end
|
80
|
-
|
81
77
|
end
|
82
78
|
end
|
@@ -31,8 +31,8 @@ module NewRelic
|
|
31
31
|
private
|
32
32
|
|
33
33
|
def get_attribute name
|
34
|
-
if @wrapped_response.respond_to?(name)
|
35
|
-
@wrapped_response.send(name)
|
34
|
+
if @wrapped_response.respond_to?(name)
|
35
|
+
@wrapped_response.send(name)
|
36
36
|
else
|
37
37
|
@wrapped_response[name]
|
38
38
|
end
|
@@ -57,8 +57,8 @@ module NewRelic
|
|
57
57
|
|
58
58
|
@method = @datum[:method].to_s.upcase
|
59
59
|
@scheme = @datum[:scheme]
|
60
|
-
@port
|
61
|
-
@path
|
60
|
+
@port = @datum[:port]
|
61
|
+
@path = @datum[:path]
|
62
62
|
end
|
63
63
|
|
64
64
|
def type
|
@@ -10,7 +10,7 @@ module NewRelic
|
|
10
10
|
module HTTPClients
|
11
11
|
class HTTPResponse < AbstractResponse
|
12
12
|
def [](key)
|
13
|
-
_, value = @wrapped_response.headers.find{ |k, _| key.downcase == k.downcase }
|
13
|
+
_, value = @wrapped_response.headers.find { |k, _| key.downcase == k.downcase }
|
14
14
|
value unless value.nil?
|
15
15
|
end
|
16
16
|
|
@@ -21,8 +21,8 @@ module NewRelic
|
|
21
21
|
|
22
22
|
class HTTPRequest < AbstractRequest
|
23
23
|
HTTP_RB = 'http.rb'
|
24
|
-
HOST
|
25
|
-
COLON
|
24
|
+
HOST = 'host'
|
25
|
+
COLON = ':'
|
26
26
|
|
27
27
|
def initialize wrapped_request
|
28
28
|
@wrapped_request = wrapped_request
|
@@ -10,7 +10,6 @@ module NewRelic
|
|
10
10
|
module Agent
|
11
11
|
module HTTPClients
|
12
12
|
class NetHTTPResponse < AbstractResponse
|
13
|
-
|
14
13
|
def [](key)
|
15
14
|
@wrapped_response[key]
|
16
15
|
end
|
@@ -63,14 +62,14 @@ module NewRelic
|
|
63
62
|
::NewRelic::Agent::HTTPClients::URIUtil.parse_and_normalize_url(@request.path)
|
64
63
|
else
|
65
64
|
connection_address = @connection.address
|
66
|
-
if
|
65
|
+
if connection_address =~ Resolv::IPv6::Regex
|
67
66
|
connection_address = "[#{connection_address}]"
|
68
67
|
end
|
69
68
|
|
70
69
|
scheme = @connection.use_ssl? ? 'https' : 'http'
|
71
70
|
::NewRelic::Agent::HTTPClients::URIUtil.parse_and_normalize_url(
|
72
71
|
"#{scheme}://#{connection_address}:#{@connection.port}#{@request.path}"
|
73
|
-
|
72
|
+
)
|
74
73
|
end
|
75
74
|
end
|
76
75
|
end
|
@@ -9,7 +9,6 @@ module NewRelic
|
|
9
9
|
module Agent
|
10
10
|
module HTTPClients
|
11
11
|
class TyphoeusHTTPResponse < AbstractResponse
|
12
|
-
|
13
12
|
def [](key)
|
14
13
|
unless headers.nil?
|
15
14
|
result = headers[key]
|
@@ -22,7 +21,7 @@ module NewRelic
|
|
22
21
|
|
23
22
|
def to_hash
|
24
23
|
hash = {}
|
25
|
-
headers.each do |(k,v)|
|
24
|
+
headers.each do |(k, v)|
|
26
25
|
hash[k] = v
|
27
26
|
end
|
28
27
|
hash
|
@@ -41,7 +40,7 @@ module NewRelic
|
|
41
40
|
@uri = case request.url
|
42
41
|
when ::URI then request.url
|
43
42
|
else NewRelic::Agent::HTTPClients::URIUtil.parse_and_normalize_url(request.url)
|
44
|
-
|
43
|
+
end
|
45
44
|
end
|
46
45
|
|
47
46
|
TYPHOEUS = "Typhoeus".freeze
|
@@ -7,10 +7,9 @@ module NewRelic
|
|
7
7
|
module Agent
|
8
8
|
module Instrumentation
|
9
9
|
class ActionCableSubscriber < NotificationsSubscriber
|
10
|
-
|
11
10
|
PERFORM_ACTION = 'perform_action.action_cable'.freeze
|
12
11
|
|
13
|
-
def start(name, id, payload) #THREAD_LOCAL_ACCESS
|
12
|
+
def start(name, id, payload) # THREAD_LOCAL_ACCESS
|
14
13
|
return unless state.is_execution_traced?
|
15
14
|
|
16
15
|
finishable = if name == PERFORM_ACTION
|
@@ -26,7 +25,7 @@ module NewRelic
|
|
26
25
|
log_notification_error e, name, 'start'
|
27
26
|
end
|
28
27
|
|
29
|
-
def finish(name, id, payload) #THREAD_LOCAL_ACCESS
|
28
|
+
def finish(name, id, payload) # THREAD_LOCAL_ACCESS
|
30
29
|
return unless state.is_execution_traced?
|
31
30
|
|
32
31
|
if exception = exception_object(payload)
|
@@ -9,8 +9,7 @@ module NewRelic
|
|
9
9
|
module Agent
|
10
10
|
module Instrumentation
|
11
11
|
class ActionControllerSubscriber < NotificationsSubscriber
|
12
|
-
|
13
|
-
def start(name, id, payload) #THREAD_LOCAL_ACCESS
|
12
|
+
def start(name, id, payload) # THREAD_LOCAL_ACCESS
|
14
13
|
# @req is a historically stable but not guaranteed Rails header property
|
15
14
|
request = payload[:headers].instance_variable_get(:@req)
|
16
15
|
|
@@ -29,7 +28,7 @@ module NewRelic
|
|
29
28
|
log_notification_error(e, name, 'start')
|
30
29
|
end
|
31
30
|
|
32
|
-
def finish(name, id, payload) #THREAD_LOCAL_ACCESS
|
31
|
+
def finish(name, id, payload) # THREAD_LOCAL_ACCESS
|
33
32
|
finishable = pop_segment(id)
|
34
33
|
|
35
34
|
if state.is_execution_traced? \
|
@@ -49,21 +48,21 @@ module NewRelic
|
|
49
48
|
|
50
49
|
def start_transaction_or_segment(payload, request, controller_class)
|
51
50
|
Tracer.start_transaction_or_segment(
|
52
|
-
name:
|
53
|
-
category:
|
54
|
-
options:
|
55
|
-
request:
|
56
|
-
filtered_params:
|
51
|
+
name: format_metric_name(payload[:action], controller_class),
|
52
|
+
category: :controller,
|
53
|
+
options: {
|
54
|
+
request: request,
|
55
|
+
filtered_params: NewRelic::Agent::ParameterFiltering.filter_using_rails(
|
57
56
|
payload[:params],
|
58
57
|
Rails.application.config.filter_parameters
|
59
58
|
),
|
60
59
|
apdex_start_time: queue_start(request),
|
61
|
-
ignore_apdex:
|
60
|
+
ignore_apdex: NewRelic::Agent::Instrumentation::IgnoreActions.is_filtered?(
|
62
61
|
ControllerInstrumentation::NR_IGNORE_APDEX_KEY,
|
63
62
|
controller_class,
|
64
63
|
payload[:action]
|
65
64
|
),
|
66
|
-
ignore_enduser:
|
65
|
+
ignore_enduser: NewRelic::Agent::Instrumentation::IgnoreActions.is_filtered?(
|
67
66
|
ControllerInstrumentation::NR_IGNORE_ENDUSER_KEY,
|
68
67
|
controller_class,
|
69
68
|
payload[:action]
|