newrelic_rpm 5.5.0.348 → 7.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +9 -0
- data/.yardopts +1 -0
- data/CHANGELOG.md +931 -0
- data/CONTRIBUTING.md +117 -19
- data/Gemfile +6 -2
- data/Guardfile +18 -1
- data/LICENSE +208 -38
- data/README.md +80 -84
- data/ROADMAP.md +24 -0
- data/Rakefile +2 -0
- data/THIRD_PARTY_NOTICES.md +213 -0
- data/bin/nrdebug +1 -1
- data/config.dot +1 -0
- data/init.rb +1 -1
- data/install.rb +1 -1
- data/lib/new_relic/agent.rb +111 -20
- data/lib/new_relic/agent/adaptive_sampler.rb +1 -1
- data/lib/new_relic/agent/agent.rb +182 -194
- data/lib/new_relic/agent/agent_logger.rb +5 -1
- data/lib/new_relic/agent/attribute_filter.rb +85 -25
- data/lib/new_relic/agent/attribute_processing.rb +1 -1
- data/lib/new_relic/agent/attributes.rb +152 -0
- data/lib/new_relic/agent/audit_logger.rb +11 -1
- data/lib/new_relic/agent/autostart.rb +19 -15
- data/lib/new_relic/agent/chained_call.rb +1 -1
- data/lib/new_relic/agent/commands/agent_command.rb +1 -1
- data/lib/new_relic/agent/commands/agent_command_router.rb +3 -22
- data/lib/new_relic/agent/commands/thread_profiler_session.rb +1 -1
- data/lib/new_relic/agent/configuration.rb +1 -1
- data/lib/new_relic/agent/configuration/default_source.rb +656 -188
- data/lib/new_relic/agent/configuration/dotted_hash.rb +1 -1
- data/lib/new_relic/agent/configuration/environment_source.rb +5 -3
- data/lib/new_relic/agent/configuration/event_harvest_config.rb +45 -0
- data/lib/new_relic/agent/configuration/high_security_source.rb +2 -1
- data/lib/new_relic/agent/configuration/manager.rb +17 -13
- data/lib/new_relic/agent/configuration/manual_source.rb +1 -1
- data/lib/new_relic/agent/configuration/mask_defaults.rb +1 -1
- data/lib/new_relic/agent/configuration/security_policy_source.rb +15 -1
- data/lib/new_relic/agent/configuration/server_source.rb +39 -4
- data/lib/new_relic/agent/configuration/yaml_source.rb +12 -7
- data/lib/new_relic/agent/connect/request_builder.rb +63 -0
- data/lib/new_relic/agent/connect/response_handler.rb +61 -0
- data/lib/new_relic/agent/custom_event_aggregator.rb +1 -1
- data/lib/new_relic/agent/database.rb +2 -3
- 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 +1 -1
- data/lib/new_relic/agent/database/postgres_explain_obfuscator.rb +1 -1
- data/lib/new_relic/agent/database_adapter.rb +33 -0
- data/lib/new_relic/agent/datastores.rb +7 -9
- data/lib/new_relic/agent/datastores/metric_helper.rb +2 -3
- data/lib/new_relic/agent/datastores/mongo.rb +2 -2
- data/lib/new_relic/agent/datastores/mongo/event_formatter.rb +3 -3
- data/lib/new_relic/agent/datastores/mongo/metric_translator.rb +1 -1
- data/lib/new_relic/agent/datastores/mongo/obfuscator.rb +9 -9
- data/lib/new_relic/agent/datastores/mongo/statement_formatter.rb +1 -1
- data/lib/new_relic/agent/datastores/redis.rb +1 -5
- data/lib/new_relic/agent/deprecator.rb +1 -1
- data/lib/new_relic/agent/distributed_tracing.rb +115 -32
- data/lib/new_relic/agent/{cross_app_payload.rb → distributed_tracing/cross_app_payload.rb} +3 -2
- data/lib/new_relic/agent/{cross_app_tracing.rb → distributed_tracing/cross_app_tracing.rb} +61 -46
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_attributes.rb +84 -0
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_metrics.rb +75 -0
- data/lib/new_relic/agent/{distributed_trace_payload.rb → distributed_tracing/distributed_trace_payload.rb} +32 -113
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_transport_type.rb +39 -0
- data/lib/new_relic/agent/distributed_tracing/trace_context.rb +246 -0
- data/lib/new_relic/agent/distributed_tracing/trace_context_payload.rb +126 -0
- data/lib/new_relic/agent/encoding_normalizer.rb +1 -1
- data/lib/new_relic/agent/error_collector.rb +88 -58
- data/lib/new_relic/agent/error_event_aggregator.rb +10 -7
- data/lib/new_relic/agent/error_filter.rb +167 -0
- data/lib/new_relic/agent/error_trace_aggregator.rb +2 -1
- data/lib/new_relic/agent/event_aggregator.rb +27 -33
- data/lib/new_relic/agent/event_buffer.rb +1 -1
- data/lib/new_relic/agent/event_listener.rb +1 -1
- data/lib/new_relic/agent/event_loop.rb +1 -1
- data/lib/new_relic/agent/external.rb +13 -11
- data/lib/new_relic/agent/guid_generator.rb +28 -0
- data/lib/new_relic/agent/harvester.rb +1 -1
- data/lib/new_relic/agent/heap.rb +1 -1
- data/lib/new_relic/agent/hostname.rb +16 -2
- data/lib/new_relic/agent/http_clients/abstract.rb +82 -0
- data/lib/new_relic/agent/http_clients/curb_wrappers.rb +25 -20
- data/lib/new_relic/agent/http_clients/excon_wrappers.rb +29 -14
- data/lib/new_relic/agent/http_clients/http_rb_wrappers.rb +18 -22
- data/lib/new_relic/agent/http_clients/httpclient_wrappers.rb +11 -12
- data/lib/new_relic/agent/http_clients/net_http_wrappers.rb +17 -5
- data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +5 -7
- data/lib/new_relic/agent/http_clients/uri_util.rb +12 -11
- data/lib/new_relic/agent/instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/action_cable_subscriber.rb +26 -43
- data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +53 -73
- data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +81 -56
- data/lib/new_relic/agent/instrumentation/active_job.rb +7 -8
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_record.rb +85 -38
- data/lib/new_relic/agent/instrumentation/active_record_helper.rb +17 -6
- data/lib/new_relic/agent/instrumentation/active_record_notifications.rb +152 -0
- data/lib/new_relic/agent/instrumentation/active_record_prepend.rb +35 -11
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +47 -51
- data/lib/new_relic/agent/instrumentation/active_storage.rb +23 -0
- data/lib/new_relic/agent/instrumentation/active_storage_subscriber.rb +63 -0
- data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +10 -9
- data/lib/new_relic/agent/instrumentation/authlogic.rb +1 -1
- data/lib/new_relic/agent/instrumentation/bunny.rb +13 -132
- data/lib/new_relic/agent/instrumentation/bunny/chain.rb +45 -0
- data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +152 -0
- data/lib/new_relic/agent/instrumentation/bunny/prepend.rb +35 -0
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +11 -4
- data/lib/new_relic/agent/instrumentation/curb.rb +11 -183
- data/lib/new_relic/agent/instrumentation/curb/chain.rb +93 -0
- data/lib/new_relic/agent/instrumentation/curb/instrumentation.rb +222 -0
- data/lib/new_relic/agent/instrumentation/curb/prepend.rb +63 -0
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +5 -3
- data/lib/new_relic/agent/instrumentation/delayed_job/chain.rb +38 -0
- data/lib/new_relic/agent/instrumentation/delayed_job/instrumentation.rb +53 -0
- data/lib/new_relic/agent/instrumentation/delayed_job/prepend.rb +34 -0
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +9 -49
- data/lib/new_relic/agent/instrumentation/excon.rb +4 -3
- data/lib/new_relic/agent/instrumentation/excon/connection.rb +8 -5
- data/lib/new_relic/agent/instrumentation/excon/middleware.rb +3 -2
- data/lib/new_relic/agent/instrumentation/grape.rb +14 -107
- data/lib/new_relic/agent/instrumentation/grape/chain.rb +25 -0
- data/lib/new_relic/agent/instrumentation/grape/instrumentation.rb +100 -0
- data/lib/new_relic/agent/instrumentation/grape/prepend.rb +17 -0
- data/lib/new_relic/agent/instrumentation/httpclient.rb +10 -30
- data/lib/new_relic/agent/instrumentation/httpclient/chain.rb +25 -0
- data/lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb +38 -0
- data/lib/new_relic/agent/instrumentation/httpclient/prepend.rb +17 -0
- data/lib/new_relic/agent/instrumentation/httprb.rb +29 -0
- data/lib/new_relic/agent/instrumentation/httprb/chain.rb +22 -0
- data/lib/new_relic/agent/instrumentation/httprb/instrumentation.rb +30 -0
- data/lib/new_relic/agent/instrumentation/httprb/prepend.rb +15 -0
- data/lib/new_relic/agent/instrumentation/ignore_actions.rb +1 -1
- data/lib/new_relic/agent/instrumentation/memcache.rb +55 -68
- data/lib/new_relic/agent/instrumentation/memcache/chain.rb +16 -0
- data/lib/new_relic/agent/instrumentation/memcache/dalli.rb +39 -118
- data/lib/new_relic/agent/instrumentation/memcache/helper.rb +56 -0
- data/lib/new_relic/agent/instrumentation/memcache/instrumentation.rb +88 -0
- data/lib/new_relic/agent/instrumentation/memcache/prepend.rb +88 -0
- data/lib/new_relic/agent/instrumentation/merb/controller.rb +1 -1
- data/lib/new_relic/agent/instrumentation/merb/errors.rb +1 -1
- data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +4 -2
- data/lib/new_relic/agent/instrumentation/middleware_tracing.rb +20 -11
- data/lib/new_relic/agent/instrumentation/mongo.rb +17 -4
- data/lib/new_relic/agent/instrumentation/mongodb_command_subscriber.rb +36 -3
- data/lib/new_relic/agent/instrumentation/net_http.rb +44 -0
- data/lib/new_relic/agent/instrumentation/net_http/chain.rb +25 -0
- data/lib/new_relic/agent/instrumentation/net_http/instrumentation.rb +40 -0
- data/lib/new_relic/agent/instrumentation/net_http/prepend.rb +21 -0
- data/lib/new_relic/agent/instrumentation/notifications_subscriber.rb +100 -0
- data/lib/new_relic/agent/instrumentation/padrino.rb +19 -52
- data/lib/new_relic/agent/instrumentation/padrino/chain.rb +34 -0
- data/lib/new_relic/agent/instrumentation/padrino/instrumentation.rb +27 -0
- data/lib/new_relic/agent/instrumentation/padrino/prepend.rb +20 -0
- data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/queue_time.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rack.rb +30 -138
- data/lib/new_relic/agent/instrumentation/rack/chain.rb +58 -0
- data/lib/new_relic/agent/instrumentation/rack/helpers.rb +32 -0
- data/lib/new_relic/agent/instrumentation/rack/instrumentation.rb +73 -0
- data/lib/new_relic/agent/instrumentation/rack/prepend.rb +37 -0
- data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rails/action_web_service.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rails_middleware.rb +1 -1
- data/lib/new_relic/agent/instrumentation/{rails5 → rails_notifications}/action_cable.rb +6 -7
- data/lib/new_relic/agent/instrumentation/{rails5 → rails_notifications}/action_controller.rb +4 -4
- data/lib/new_relic/agent/instrumentation/{rails4 → rails_notifications}/action_view.rb +4 -4
- data/lib/new_relic/agent/instrumentation/rainbows_instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rake.rb +14 -155
- data/lib/new_relic/agent/instrumentation/rake/chain.rb +25 -0
- data/lib/new_relic/agent/instrumentation/rake/instrumentation.rb +144 -0
- data/lib/new_relic/agent/instrumentation/rake/prepend.rb +14 -0
- data/lib/new_relic/agent/instrumentation/redis.rb +13 -102
- data/lib/new_relic/agent/instrumentation/redis/chain.rb +34 -0
- data/lib/new_relic/agent/instrumentation/redis/instrumentation.rb +65 -0
- data/lib/new_relic/agent/instrumentation/redis/prepend.rb +24 -0
- data/lib/new_relic/agent/instrumentation/resque.rb +22 -30
- data/lib/new_relic/agent/instrumentation/resque/chain.rb +22 -0
- data/lib/new_relic/agent/instrumentation/resque/helper.rb +19 -0
- data/lib/new_relic/agent/instrumentation/resque/instrumentation.rb +35 -0
- data/lib/new_relic/agent/instrumentation/resque/prepend.rb +16 -0
- data/lib/new_relic/agent/instrumentation/sequel.rb +2 -2
- data/lib/new_relic/agent/instrumentation/sequel_helper.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sidekiq.rb +48 -24
- data/lib/new_relic/agent/instrumentation/sinatra.rb +21 -160
- data/lib/new_relic/agent/instrumentation/sinatra/chain.rb +55 -0
- data/lib/new_relic/agent/instrumentation/sinatra/ignorer.rb +30 -35
- data/lib/new_relic/agent/instrumentation/sinatra/instrumentation.rb +124 -0
- data/lib/new_relic/agent/instrumentation/sinatra/prepend.rb +33 -0
- data/lib/new_relic/agent/instrumentation/sinatra/transaction_namer.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sunspot.rb +1 -1
- data/lib/new_relic/agent/instrumentation/typhoeus.rb +12 -74
- data/lib/new_relic/agent/instrumentation/typhoeus/chain.rb +22 -0
- data/lib/new_relic/agent/instrumentation/typhoeus/instrumentation.rb +82 -0
- data/lib/new_relic/agent/instrumentation/typhoeus/prepend.rb +14 -0
- data/lib/new_relic/agent/internal_agent_error.rb +1 -1
- data/lib/new_relic/agent/javascript_instrumentor.rb +15 -10
- data/lib/new_relic/agent/log_once.rb +1 -1
- data/lib/new_relic/agent/logging.rb +139 -0
- data/lib/new_relic/agent/memory_logger.rb +1 -1
- data/lib/new_relic/agent/messaging.rb +15 -82
- data/lib/new_relic/agent/method_tracer.rb +10 -8
- data/lib/new_relic/agent/method_tracer_helpers.rb +5 -5
- data/lib/new_relic/agent/monitors.rb +27 -0
- data/lib/new_relic/agent/monitors/cross_app_monitor.rb +110 -0
- data/lib/new_relic/agent/monitors/distributed_tracing_monitor.rb +27 -0
- data/lib/new_relic/agent/{inbound_request_monitor.rb → monitors/inbound_request_monitor.rb} +4 -4
- data/lib/new_relic/agent/{synthetics_monitor.rb → monitors/synthetics_monitor.rb} +4 -7
- data/lib/new_relic/agent/new_relic_service.rb +106 -40
- data/lib/new_relic/agent/new_relic_service/encoders.rb +1 -1
- data/lib/new_relic/agent/new_relic_service/json_marshaller.rb +1 -2
- data/lib/new_relic/agent/new_relic_service/marshaller.rb +6 -27
- data/lib/new_relic/agent/new_relic_service/security_policy_settings.rb +1 -1
- data/lib/new_relic/agent/noticible_error.rb +22 -0
- data/lib/new_relic/agent/null_logger.rb +1 -1
- data/lib/new_relic/agent/obfuscator.rb +1 -1
- data/lib/new_relic/agent/parameter_filtering.rb +19 -6
- data/lib/new_relic/agent/payload_metric_mapping.rb +1 -1
- data/lib/new_relic/agent/pipe_channel_manager.rb +1 -1
- data/lib/new_relic/agent/pipe_service.rb +1 -1
- data/lib/new_relic/agent/prepend_supportability.rb +1 -1
- data/lib/new_relic/agent/priority_sampled_buffer.rb +9 -4
- data/lib/new_relic/agent/range_extensions.rb +1 -1
- data/lib/new_relic/agent/rules_engine.rb +1 -1
- data/lib/new_relic/agent/rules_engine/replacement_rule.rb +1 -1
- data/lib/new_relic/agent/rules_engine/segment_terms_rule.rb +1 -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 +1 -1
- data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +1 -1
- data/lib/new_relic/agent/samplers/memory_sampler.rb +2 -2
- data/lib/new_relic/agent/samplers/object_sampler.rb +1 -1
- data/lib/new_relic/agent/samplers/vm_sampler.rb +1 -1
- data/lib/new_relic/agent/span_event_aggregator.rb +3 -5
- data/lib/new_relic/agent/span_event_primitive.rb +129 -65
- data/lib/new_relic/agent/sql_sampler.rb +12 -12
- data/lib/new_relic/agent/stats.rb +1 -1
- data/lib/new_relic/agent/stats_engine.rb +3 -3
- data/lib/new_relic/agent/stats_engine/gc_profiler.rb +2 -2
- data/lib/new_relic/agent/stats_engine/stats_hash.rb +1 -1
- data/lib/new_relic/agent/supported_versions.rb +3 -3
- data/lib/new_relic/agent/synthetics_event_aggregator.rb +1 -1
- data/lib/new_relic/agent/system_info.rb +18 -4
- data/lib/new_relic/agent/threading/agent_thread.rb +2 -2
- data/lib/new_relic/agent/threading/backtrace_node.rb +1 -1
- data/lib/new_relic/agent/threading/backtrace_service.rb +4 -4
- data/lib/new_relic/agent/threading/thread_profile.rb +10 -24
- data/lib/new_relic/agent/timestamp_sampled_buffer.rb +1 -1
- data/lib/new_relic/agent/tracer.rb +509 -0
- data/lib/new_relic/agent/transaction.rb +143 -171
- data/lib/new_relic/agent/transaction/abstract_segment.rb +33 -6
- data/lib/new_relic/agent/transaction/datastore_segment.rb +1 -3
- data/lib/new_relic/agent/transaction/distributed_tracer.rb +177 -0
- data/lib/new_relic/agent/transaction/distributed_tracing.rb +59 -149
- data/lib/new_relic/agent/transaction/external_request_segment.rb +32 -39
- data/lib/new_relic/agent/transaction/message_broker_segment.rb +5 -12
- data/lib/new_relic/agent/transaction/request_attributes.rb +1 -1
- data/lib/new_relic/agent/transaction/segment.rb +28 -2
- data/lib/new_relic/agent/transaction/slowest_sample_buffer.rb +1 -1
- data/lib/new_relic/agent/transaction/synthetics_sample_buffer.rb +1 -1
- data/lib/new_relic/agent/transaction/trace.rb +6 -13
- data/lib/new_relic/agent/transaction/trace_builder.rb +1 -2
- data/lib/new_relic/agent/transaction/trace_context.rb +168 -0
- data/lib/new_relic/agent/transaction/trace_node.rb +12 -8
- data/lib/new_relic/agent/transaction/tracing.rb +1 -100
- data/lib/new_relic/agent/transaction/transaction_sample_buffer.rb +1 -1
- data/lib/new_relic/agent/transaction_error_primitive.rb +11 -16
- data/lib/new_relic/agent/transaction_event_aggregator.rb +1 -1
- data/lib/new_relic/agent/transaction_event_primitive.rb +29 -40
- data/lib/new_relic/agent/transaction_event_recorder.rb +4 -4
- data/lib/new_relic/agent/transaction_metrics.rb +1 -1
- data/lib/new_relic/agent/transaction_sampler.rb +2 -6
- data/lib/new_relic/agent/transaction_time_aggregator.rb +50 -26
- data/lib/new_relic/agent/utilization/aws.rb +1 -1
- data/lib/new_relic/agent/utilization/azure.rb +1 -1
- data/lib/new_relic/agent/utilization/gcp.rb +1 -1
- 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/utilization_data.rb +37 -2
- data/lib/new_relic/agent/vm.rb +1 -1
- data/lib/new_relic/agent/vm/jruby_vm.rb +1 -1
- data/lib/new_relic/agent/vm/monotonic_gc_profiler.rb +1 -1
- data/lib/new_relic/agent/vm/mri_vm.rb +7 -5
- data/lib/new_relic/agent/vm/snapshot.rb +1 -1
- data/lib/new_relic/agent/worker_loop.rb +1 -1
- data/lib/new_relic/cli/command.rb +1 -1
- data/lib/new_relic/cli/commands/deployments.rb +2 -3
- data/lib/new_relic/cli/commands/install.rb +4 -3
- data/lib/new_relic/coerce.rb +32 -7
- data/lib/new_relic/collection_helper.rb +1 -1
- data/lib/new_relic/constants.rb +42 -0
- data/lib/new_relic/control.rb +1 -1
- data/lib/new_relic/control/class_methods.rb +8 -2
- data/lib/new_relic/control/frameworks.rb +1 -1
- data/lib/new_relic/control/frameworks/external.rb +1 -1
- data/lib/new_relic/control/frameworks/merb.rb +1 -1
- data/lib/new_relic/control/frameworks/rails.rb +12 -10
- data/lib/new_relic/control/frameworks/rails3.rb +1 -1
- data/lib/new_relic/control/frameworks/rails4.rb +1 -1
- data/lib/new_relic/control/frameworks/{rails5.rb → rails_notifications.rb} +2 -2
- data/lib/new_relic/control/frameworks/ruby.rb +1 -1
- data/lib/new_relic/control/frameworks/sinatra.rb +1 -1
- data/lib/new_relic/control/instance_methods.rb +12 -2
- data/lib/new_relic/control/instrumentation.rb +1 -1
- data/lib/new_relic/control/server_methods.rb +1 -1
- data/lib/new_relic/delayed_job_injection.rb +1 -1
- data/lib/new_relic/dependency_detection.rb +124 -14
- data/lib/new_relic/environment_report.rb +2 -4
- data/lib/new_relic/helper.rb +1 -1
- data/lib/new_relic/language_support.rb +1 -1
- data/lib/new_relic/latest_changes.rb +4 -4
- data/lib/new_relic/local_environment.rb +1 -1
- data/lib/new_relic/metric_data.rb +1 -1
- data/lib/new_relic/metric_spec.rb +1 -1
- data/lib/new_relic/noticed_error.rb +38 -21
- data/lib/new_relic/rack.rb +1 -1
- data/lib/new_relic/rack/agent_hooks.rb +1 -1
- data/lib/new_relic/rack/agent_middleware.rb +2 -2
- data/lib/new_relic/rack/browser_monitoring.rb +16 -9
- data/lib/new_relic/recipes.rb +1 -1
- data/lib/new_relic/recipes/capistrano3.rb +1 -1
- data/lib/new_relic/recipes/capistrano_legacy.rb +1 -1
- data/lib/new_relic/supportability_helper.rb +16 -1
- data/lib/new_relic/version.rb +3 -3
- data/lib/newrelic_rpm.rb +1 -1
- data/lib/sequel/extensions/newrelic_instrumentation.rb +1 -1
- data/lib/sequel/plugins/newrelic_instrumentation.rb +1 -1
- data/lib/tasks/all.rb +1 -1
- data/lib/tasks/config.html.erb +14 -25
- data/lib/tasks/config.rake +9 -9
- data/lib/tasks/multiverse.rb +35 -1
- data/lib/tasks/newrelic.rb +1 -1
- data/lib/tasks/tests.rake +6 -1
- data/newrelic_rpm.gemspec +22 -17
- data/recipes/newrelic.rb +1 -1
- data/test/agent_helper.rb +358 -78
- metadata +151 -66
- data/.travis.yml +0 -201
- data/cert/cacert.pem +0 -1177
- data/lib/new_relic/agent/commands/xray_session.rb +0 -55
- data/lib/new_relic/agent/commands/xray_session_collection.rb +0 -161
- data/lib/new_relic/agent/cross_app_monitor.rb +0 -110
- data/lib/new_relic/agent/distributed_trace_monitor.rb +0 -41
- data/lib/new_relic/agent/http_clients/abstract_request.rb +0 -31
- data/lib/new_relic/agent/instrumentation/active_record_4.rb +0 -42
- data/lib/new_relic/agent/instrumentation/active_record_5.rb +0 -41
- data/lib/new_relic/agent/instrumentation/evented_subscriber.rb +0 -104
- data/lib/new_relic/agent/instrumentation/http.rb +0 -46
- data/lib/new_relic/agent/instrumentation/net.rb +0 -50
- data/lib/new_relic/agent/instrumentation/rails4/action_controller.rb +0 -32
- data/lib/new_relic/agent/instrumentation/rails5/action_view.rb +0 -27
- data/lib/new_relic/agent/transaction/attributes.rb +0 -154
- data/lib/new_relic/agent/transaction/xray_sample_buffer.rb +0 -64
- data/lib/new_relic/agent/transaction_state.rb +0 -186
- data/lib/new_relic/build.rb +0 -2
- data/lib/new_relic/metrics.rb +0 -13
- data/lib/tasks/versions.html.erb +0 -28
- data/lib/tasks/versions.postface.html +0 -8
- data/lib/tasks/versions.preface.html +0 -9
- data/lib/tasks/versions.rake +0 -65
- data/lib/tasks/versions.txt.erb +0 -14
@@ -0,0 +1,39 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# This file is distributed under New Relic's license terms.
|
3
|
+
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
4
|
+
# frozen_string_literal: true
|
5
|
+
|
6
|
+
module NewRelic
|
7
|
+
module Agent
|
8
|
+
module DistributedTraceTransportType
|
9
|
+
extend self
|
10
|
+
|
11
|
+
ALLOWABLE_TRANSPORT_TYPES = [
|
12
|
+
NewRelic::UNKNOWN,
|
13
|
+
NewRelic::HTTP,
|
14
|
+
NewRelic::HTTPS,
|
15
|
+
"Kafka",
|
16
|
+
"JMS",
|
17
|
+
"IronMQ",
|
18
|
+
"AMQP",
|
19
|
+
"Queue",
|
20
|
+
"Other",
|
21
|
+
].freeze
|
22
|
+
|
23
|
+
URL_SCHEMES = {
|
24
|
+
'http' => NewRelic::HTTP,
|
25
|
+
'https' => NewRelic::HTTPS,
|
26
|
+
}.freeze
|
27
|
+
|
28
|
+
RACK_URL_SCHEME = 'rack.url_scheme'
|
29
|
+
|
30
|
+
def from value
|
31
|
+
ALLOWABLE_TRANSPORT_TYPES.include?(value) ? value : NewRelic::UNKNOWN
|
32
|
+
end
|
33
|
+
|
34
|
+
def for_rack_request request
|
35
|
+
URL_SCHEMES[request[RACK_URL_SCHEME]]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,246 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# This file is distributed under New Relic's license terms.
|
3
|
+
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
4
|
+
# frozen_string_literal: true
|
5
|
+
|
6
|
+
require_relative 'trace_context_payload'
|
7
|
+
|
8
|
+
module NewRelic
|
9
|
+
module Agent
|
10
|
+
module DistributedTracing
|
11
|
+
class TraceContext
|
12
|
+
VERSION = 0x0
|
13
|
+
|
14
|
+
COMMA = ','
|
15
|
+
EQUALS = '='
|
16
|
+
INVALID_TRACE_ID = ('0' * 32)
|
17
|
+
INVALID_PARENT_ID = ('0' * 16)
|
18
|
+
INVALID_VERSION = 'ff'
|
19
|
+
|
20
|
+
TRACE_ID_KEY = 'trace_id'
|
21
|
+
TRACE_FLAGS_KEY = 'trace_flags'
|
22
|
+
PARENT_ID_KEY = 'parent_id'
|
23
|
+
VERSION_KEY = 'version'
|
24
|
+
UNDEFINED_FIELDS_KEY = 'undefined_fields'
|
25
|
+
|
26
|
+
TP_VERSION = "(?<#{VERSION_KEY}>[a-f\\d]{2})"
|
27
|
+
TP_TRACE_ID = "(?<#{TRACE_ID_KEY}>[a-f\\d]{32})"
|
28
|
+
TP_PARENT_ID = "(?<#{PARENT_ID_KEY}>[a-f\\d]{16})"
|
29
|
+
TP_TRACE_FLAGS = "(?<#{TRACE_FLAGS_KEY}>\\d{2})"
|
30
|
+
TP_UNDEFINED_FIELDS = "(?<#{UNDEFINED_FIELDS_KEY}>-[a-zA-Z\\d-]*)"
|
31
|
+
TRACE_PARENT_REGEX = /\A#{TP_VERSION}-#{TP_TRACE_ID}-#{TP_PARENT_ID}-#{TP_TRACE_FLAGS}#{TP_UNDEFINED_FIELDS}?\z/
|
32
|
+
|
33
|
+
TRACE_PARENT_FORMAT_STRING = "%02x-%s-%s-%02x"
|
34
|
+
|
35
|
+
MAX_TRACE_STATE_SIZE = 512 # bytes
|
36
|
+
MAX_TRACE_STATE_ENTRY_SIZE = 128 # bytes
|
37
|
+
|
38
|
+
SUPPORTABILITY_TRACE_PARENT_PARSE_EXCEPTION = "Supportability/TraceContext/TraceParent/Parse/Exception"
|
39
|
+
SUPPORTABILITY_TRACE_STATE_PARSE_EXCEPTION = "Supportability/TraceContext/TraceState/Parse/Exception"
|
40
|
+
SUPPORTABILITY_TRACE_STATE_INVALID_NR_ENTRY = "Supportability/TraceContext/TraceState/InvalidNrEntry"
|
41
|
+
|
42
|
+
class << self
|
43
|
+
def insert format: NewRelic::FORMAT_NON_RACK,
|
44
|
+
carrier: nil,
|
45
|
+
parent_id: nil,
|
46
|
+
trace_id: nil,
|
47
|
+
trace_flags: nil,
|
48
|
+
trace_state: nil
|
49
|
+
|
50
|
+
trace_parent_header = trace_parent_header_for_format format
|
51
|
+
carrier[trace_parent_header] = format_trace_parent \
|
52
|
+
trace_id: trace_id,
|
53
|
+
parent_id: parent_id,
|
54
|
+
trace_flags: trace_flags
|
55
|
+
|
56
|
+
trace_state_header = trace_state_header_for_format format
|
57
|
+
carrier[trace_state_header] = trace_state if trace_state && !trace_state.empty?
|
58
|
+
end
|
59
|
+
|
60
|
+
def parse format: NewRelic::FORMAT_NON_RACK,
|
61
|
+
carrier: nil,
|
62
|
+
trace_state_entry_key: nil
|
63
|
+
trace_parent = extract_traceparent(format, carrier)
|
64
|
+
unless trace_parent_valid? trace_parent
|
65
|
+
NewRelic::Agent.increment_metric SUPPORTABILITY_TRACE_PARENT_PARSE_EXCEPTION
|
66
|
+
return nil
|
67
|
+
end
|
68
|
+
|
69
|
+
begin
|
70
|
+
if header_data = extract_tracestate(format, carrier, trace_state_entry_key)
|
71
|
+
header_data.trace_parent = trace_parent
|
72
|
+
header_data
|
73
|
+
end
|
74
|
+
rescue Exception
|
75
|
+
NewRelic::Agent.increment_metric SUPPORTABILITY_TRACE_STATE_PARSE_EXCEPTION
|
76
|
+
return nil
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def create_trace_state_entry entry_key, payload
|
81
|
+
"#{entry_key}=#{payload}".dup
|
82
|
+
end
|
83
|
+
|
84
|
+
private
|
85
|
+
|
86
|
+
def format_trace_parent trace_id: nil,
|
87
|
+
parent_id: nil,
|
88
|
+
trace_flags: nil
|
89
|
+
sprintf TRACE_PARENT_FORMAT_STRING,
|
90
|
+
VERSION,
|
91
|
+
trace_id,
|
92
|
+
parent_id,
|
93
|
+
trace_flags
|
94
|
+
end
|
95
|
+
|
96
|
+
def extract_traceparent format, carrier
|
97
|
+
header_name = trace_parent_header_for_format format
|
98
|
+
return unless header = carrier[header_name]
|
99
|
+
if matchdata = header.match(TRACE_PARENT_REGEX)
|
100
|
+
TRACE_PARENT_REGEX.named_captures.inject({}) do |hash, (name, (index))|
|
101
|
+
hash[name] = matchdata[index]
|
102
|
+
hash
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def trace_parent_valid? trace_parent
|
108
|
+
return false if trace_parent.nil?
|
109
|
+
return false if trace_parent[TRACE_ID_KEY] == INVALID_TRACE_ID
|
110
|
+
return false if trace_parent[PARENT_ID_KEY] == INVALID_PARENT_ID
|
111
|
+
return false if trace_parent[VERSION_KEY] == INVALID_VERSION
|
112
|
+
return false if trace_parent[VERSION_KEY].to_i(16) == VERSION && !trace_parent[UNDEFINED_FIELDS_KEY].nil?
|
113
|
+
|
114
|
+
true
|
115
|
+
end
|
116
|
+
|
117
|
+
def trace_parent_header_for_format format
|
118
|
+
if format == NewRelic::FORMAT_RACK
|
119
|
+
NewRelic::HTTP_TRACEPARENT_KEY
|
120
|
+
else
|
121
|
+
NewRelic::TRACEPARENT_KEY
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def trace_state_header_for_format format
|
126
|
+
if format == NewRelic::FORMAT_RACK
|
127
|
+
NewRelic::HTTP_TRACESTATE_KEY
|
128
|
+
else
|
129
|
+
NewRelic::TRACESTATE_KEY
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def extract_tracestate format, carrier, trace_state_entry_key
|
134
|
+
header_name = trace_state_header_for_format format
|
135
|
+
header = carrier[header_name]
|
136
|
+
return HeaderData.create if header.nil? || header.empty?
|
137
|
+
|
138
|
+
payload = nil
|
139
|
+
trace_state_size = 0
|
140
|
+
trace_state_vendors = String.new
|
141
|
+
trace_state = header.split(COMMA).map(&:strip)
|
142
|
+
trace_state.reject! do |entry|
|
143
|
+
if entry == NewRelic::EMPTY_STR
|
144
|
+
false
|
145
|
+
else
|
146
|
+
vendor_id = entry.slice 0, entry.index(EQUALS)
|
147
|
+
if vendor_id == trace_state_entry_key
|
148
|
+
payload = entry.slice! trace_state_entry_key.size + 1, entry.size
|
149
|
+
true
|
150
|
+
else
|
151
|
+
trace_state_size += entry.size
|
152
|
+
trace_state_vendors << vendor_id << COMMA
|
153
|
+
false
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
trace_state_vendors.chomp! COMMA
|
159
|
+
|
160
|
+
HeaderData.create trace_state_payload: payload ? decode_payload(payload) : nil,
|
161
|
+
trace_state_entries: trace_state,
|
162
|
+
trace_state_size: trace_state_size,
|
163
|
+
trace_state_vendors: trace_state_vendors
|
164
|
+
end
|
165
|
+
|
166
|
+
def decode_payload payload
|
167
|
+
TraceContextPayload.from_s payload
|
168
|
+
rescue
|
169
|
+
if payload
|
170
|
+
NewRelic::Agent.increment_metric SUPPORTABILITY_TRACE_STATE_INVALID_NR_ENTRY
|
171
|
+
end
|
172
|
+
return nil
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
class HeaderData
|
177
|
+
class << self
|
178
|
+
def create trace_parent: nil,
|
179
|
+
trace_state_payload: nil,
|
180
|
+
trace_state_entries: nil,
|
181
|
+
trace_state_size: 0,
|
182
|
+
trace_state_vendors: nil
|
183
|
+
new trace_parent, \
|
184
|
+
trace_state_payload, \
|
185
|
+
trace_state_entries, \
|
186
|
+
trace_state_size, \
|
187
|
+
trace_state_vendors
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
def initialize trace_parent, trace_state_payload, trace_state_entries, trace_state_size, trace_state_vendors
|
192
|
+
@trace_parent = trace_parent
|
193
|
+
@trace_state = nil
|
194
|
+
@trace_state_entries = trace_state_entries
|
195
|
+
@trace_state_payload = trace_state_payload
|
196
|
+
@trace_state_size = trace_state_size
|
197
|
+
@trace_state_vendors = trace_state_vendors
|
198
|
+
end
|
199
|
+
|
200
|
+
attr_accessor :trace_parent, :trace_state_payload, :trace_state_vendors
|
201
|
+
|
202
|
+
def trace_state trace_state_entry
|
203
|
+
@trace_state ||= join_trace_state trace_state_entry.size
|
204
|
+
@trace_state_entries = nil
|
205
|
+
|
206
|
+
trace_state_entry << @trace_state
|
207
|
+
end
|
208
|
+
|
209
|
+
def trace_id
|
210
|
+
@trace_parent[TRACE_ID_KEY]
|
211
|
+
end
|
212
|
+
|
213
|
+
def parent_id
|
214
|
+
@trace_parent[PARENT_ID_KEY]
|
215
|
+
end
|
216
|
+
|
217
|
+
private
|
218
|
+
|
219
|
+
def join_trace_state trace_state_entry_size
|
220
|
+
return @trace_state || NewRelic::EMPTY_STR if @trace_state_entries.nil? || @trace_state_entries.empty?
|
221
|
+
|
222
|
+
max_size = MAX_TRACE_STATE_SIZE - trace_state_entry_size
|
223
|
+
return @trace_state_entries.join(COMMA).prepend(COMMA) if @trace_state_size < max_size
|
224
|
+
|
225
|
+
joined_trace_state = ''.dup
|
226
|
+
|
227
|
+
used_size = 0
|
228
|
+
|
229
|
+
@trace_state_entries.each do |entry|
|
230
|
+
entry_size = entry.size + 1
|
231
|
+
break if used_size + entry_size > max_size
|
232
|
+
next if entry_size > MAX_TRACE_STATE_ENTRY_SIZE
|
233
|
+
|
234
|
+
joined_trace_state << COMMA << entry
|
235
|
+
used_size += entry_size
|
236
|
+
end
|
237
|
+
|
238
|
+
joined_trace_state
|
239
|
+
end
|
240
|
+
|
241
|
+
end
|
242
|
+
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# This file is distributed under New Relic's license terms.
|
3
|
+
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
4
|
+
|
5
|
+
require 'new_relic/coerce'
|
6
|
+
|
7
|
+
module NewRelic
|
8
|
+
module Agent
|
9
|
+
class TraceContextPayload
|
10
|
+
VERSION = 0
|
11
|
+
PARENT_TYPE = 0
|
12
|
+
DELIMITER = "-".freeze
|
13
|
+
SUPPORTABILITY_PARSE_EXCEPTION = "Supportability/TraceContext/Parse/Exception".freeze
|
14
|
+
|
15
|
+
TRUE_CHAR = '1'.freeze
|
16
|
+
FALSE_CHAR = '0'.freeze
|
17
|
+
|
18
|
+
PARENT_TYPES = %w(App Browser Mobile).map(&:freeze).freeze
|
19
|
+
|
20
|
+
class << self
|
21
|
+
def create version: VERSION,
|
22
|
+
parent_type: PARENT_TYPE,
|
23
|
+
parent_account_id: nil,
|
24
|
+
parent_app_id: nil,
|
25
|
+
id: nil,
|
26
|
+
transaction_id: nil,
|
27
|
+
sampled: nil,
|
28
|
+
priority: nil,
|
29
|
+
timestamp: now_ms
|
30
|
+
|
31
|
+
new version, parent_type, parent_account_id, parent_app_id, id,
|
32
|
+
transaction_id, sampled, priority, timestamp
|
33
|
+
end
|
34
|
+
|
35
|
+
include NewRelic::Coerce
|
36
|
+
|
37
|
+
def from_s payload_string
|
38
|
+
attrs = payload_string.split(DELIMITER)
|
39
|
+
|
40
|
+
payload = create \
|
41
|
+
version: int!(attrs[0]),
|
42
|
+
parent_type: int!(attrs[1]),
|
43
|
+
parent_account_id: attrs[2],
|
44
|
+
parent_app_id: attrs[3],
|
45
|
+
id: value_or_nil(attrs[4]),
|
46
|
+
transaction_id: value_or_nil(attrs[5]),
|
47
|
+
sampled: value_or_nil(attrs[6]) ? boolean_int!(attrs[6]) == 1 : nil,
|
48
|
+
priority: float!(attrs[7]),
|
49
|
+
timestamp: int!(attrs[8])
|
50
|
+
handle_invalid_payload message: 'payload missing attributes' unless payload.valid?
|
51
|
+
payload
|
52
|
+
rescue => e
|
53
|
+
handle_invalid_payload error: e
|
54
|
+
raise
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def now_ms
|
60
|
+
(Time.now.to_f * 1000).round
|
61
|
+
end
|
62
|
+
|
63
|
+
def handle_invalid_payload error: nil, message: nil
|
64
|
+
NewRelic::Agent.increment_metric SUPPORTABILITY_PARSE_EXCEPTION
|
65
|
+
if error
|
66
|
+
NewRelic::Agent.logger.warn "Error parsing trace context payload", error
|
67
|
+
elsif message
|
68
|
+
NewRelic::Agent.logger.warn "Error parsing trace context payload: #{message}"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
attr_accessor :version,
|
74
|
+
:parent_type_id,
|
75
|
+
:parent_account_id,
|
76
|
+
:parent_app_id,
|
77
|
+
:id,
|
78
|
+
:transaction_id,
|
79
|
+
:sampled,
|
80
|
+
:priority,
|
81
|
+
:timestamp
|
82
|
+
|
83
|
+
alias_method :sampled?, :sampled
|
84
|
+
|
85
|
+
def initialize version, parent_type_id, parent_account_id, parent_app_id,
|
86
|
+
id, transaction_id, sampled, priority, timestamp
|
87
|
+
@version = version
|
88
|
+
@parent_type_id = parent_type_id
|
89
|
+
@parent_account_id = parent_account_id
|
90
|
+
@parent_app_id = parent_app_id
|
91
|
+
@id = id
|
92
|
+
@transaction_id = transaction_id
|
93
|
+
@sampled = sampled
|
94
|
+
@priority = priority
|
95
|
+
@timestamp = timestamp
|
96
|
+
end
|
97
|
+
|
98
|
+
def parent_type
|
99
|
+
@parent_type_string ||= PARENT_TYPES[@parent_type_id]
|
100
|
+
end
|
101
|
+
|
102
|
+
def valid?
|
103
|
+
version \
|
104
|
+
&& parent_type_id \
|
105
|
+
&& !parent_account_id.empty? \
|
106
|
+
&& !parent_app_id.empty? \
|
107
|
+
&& timestamp
|
108
|
+
rescue
|
109
|
+
false
|
110
|
+
end
|
111
|
+
|
112
|
+
def to_s
|
113
|
+
result = version.to_s
|
114
|
+
result << DELIMITER << parent_type_id.to_s
|
115
|
+
result << DELIMITER << parent_account_id
|
116
|
+
result << DELIMITER << parent_app_id
|
117
|
+
result << DELIMITER << (id || NewRelic::EMPTY_STR)
|
118
|
+
result << DELIMITER << (transaction_id || NewRelic::EMPTY_STR)
|
119
|
+
result << DELIMITER << (sampled ? TRUE_CHAR : FALSE_CHAR)
|
120
|
+
result << DELIMITER << sprintf("%.6f", priority)
|
121
|
+
result << DELIMITER << timestamp.to_s
|
122
|
+
result
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
# This file is distributed under New Relic's license terms.
|
3
|
-
# See https://github.com/newrelic/
|
3
|
+
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
4
4
|
|
5
5
|
# This module was extracted from NewRelic::JSONWrapper
|
6
6
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
# This file is distributed under New Relic's license terms.
|
3
|
-
# See https://github.com/newrelic/
|
3
|
+
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
4
4
|
require 'new_relic/agent/error_trace_aggregator'
|
5
5
|
require 'new_relic/agent/error_event_aggregator'
|
6
6
|
|
@@ -13,36 +13,27 @@ module NewRelic
|
|
13
13
|
# made configurable in the future. This is a tradeoff between
|
14
14
|
# memory and data retention
|
15
15
|
MAX_ERROR_QUEUE_LENGTH = 20
|
16
|
-
# Maximum number of frames in backtraces. May be made configurable
|
17
|
-
# in the future.
|
18
|
-
MAX_BACKTRACE_FRAMES = 50
|
19
16
|
EXCEPTION_TAG_IVAR = :'@__nr_seen_exception'
|
20
17
|
|
21
18
|
attr_reader :error_trace_aggregator, :error_event_aggregator
|
22
19
|
|
23
20
|
# Returns a new error collector
|
24
|
-
def initialize
|
21
|
+
def initialize events
|
25
22
|
@error_trace_aggregator = ErrorTraceAggregator.new(MAX_ERROR_QUEUE_LENGTH)
|
26
|
-
@error_event_aggregator = ErrorEventAggregator.new
|
23
|
+
@error_event_aggregator = ErrorEventAggregator.new events
|
27
24
|
|
28
|
-
|
29
|
-
@ignore = {}
|
25
|
+
@error_filter = NewRelic::Agent::ErrorFilter.new
|
30
26
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
27
|
+
%w(
|
28
|
+
ignore_errors ignore_classes ignore_messages ignore_status_codes
|
29
|
+
expected_classes expected_messages expected_status_codes
|
30
|
+
).each do |w|
|
31
|
+
Agent.config.register_callback(:"error_collector.#{w}") do |value|
|
32
|
+
@error_filter.load_from_config(w, value)
|
33
|
+
end
|
35
34
|
end
|
36
35
|
end
|
37
36
|
|
38
|
-
|
39
|
-
def initialize_ignored_errors(ignore_errors)
|
40
|
-
@ignore.clear
|
41
|
-
ignore_errors = ignore_errors.split(",") if ignore_errors.is_a? String
|
42
|
-
ignore_errors.each { |error| error.strip! }
|
43
|
-
ignore(ignore_errors)
|
44
|
-
end
|
45
|
-
|
46
37
|
def enabled?
|
47
38
|
error_trace_aggregator.enabled? || error_event_aggregator.enabled?
|
48
39
|
end
|
@@ -77,33 +68,42 @@ module NewRelic
|
|
77
68
|
end
|
78
69
|
|
79
70
|
def self.ignore_error_filter
|
80
|
-
@ignore_filter
|
71
|
+
defined?(@ignore_filter) ? @ignore_filter : nil
|
81
72
|
end
|
82
73
|
|
83
|
-
# errors is an array of Exception Class Names
|
84
|
-
#
|
85
74
|
def ignore(errors)
|
86
|
-
errors
|
87
|
-
|
88
|
-
|
89
|
-
|
75
|
+
@error_filter.ignore(errors)
|
76
|
+
end
|
77
|
+
|
78
|
+
def ignore?(ex, status_code = nil)
|
79
|
+
@error_filter.ignore?(ex, status_code)
|
80
|
+
end
|
81
|
+
|
82
|
+
def expect(errors)
|
83
|
+
@error_filter.expect(errors)
|
84
|
+
end
|
85
|
+
|
86
|
+
def expected?(ex, status_code = nil)
|
87
|
+
@error_filter.expected?(ex, status_code)
|
88
|
+
end
|
89
|
+
|
90
|
+
def load_error_filters
|
91
|
+
@error_filter.load_all
|
92
|
+
end
|
93
|
+
|
94
|
+
def reset_error_filters
|
95
|
+
@error_filter.reset
|
90
96
|
end
|
91
97
|
|
92
98
|
# Checks the provided error against the error filter, if there
|
93
99
|
# is an error filter
|
94
|
-
def
|
100
|
+
def ignored_by_filter_proc?(error)
|
95
101
|
respond_to?(:ignore_filter_proc) && !ignore_filter_proc(error)
|
96
102
|
end
|
97
103
|
|
98
|
-
# Checks the array of error names and the error filter against
|
99
|
-
# the provided error
|
100
|
-
def filtered_error?(error)
|
101
|
-
@ignore[error.class.name] || filtered_by_error_filter?(error)
|
102
|
-
end
|
103
|
-
|
104
104
|
# an error is ignored if it is nil or if it is filtered
|
105
|
-
def error_is_ignored?(error)
|
106
|
-
error &&
|
105
|
+
def error_is_ignored?(error, status_code = nil)
|
106
|
+
error && (@error_filter.ignore?(error, status_code) || ignored_by_filter_proc?(error))
|
107
107
|
rescue => e
|
108
108
|
NewRelic::Agent.logger.error("Error '#{error}' will NOT be ignored. Exception '#{e}' while determining whether to ignore or not.", e)
|
109
109
|
false
|
@@ -120,14 +120,22 @@ module NewRelic
|
|
120
120
|
NewRelic::LanguageSupport.jruby? && exception.respond_to?(:java_class)
|
121
121
|
end
|
122
122
|
|
123
|
-
def
|
123
|
+
def exception_tagged_with?(ivar, exception)
|
124
124
|
return false if exception_is_java_object?(exception)
|
125
|
-
exception.instance_variable_defined?(
|
125
|
+
exception.instance_variable_defined?(ivar)
|
126
|
+
end
|
127
|
+
|
128
|
+
def tag_exception_using(ivar, exception)
|
129
|
+
return if exception_is_java_object?(exception) || exception.frozen?
|
130
|
+
begin
|
131
|
+
exception.instance_variable_set(ivar, true)
|
132
|
+
rescue => e
|
133
|
+
NewRelic::Agent.logger.warn("Failed to tag exception: #{exception}: ", e)
|
134
|
+
end
|
126
135
|
end
|
127
136
|
|
128
137
|
def tag_exception(exception)
|
129
|
-
return if exception_is_java_object?(exception)
|
130
|
-
return if exception.frozen?
|
138
|
+
return if exception_is_java_object?(exception) || exception.frozen?
|
131
139
|
begin
|
132
140
|
exception.instance_variable_set(EXCEPTION_TAG_IVAR, true)
|
133
141
|
rescue => e
|
@@ -170,11 +178,18 @@ module NewRelic
|
|
170
178
|
end
|
171
179
|
end
|
172
180
|
|
173
|
-
def
|
181
|
+
def increment_expected_error_count!(state, exception)
|
182
|
+
stats_engine = NewRelic::Agent.agent.stats_engine
|
183
|
+
stats_engine.record_unscoped_metrics(state, ['ErrorsExpected/all']) do |stats|
|
184
|
+
stats.increment_count
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
def skip_notice_error?(exception, status_code = nil)
|
174
189
|
disabled? ||
|
175
|
-
|
176
|
-
|
177
|
-
|
190
|
+
exception.nil? ||
|
191
|
+
exception_tagged_with?(EXCEPTION_TAG_IVAR, exception) ||
|
192
|
+
error_is_ignored?(exception, status_code)
|
178
193
|
end
|
179
194
|
|
180
195
|
# calls a method on an object, if it responds to it - used for
|
@@ -194,30 +209,47 @@ module NewRelic
|
|
194
209
|
sense_method(actual_exception, :backtrace) || '<no stack trace>'
|
195
210
|
end
|
196
211
|
|
197
|
-
|
198
|
-
def notice_error(exception, options={}) #THREAD_LOCAL_ACCESS
|
212
|
+
def notice_segment_error(segment, exception, options={})
|
199
213
|
return if skip_notice_error?(exception)
|
200
214
|
|
201
|
-
|
215
|
+
segment.set_noticed_error create_noticed_error(exception, options)
|
216
|
+
exception
|
217
|
+
rescue => e
|
218
|
+
::NewRelic::Agent.logger.warn("Failure when capturing segment error '#{exception}':", e)
|
219
|
+
nil
|
220
|
+
end
|
221
|
+
|
222
|
+
# See NewRelic::Agent.notice_error for options and commentary
|
223
|
+
def notice_error(exception, options={}, span_id=nil)
|
224
|
+
state = ::NewRelic::Agent::Tracer.state
|
225
|
+
transaction = state.current_transaction
|
226
|
+
status_code = transaction ? transaction.http_response_code : nil
|
227
|
+
|
228
|
+
return if skip_notice_error?(exception, status_code)
|
202
229
|
|
203
|
-
|
230
|
+
tag_exception(exception)
|
204
231
|
|
205
|
-
|
232
|
+
if options[:expected] || @error_filter.expected?(exception, status_code)
|
233
|
+
increment_expected_error_count!(state, exception)
|
234
|
+
else
|
206
235
|
increment_error_count!(state, exception, options)
|
207
236
|
end
|
208
237
|
|
209
238
|
noticed_error = create_noticed_error(exception, options)
|
210
239
|
error_trace_aggregator.add_to_error_queue(noticed_error)
|
211
|
-
|
212
|
-
|
240
|
+
transaction = state.current_transaction
|
241
|
+
payload = transaction ? transaction.payload : nil
|
242
|
+
span_id ||= (transaction && transaction.current_segment) ? transaction.current_segment.guid : nil
|
243
|
+
error_event_aggregator.record(noticed_error, payload, span_id)
|
213
244
|
exception
|
214
245
|
rescue => e
|
215
246
|
::NewRelic::Agent.logger.warn("Failure when capturing error '#{exception}':", e)
|
216
247
|
nil
|
217
248
|
end
|
218
249
|
|
219
|
-
def truncate_trace(trace, keep_frames=
|
220
|
-
|
250
|
+
def truncate_trace(trace, keep_frames=nil)
|
251
|
+
keep_frames ||= Agent.config[:'error_collector.max_backtrace_frames']
|
252
|
+
return trace if !keep_frames || trace.length < keep_frames || trace.length == 0
|
221
253
|
|
222
254
|
# If keep_frames is odd, we will split things up favoring the top of the trace
|
223
255
|
keep_top = (keep_frames / 2.0).ceil
|
@@ -229,13 +261,11 @@ module NewRelic
|
|
229
261
|
truncated_trace
|
230
262
|
end
|
231
263
|
|
232
|
-
EMPTY_STRING = ''.freeze
|
233
|
-
|
234
264
|
def create_noticed_error(exception, options)
|
235
|
-
error_metric = options.delete(:metric) ||
|
265
|
+
error_metric = options.delete(:metric) || NewRelic::EMPTY_STR
|
236
266
|
|
237
267
|
noticed_error = NewRelic::NoticedError.new(error_metric, exception)
|
238
|
-
noticed_error.request_uri = options.delete(:uri) ||
|
268
|
+
noticed_error.request_uri = options.delete(:uri) || NewRelic::EMPTY_STR
|
239
269
|
noticed_error.request_port = options.delete(:port)
|
240
270
|
noticed_error.attributes = options.delete(:attributes)
|
241
271
|
|
@@ -243,7 +273,7 @@ module NewRelic
|
|
243
273
|
noticed_error.line_number = sense_method(exception, :line_number)
|
244
274
|
noticed_error.stack_trace = truncate_trace(extract_stack_trace(exception))
|
245
275
|
|
246
|
-
noticed_error.expected = !!
|
276
|
+
noticed_error.expected = !!options.delete(:expected) || expected?(exception)
|
247
277
|
|
248
278
|
noticed_error.attributes_from_notice_error = options.delete(:custom_params) || {}
|
249
279
|
|