newrelic_rpm 5.7.0.350 → 7.0.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 +788 -0
- data/CONTRIBUTING.md +106 -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/init.rb +1 -1
- data/install.rb +1 -1
- data/lib/new_relic/agent/adaptive_sampler.rb +1 -1
- data/lib/new_relic/agent/agent.rb +176 -191
- data/lib/new_relic/agent/agent_logger.rb +5 -1
- data/lib/new_relic/agent/attribute_filter.rb +8 -8
- 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/default_source.rb +447 -89
- 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 +16 -12
- 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 +1 -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/configuration.rb +1 -1
- data/lib/new_relic/agent/connect/request_builder.rb +61 -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/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.rb +2 -3
- data/lib/new_relic/agent/database_adapter.rb +33 -0
- data/lib/new_relic/agent/datastores/metric_helper.rb +2 -3
- 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/mongo.rb +2 -2
- data/lib/new_relic/agent/datastores/redis.rb +1 -5
- data/lib/new_relic/agent/datastores.rb +7 -9
- data/lib/new_relic/agent/deprecator.rb +1 -1
- 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/distributed_tracing.rb +115 -32
- data/lib/new_relic/agent/encoding_normalizer.rb +1 -1
- data/lib/new_relic/agent/error_collector.rb +37 -20
- data/lib/new_relic/agent/error_event_aggregator.rb +10 -7
- 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/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 -49
- data/lib/new_relic/agent/instrumentation/active_storage.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_storage_subscriber.rb +13 -9
- 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/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/bunny.rb +13 -132
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +10 -4
- 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/curb.rb +11 -183
- 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/connection.rb +8 -5
- data/lib/new_relic/agent/instrumentation/excon/middleware.rb +3 -2
- data/lib/new_relic/agent/instrumentation/excon.rb +4 -3
- 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/grape.rb +14 -118
- 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/httpclient.rb +10 -30
- 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/httprb.rb +29 -0
- data/lib/new_relic/agent/instrumentation/ignore_actions.rb +1 -1
- 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/memcache.rb +55 -68
- 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/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/net_http.rb +39 -0
- data/lib/new_relic/agent/instrumentation/notifications_subscriber.rb +100 -0
- 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/padrino.rb +19 -52
- 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/chain.rb +57 -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 +36 -0
- data/lib/new_relic/agent/instrumentation/rack.rb +30 -138
- 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/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/rake.rb +14 -155
- 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/redis.rb +11 -104
- data/lib/new_relic/agent/instrumentation/resque/chain.rb +22 -0
- data/lib/new_relic/agent/instrumentation/resque/instrumentation.rb +33 -0
- data/lib/new_relic/agent/instrumentation/resque/prepend.rb +16 -0
- data/lib/new_relic/agent/instrumentation/resque.rb +9 -26
- data/lib/new_relic/agent/instrumentation/sequel.rb +1 -1
- 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/chain.rb +55 -0
- data/lib/new_relic/agent/instrumentation/sinatra/ignorer.rb +30 -35
- data/lib/new_relic/agent/instrumentation/sinatra/instrumentation.rb +118 -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/sinatra.rb +21 -160
- data/lib/new_relic/agent/instrumentation/sunspot.rb +1 -1
- 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/instrumentation/typhoeus.rb +12 -74
- data/lib/new_relic/agent/instrumentation.rb +1 -1
- data/lib/new_relic/agent/internal_agent_error.rb +1 -1
- data/lib/new_relic/agent/javascript_instrumentor.rb +3 -3
- 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/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/monitors.rb +27 -0
- 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/new_relic_service.rb +95 -40
- 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/replacement_rule.rb +1 -1
- data/lib/new_relic/agent/rules_engine/segment_terms_rule.rb +1 -1
- data/lib/new_relic/agent/rules_engine.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 +108 -54
- data/lib/new_relic/agent/sql_sampler.rb +10 -10
- data/lib/new_relic/agent/stats.rb +1 -1
- 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/stats_engine.rb +3 -3
- 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/abstract_segment.rb +33 -6
- data/lib/new_relic/agent/transaction/datastore_segment.rb +1 -1
- 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 +11 -9
- 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.rb +140 -170
- 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 +20 -6
- 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/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/vm.rb +1 -1
- data/lib/new_relic/agent/worker_loop.rb +1 -1
- data/lib/new_relic/agent.rb +106 -18
- 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/class_methods.rb +8 -2
- 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/frameworks.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/control.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 +2 -2
- 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 +35 -18
- 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/rack.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/recipes.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.rake +1 -2
- 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 +147 -66
- data/.travis.yml +0 -228
- 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
@@ -1,16 +1,18 @@
|
|
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
|
+
# frozen_string_literal: true
|
4
5
|
|
5
6
|
require 'new_relic/agent/instrumentation/queue_time'
|
6
7
|
require 'new_relic/agent/transaction_metrics'
|
7
8
|
require 'new_relic/agent/method_tracer_helpers'
|
8
|
-
require 'new_relic/agent/
|
9
|
+
require 'new_relic/agent/attributes'
|
9
10
|
require 'new_relic/agent/transaction/request_attributes'
|
10
11
|
require 'new_relic/agent/transaction/tracing'
|
11
|
-
require 'new_relic/agent/transaction/
|
12
|
-
require 'new_relic/agent/cross_app_tracing'
|
12
|
+
require 'new_relic/agent/transaction/distributed_tracer'
|
13
13
|
require 'new_relic/agent/transaction_time_aggregator'
|
14
|
+
require 'new_relic/agent/deprecator'
|
15
|
+
require 'new_relic/agent/guid_generator'
|
14
16
|
|
15
17
|
module NewRelic
|
16
18
|
module Agent
|
@@ -20,26 +22,38 @@ module NewRelic
|
|
20
22
|
# @api public
|
21
23
|
class Transaction
|
22
24
|
include Tracing
|
23
|
-
include DistributedTracing
|
24
|
-
include CrossAppTracing
|
25
25
|
|
26
26
|
# for nested transactions
|
27
|
-
|
28
|
-
CONTROLLER_PREFIX =
|
29
|
-
MIDDLEWARE_PREFIX =
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
WEB_TRANSACTION_CATEGORIES = [:controller, :uri, :rack, :sinatra, :grape, :middleware, :action_cable].freeze
|
27
|
+
NESTED_TRANSACTION_PREFIX = "Nested/"
|
28
|
+
CONTROLLER_PREFIX = "Controller/"
|
29
|
+
MIDDLEWARE_PREFIX = "Middleware/Rack/"
|
30
|
+
OTHER_TRANSACTION_PREFIX = "OtherTransaction/"
|
31
|
+
TASK_PREFIX = "#{OTHER_TRANSACTION_PREFIX}Background/"
|
32
|
+
RAKE_PREFIX = "#{OTHER_TRANSACTION_PREFIX}Rake/"
|
33
|
+
MESSAGE_PREFIX = "#{OTHER_TRANSACTION_PREFIX}Message/"
|
34
|
+
RACK_PREFIX = "#{CONTROLLER_PREFIX}Rack/"
|
35
|
+
SINATRA_PREFIX = "#{CONTROLLER_PREFIX}Sinatra/"
|
36
|
+
GRAPE_PREFIX = "#{CONTROLLER_PREFIX}Grape/"
|
37
|
+
ACTION_CABLE_PREFIX = "#{CONTROLLER_PREFIX}ActionCable/"
|
38
|
+
|
39
|
+
WEB_TRANSACTION_CATEGORIES = [:web, :controller, :uri, :rack, :sinatra, :grape, :middleware, :action_cable].freeze
|
40
40
|
TRANSACTION_NAMING_SOURCES = [:child, :api].freeze
|
41
41
|
|
42
|
-
MIDDLEWARE_SUMMARY_METRICS = [
|
42
|
+
MIDDLEWARE_SUMMARY_METRICS = ["Middleware/all"].freeze
|
43
|
+
WEB_SUMMARY_METRIC = "HttpDispatcher"
|
44
|
+
OTHER_SUMMARY_METRIC = "#{OTHER_TRANSACTION_PREFIX}all"
|
45
|
+
QUEUE_TIME_METRIC = "WebFrontend/QueueTime"
|
46
|
+
|
47
|
+
APDEX_S = "S"
|
48
|
+
APDEX_T = "T"
|
49
|
+
APDEX_F = "F"
|
50
|
+
APDEX_ALL_METRIC = "ApdexAll"
|
51
|
+
APDEX_METRIC = "Apdex"
|
52
|
+
APDEX_OTHER_METRIC = "ApdexOther"
|
53
|
+
APDEX_TXN_METRIC_PREFIX = "Apdex/"
|
54
|
+
APDEX_OTHER_TXN_METRIC_PREFIX = "ApdexOther/Transaction/"
|
55
|
+
|
56
|
+
JRUBY_CPU_TIME_ERROR = "Error calculating JRuby CPU Time"
|
43
57
|
|
44
58
|
# reference to the transaction state managing this transaction
|
45
59
|
attr_accessor :state
|
@@ -58,13 +72,13 @@ module NewRelic
|
|
58
72
|
:process_cpu_start,
|
59
73
|
:http_response_code,
|
60
74
|
:response_content_length,
|
61
|
-
:response_content_type
|
75
|
+
:response_content_type,
|
76
|
+
:parent_span_id
|
62
77
|
|
63
78
|
attr_reader :guid,
|
64
79
|
:metrics,
|
65
80
|
:gc_start_snapshot,
|
66
81
|
:category,
|
67
|
-
:frame_stack,
|
68
82
|
:attributes,
|
69
83
|
:payload,
|
70
84
|
:nesting_max_depth,
|
@@ -83,28 +97,37 @@ module NewRelic
|
|
83
97
|
|
84
98
|
# Return the currently active transaction, or nil.
|
85
99
|
def self.tl_current
|
86
|
-
|
100
|
+
Tracer.current_transaction
|
87
101
|
end
|
88
102
|
|
89
|
-
def self.set_default_transaction_name(
|
103
|
+
def self.set_default_transaction_name(partial_name, category = nil) #THREAD_LOCAL_ACCESS
|
90
104
|
txn = tl_current
|
91
|
-
name =
|
92
|
-
txn.name_last_frame(node_name || name)
|
105
|
+
name = name_from_partial(partial_name, category || txn.category)
|
93
106
|
txn.set_default_transaction_name(name, category)
|
94
107
|
end
|
95
108
|
|
96
|
-
def self.set_overriding_transaction_name(
|
109
|
+
def self.set_overriding_transaction_name(partial_name, category = nil) #THREAD_LOCAL_ACCESS
|
97
110
|
txn = tl_current
|
98
111
|
return unless txn
|
99
112
|
|
100
|
-
name =
|
101
|
-
|
102
|
-
txn.name_last_frame(name)
|
113
|
+
name = name_from_partial(partial_name, category || txn.category)
|
103
114
|
txn.set_overriding_transaction_name(name, category)
|
104
115
|
end
|
105
116
|
|
117
|
+
def self.name_from_partial(partial_name, category)
|
118
|
+
namer = Instrumentation::ControllerInstrumentation::TransactionNamer
|
119
|
+
"#{namer.prefix_for_category(self, category)}#{partial_name}"
|
120
|
+
end
|
121
|
+
|
106
122
|
def self.wrap(state, name, category, options = {})
|
107
|
-
Transaction.
|
123
|
+
Deprecator.deprecate 'Transaction.wrap',
|
124
|
+
'Tracer#in_transaction'
|
125
|
+
|
126
|
+
finishable = Tracer.start_transaction_or_segment(
|
127
|
+
name: name,
|
128
|
+
category: category,
|
129
|
+
options: options
|
130
|
+
)
|
108
131
|
|
109
132
|
begin
|
110
133
|
# We shouldn't raise from Transaction.start, but only wrap the yield
|
@@ -114,26 +137,10 @@ module NewRelic
|
|
114
137
|
Transaction.notice_error(e)
|
115
138
|
raise e
|
116
139
|
ensure
|
117
|
-
|
140
|
+
finishable.finish if finishable
|
118
141
|
end
|
119
142
|
end
|
120
143
|
|
121
|
-
def self.start(state, category, options)
|
122
|
-
category ||= :controller
|
123
|
-
txn = state.current_transaction
|
124
|
-
|
125
|
-
if txn
|
126
|
-
txn.create_nested_frame(category, options)
|
127
|
-
else
|
128
|
-
txn = start_new_transaction(state, category, options)
|
129
|
-
end
|
130
|
-
|
131
|
-
txn
|
132
|
-
rescue => e
|
133
|
-
NewRelic::Agent.logger.error("Exception during Transaction.start", e)
|
134
|
-
nil
|
135
|
-
end
|
136
|
-
|
137
144
|
def self.start_new_transaction(state, category, options)
|
138
145
|
txn = Transaction.new(category, options)
|
139
146
|
state.reset(txn)
|
@@ -142,53 +149,24 @@ module NewRelic
|
|
142
149
|
txn
|
143
150
|
end
|
144
151
|
|
145
|
-
FAILED_TO_STOP_MESSAGE = "Failed during Transaction.stop because there is no current transaction"
|
146
|
-
|
147
|
-
def self.stop(state)
|
148
|
-
txn = state.current_transaction
|
149
|
-
|
150
|
-
if txn.nil?
|
151
|
-
NewRelic::Agent.logger.error(FAILED_TO_STOP_MESSAGE)
|
152
|
-
return
|
153
|
-
end
|
154
|
-
|
155
|
-
nested_frame = txn.frame_stack.pop
|
156
|
-
|
157
|
-
if txn.frame_stack.empty?
|
158
|
-
txn.stop(nested_frame) if nested_frame
|
159
|
-
state.reset
|
160
|
-
else
|
161
|
-
nested_frame.finish
|
162
|
-
end
|
163
|
-
|
164
|
-
:transaction_stopped
|
165
|
-
rescue => e
|
166
|
-
state.reset
|
167
|
-
NewRelic::Agent.logger.error("Exception during Transaction.stop", e)
|
168
|
-
nil
|
169
|
-
end
|
170
|
-
|
171
152
|
def self.nested_transaction_name(name)
|
172
153
|
if name.start_with?(CONTROLLER_PREFIX) || name.start_with?(OTHER_TRANSACTION_PREFIX)
|
173
|
-
"#{
|
154
|
+
"#{NESTED_TRANSACTION_PREFIX}#{name}"
|
174
155
|
else
|
175
156
|
name
|
176
157
|
end
|
177
158
|
end
|
178
159
|
|
179
|
-
#
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
txn.abort_transaction! if txn
|
160
|
+
# discards the currently saved transaction information
|
161
|
+
def self.abort_transaction!
|
162
|
+
if txn = Tracer.current_transaction
|
163
|
+
txn.abort_transaction!
|
164
|
+
end
|
185
165
|
end
|
186
166
|
|
187
167
|
# See NewRelic::Agent.notice_error for options and commentary
|
188
|
-
def self.notice_error(e, options={})
|
189
|
-
|
190
|
-
txn = state.current_transaction
|
191
|
-
if txn
|
168
|
+
def self.notice_error(e, options={})
|
169
|
+
if txn = Tracer.current_transaction
|
192
170
|
txn.notice_error(e, options)
|
193
171
|
elsif NewRelic::Agent.instance
|
194
172
|
NewRelic::Agent.instance.error_collector.notice_error(e, options)
|
@@ -230,6 +208,7 @@ module NewRelic
|
|
230
208
|
|
231
209
|
def add_agent_attribute(key, value, default_destinations)
|
232
210
|
@attributes.add_agent_attribute(key, value, default_destinations)
|
211
|
+
current_segment.add_agent_attribute(key, value) if current_segment
|
233
212
|
end
|
234
213
|
|
235
214
|
def self.merge_untrusted_agent_attributes(attributes, prefix, default_destinations)
|
@@ -242,6 +221,7 @@ module NewRelic
|
|
242
221
|
|
243
222
|
def merge_untrusted_agent_attributes(attributes, prefix, default_destinations)
|
244
223
|
@attributes.merge_untrusted_agent_attributes(attributes, prefix, default_destinations)
|
224
|
+
current_segment.merge_untrusted_agent_attributes(attributes, prefix, default_destinations) if current_segment
|
245
225
|
end
|
246
226
|
|
247
227
|
@@java_classes_loaded = false
|
@@ -260,7 +240,6 @@ module NewRelic
|
|
260
240
|
@nesting_max_depth = 0
|
261
241
|
@current_segment = nil
|
262
242
|
@segments = []
|
263
|
-
@frame_stack = []
|
264
243
|
|
265
244
|
self.default_name = options[:transaction_name]
|
266
245
|
@overridden_name = nil
|
@@ -278,7 +257,7 @@ module NewRelic
|
|
278
257
|
|
279
258
|
@exceptions = {}
|
280
259
|
@metrics = TransactionMetrics.new
|
281
|
-
@guid = generate_guid
|
260
|
+
@guid = NewRelic::Agent::GuidGenerator.generate_guid
|
282
261
|
|
283
262
|
@ignore_this_transaction = false
|
284
263
|
@ignore_apdex = options.fetch(:ignore_apdex, false)
|
@@ -301,6 +280,10 @@ module NewRelic
|
|
301
280
|
end
|
302
281
|
end
|
303
282
|
|
283
|
+
def distributed_tracer
|
284
|
+
@distributed_tracer ||= DistributedTracer.new(self)
|
285
|
+
end
|
286
|
+
|
304
287
|
def sampled?
|
305
288
|
return unless Agent.config[:'distributed_tracing.enabled']
|
306
289
|
if @sampled.nil?
|
@@ -309,12 +292,16 @@ module NewRelic
|
|
309
292
|
@sampled
|
310
293
|
end
|
311
294
|
|
295
|
+
def trace_id
|
296
|
+
@trace_id ||= NewRelic::Agent::GuidGenerator.generate_guid 32
|
297
|
+
end
|
298
|
+
|
299
|
+
def trace_id=(value)
|
300
|
+
@trace_id = value
|
301
|
+
end
|
302
|
+
|
312
303
|
def priority
|
313
|
-
|
314
|
-
@priority = rand.round(6)
|
315
|
-
@priority += 1 if sampled?
|
316
|
-
end
|
317
|
-
@priority
|
304
|
+
@priority ||= (sampled? ? 1.0 + rand : rand).round(NewRelic::PRIORITY_PRECISION)
|
318
305
|
end
|
319
306
|
|
320
307
|
def referer
|
@@ -359,11 +346,6 @@ module NewRelic
|
|
359
346
|
merge_untrusted_agent_attributes(params, :'request.parameters', AttributeFilter::DST_NONE)
|
360
347
|
end
|
361
348
|
|
362
|
-
def make_transaction_name(name, category=nil)
|
363
|
-
namer = Instrumentation::ControllerInstrumentation::TransactionNamer
|
364
|
-
"#{namer.prefix_for_category(self, category)}#{name}"
|
365
|
-
end
|
366
|
-
|
367
349
|
def set_default_transaction_name(name, category)
|
368
350
|
return log_frozen_name(name) if name_frozen?
|
369
351
|
if influences_transaction_name?(category)
|
@@ -380,35 +362,26 @@ module NewRelic
|
|
380
362
|
end
|
381
363
|
end
|
382
364
|
|
383
|
-
def name_last_frame(name)
|
384
|
-
name = self.class.nested_transaction_name(name) if nesting_max_depth > 1
|
385
|
-
frame_stack.last.name = name
|
386
|
-
end
|
387
|
-
|
388
365
|
def log_frozen_name(name)
|
389
366
|
NewRelic::Agent.logger.warn("Attempted to rename transaction to '#{name}' after transaction name was already frozen as '#{@frozen_name}'.")
|
390
367
|
nil
|
391
368
|
end
|
392
369
|
|
393
370
|
def influences_transaction_name?(category)
|
394
|
-
!category ||
|
371
|
+
!category || nesting_max_depth == 1 || similar_category?(category)
|
395
372
|
end
|
396
373
|
|
397
374
|
def best_name
|
398
|
-
@frozen_name
|
399
|
-
|
375
|
+
@frozen_name ||
|
376
|
+
@overridden_name ||
|
377
|
+
@default_name ||
|
378
|
+
NewRelic::Agent::UNKNOWN_METRIC
|
400
379
|
end
|
401
380
|
|
402
381
|
# For common interface with Trace
|
403
382
|
alias_method :transaction_name, :best_name
|
404
|
-
|
405
|
-
attr_accessor :xray_session_id
|
406
383
|
# End common interface
|
407
384
|
|
408
|
-
def name_set?
|
409
|
-
(@overridden_name || @default_name) ? true : false
|
410
|
-
end
|
411
|
-
|
412
385
|
def promoted_transaction_name(name)
|
413
386
|
if name.start_with?(MIDDLEWARE_PREFIX)
|
414
387
|
"#{CONTROLLER_PREFIX}#{name}"
|
@@ -449,14 +422,18 @@ module NewRelic
|
|
449
422
|
|
450
423
|
ignore! if user_defined_rules_ignore?
|
451
424
|
|
452
|
-
create_initial_segment
|
425
|
+
create_initial_segment
|
426
|
+
Segment.merge_untrusted_agent_attributes \
|
427
|
+
@filtered_params,
|
428
|
+
:'request.parameters',
|
429
|
+
AttributeFilter::DST_SPAN_EVENTS
|
453
430
|
end
|
454
431
|
|
455
432
|
def initial_segment
|
456
433
|
segments.first
|
457
434
|
end
|
458
435
|
|
459
|
-
def create_initial_segment
|
436
|
+
def create_initial_segment
|
460
437
|
segment = create_segment @default_name
|
461
438
|
segment.record_scoped_metric = false
|
462
439
|
end
|
@@ -470,16 +447,15 @@ module NewRelic
|
|
470
447
|
|
471
448
|
@nesting_max_depth += 1
|
472
449
|
|
473
|
-
segment =
|
450
|
+
segment = Tracer.start_segment(
|
474
451
|
name: name,
|
475
452
|
unscoped_metrics: summary_metrics
|
476
453
|
)
|
477
454
|
|
478
|
-
frame_stack.push segment
|
479
455
|
segment
|
480
456
|
end
|
481
457
|
|
482
|
-
def
|
458
|
+
def create_nested_segment(category, options)
|
483
459
|
if options[:filtered_params] && !options[:filtered_params].empty?
|
484
460
|
@filtered_params = options[:filtered_params]
|
485
461
|
merge_request_parameters(options[:filtered_params])
|
@@ -488,10 +464,11 @@ module NewRelic
|
|
488
464
|
@ignore_apdex = options[:ignore_apdex] if options.key? :ignore_apdex
|
489
465
|
@ignore_enduser = options[:ignore_enduser] if options.key? :ignore_enduser
|
490
466
|
|
491
|
-
nest_initial_segment if
|
467
|
+
nest_initial_segment if segments.length == 1
|
492
468
|
nested_name = self.class.nested_transaction_name options[:transaction_name]
|
493
|
-
create_segment nested_name
|
469
|
+
segment = create_segment nested_name
|
494
470
|
set_default_transaction_name(options[:transaction_name], category)
|
471
|
+
segment
|
495
472
|
end
|
496
473
|
|
497
474
|
def nest_initial_segment
|
@@ -505,9 +482,6 @@ module NewRelic
|
|
505
482
|
@ignore_trace = true
|
506
483
|
end
|
507
484
|
|
508
|
-
WEB_SUMMARY_METRIC = 'HttpDispatcher'.freeze
|
509
|
-
OTHER_SUMMARY_METRIC = 'OtherTransaction/all'.freeze
|
510
|
-
|
511
485
|
def summary_metrics
|
512
486
|
if @frozen_name.start_with?(CONTROLLER_PREFIX)
|
513
487
|
[WEB_SUMMARY_METRIC]
|
@@ -529,23 +503,29 @@ module NewRelic
|
|
529
503
|
name.start_with?(MIDDLEWARE_PREFIX)
|
530
504
|
end
|
531
505
|
|
532
|
-
def
|
533
|
-
return
|
534
|
-
return self.class.stop(state) unless outermost_frame
|
535
|
-
|
506
|
+
def finish
|
507
|
+
return unless state.is_execution_traced?
|
536
508
|
@end_time = Time.now
|
537
509
|
@duration = @end_time.to_f - @start_time.to_f
|
538
510
|
freeze_name_and_execute_if_not_ignored
|
539
511
|
|
540
512
|
if nesting_max_depth == 1
|
541
|
-
|
513
|
+
initial_segment.name = @frozen_name
|
542
514
|
end
|
543
515
|
|
544
|
-
|
516
|
+
initial_segment.transaction_name = @frozen_name
|
517
|
+
assign_segment_dt_attributes
|
518
|
+
assign_agent_attributes
|
519
|
+
initial_segment.finish
|
545
520
|
|
546
521
|
NewRelic::Agent::TransactionTimeAggregator.transaction_stop(@end_time, @starting_thread_id)
|
547
522
|
|
548
|
-
commit!(
|
523
|
+
commit!(initial_segment.name) unless @ignore_this_transaction
|
524
|
+
rescue => e
|
525
|
+
NewRelic::Agent.logger.error("Exception during Transaction#finish", e)
|
526
|
+
nil
|
527
|
+
ensure
|
528
|
+
state.reset
|
549
529
|
end
|
550
530
|
|
551
531
|
def user_defined_rules_ignore?
|
@@ -559,8 +539,6 @@ module NewRelic
|
|
559
539
|
|
560
540
|
def commit!(outermost_node_name)
|
561
541
|
generate_payload
|
562
|
-
|
563
|
-
assign_agent_attributes
|
564
542
|
assign_intrinsics
|
565
543
|
|
566
544
|
finalize_segments
|
@@ -572,8 +550,7 @@ module NewRelic
|
|
572
550
|
record_total_time_metrics
|
573
551
|
record_apdex unless ignore_apdex?
|
574
552
|
record_queue_time
|
575
|
-
|
576
|
-
record_distributed_tracing_metrics
|
553
|
+
distributed_tracer.record_metrics
|
577
554
|
|
578
555
|
record_exceptions
|
579
556
|
record_transaction_event
|
@@ -581,13 +558,20 @@ module NewRelic
|
|
581
558
|
send_transaction_finished_event
|
582
559
|
end
|
583
560
|
|
561
|
+
def assign_segment_dt_attributes
|
562
|
+
dt_payload = distributed_tracer.trace_state_payload || distributed_tracer.distributed_trace_payload
|
563
|
+
parent_attributes = {}
|
564
|
+
DistributedTraceAttributes.copy_parent_attributes self, dt_payload, parent_attributes
|
565
|
+
parent_attributes.each { |k, v| initial_segment.add_agent_attribute k, v }
|
566
|
+
end
|
567
|
+
|
584
568
|
def assign_agent_attributes
|
585
569
|
default_destinations = AttributeFilter::DST_TRANSACTION_TRACER |
|
586
570
|
AttributeFilter::DST_TRANSACTION_EVENTS |
|
587
571
|
AttributeFilter::DST_ERROR_COLLECTOR
|
588
572
|
|
589
573
|
if http_response_code
|
590
|
-
add_agent_attribute(:
|
574
|
+
add_agent_attribute(:'http.statusCode', http_response_code, default_destinations)
|
591
575
|
end
|
592
576
|
|
593
577
|
if response_content_length
|
@@ -625,11 +609,7 @@ module NewRelic
|
|
625
609
|
attributes.add_intrinsic_attribute(:synthetics_monitor_id, synthetics_monitor_id)
|
626
610
|
end
|
627
611
|
|
628
|
-
|
629
|
-
assign_distributed_trace_intrinsics
|
630
|
-
elsif is_cross_app?
|
631
|
-
assign_cross_app_intrinsics
|
632
|
-
end
|
612
|
+
distributed_tracer.assign_intrinsics
|
633
613
|
end
|
634
614
|
|
635
615
|
def calculate_gc_time
|
@@ -637,6 +617,16 @@ module NewRelic
|
|
637
617
|
NewRelic::Agent::StatsEngine::GCProfiler.record_delta(gc_start_snapshot, gc_stop_snapshot)
|
638
618
|
end
|
639
619
|
|
620
|
+
# This method returns transport_duration in seconds. Transport duration
|
621
|
+
# is stored in milliseconds on the payload, but it's needed in seconds
|
622
|
+
# for metrics and intrinsics.
|
623
|
+
def calculate_transport_duration distributed_trace_payload
|
624
|
+
return unless distributed_trace_payload
|
625
|
+
|
626
|
+
duration = (start_time.to_f * 1000 - distributed_trace_payload.timestamp) / 1000
|
627
|
+
duration < 0 ? 0 : duration
|
628
|
+
end
|
629
|
+
|
640
630
|
# The summary metrics recorded by this method all end up with a duration
|
641
631
|
# equal to the transaction itself, and an exclusive time of zero.
|
642
632
|
def record_summary_metrics(outermost_node_name)
|
@@ -663,14 +653,13 @@ module NewRelic
|
|
663
653
|
:priority => priority
|
664
654
|
}
|
665
655
|
|
666
|
-
|
667
|
-
append_distributed_trace_info(@payload)
|
656
|
+
distributed_tracer.append_payload(@payload)
|
668
657
|
append_apdex_perf_zone(@payload)
|
669
658
|
append_synthetics_to(@payload)
|
670
659
|
end
|
671
660
|
|
672
661
|
def include_guid?
|
673
|
-
is_cross_app? || is_synthetics_request?
|
662
|
+
distributed_tracer.is_cross_app? || is_synthetics_request?
|
674
663
|
end
|
675
664
|
|
676
665
|
def is_synthetics_request?
|
@@ -702,10 +691,6 @@ module NewRelic
|
|
702
691
|
info[4]
|
703
692
|
end
|
704
693
|
|
705
|
-
APDEX_S = 'S'.freeze
|
706
|
-
APDEX_T = 'T'.freeze
|
707
|
-
APDEX_F = 'F'.freeze
|
708
|
-
|
709
694
|
def append_apdex_perf_zone(payload)
|
710
695
|
if recording_web_transaction?
|
711
696
|
bucket = apdex_bucket(duration, apdex_t)
|
@@ -744,13 +729,21 @@ module NewRelic
|
|
744
729
|
options[:metric] = best_name
|
745
730
|
options[:attributes] = @attributes
|
746
731
|
|
747
|
-
|
732
|
+
span_id = options.delete :span_id
|
733
|
+
error_recorded = !!agent.error_collector.notice_error(exception, options, span_id) || error_recorded
|
748
734
|
end
|
749
735
|
payload[:error] = error_recorded if payload
|
750
736
|
end
|
751
737
|
|
752
738
|
# Do not call this. Invoke the class method instead.
|
753
739
|
def notice_error(error, options={}) # :nodoc:
|
740
|
+
|
741
|
+
# Only the last error is kept
|
742
|
+
if @current_segment
|
743
|
+
@current_segment.notice_error error, expected: options[:expected]
|
744
|
+
options[:span_id] = @current_segment.guid
|
745
|
+
end
|
746
|
+
|
754
747
|
if @exceptions[error]
|
755
748
|
@exceptions[error].merge! options
|
756
749
|
else
|
@@ -762,8 +755,6 @@ module NewRelic
|
|
762
755
|
agent.transaction_event_recorder.record payload
|
763
756
|
end
|
764
757
|
|
765
|
-
QUEUE_TIME_METRIC = 'WebFrontend/QueueTime'.freeze
|
766
|
-
|
767
758
|
def queue_time
|
768
759
|
@apdex_start ? @start_time - @apdex_start : 0
|
769
760
|
end
|
@@ -779,17 +770,9 @@ module NewRelic
|
|
779
770
|
end
|
780
771
|
end
|
781
772
|
|
782
|
-
APDEX_ALL_METRIC = 'ApdexAll'.freeze
|
783
|
-
|
784
|
-
APDEX_METRIC = 'Apdex'.freeze
|
785
|
-
APDEX_OTHER_METRIC = 'ApdexOther'.freeze
|
786
|
-
|
787
|
-
APDEX_TXN_METRIC_PREFIX = 'Apdex/'.freeze
|
788
|
-
APDEX_OTHER_TXN_METRIC_PREFIX = 'ApdexOther/Transaction/'.freeze
|
789
|
-
|
790
773
|
def had_error_affecting_apdex?
|
791
774
|
@exceptions.each do |exception, options|
|
792
|
-
ignored
|
775
|
+
ignored = NewRelic::Agent.instance.error_collector.error_is_ignored?(exception)
|
793
776
|
expected = options[:expected]
|
794
777
|
|
795
778
|
return true unless ignored || expected
|
@@ -928,7 +911,6 @@ module NewRelic
|
|
928
911
|
p.stime + p.utime
|
929
912
|
end
|
930
913
|
|
931
|
-
JRUBY_CPU_TIME_ERROR = "Error calculating JRuby CPU Time".freeze
|
932
914
|
def jruby_cpu_time
|
933
915
|
return nil unless @@java_classes_loaded
|
934
916
|
threadMBean = Java::JavaLangManagement::ManagementFactory.getThreadMXBean()
|
@@ -954,18 +936,6 @@ module NewRelic
|
|
954
936
|
def sql_sampler
|
955
937
|
agent.sql_sampler
|
956
938
|
end
|
957
|
-
|
958
|
-
HEX_DIGITS = (0..15).map{|i| i.to_s(16)}
|
959
|
-
GUID_LENGTH = 16
|
960
|
-
|
961
|
-
# generate a random 64 bit uuid
|
962
|
-
def generate_guid
|
963
|
-
guid = ''
|
964
|
-
GUID_LENGTH.times do |a|
|
965
|
-
guid << HEX_DIGITS[rand(16)]
|
966
|
-
end
|
967
|
-
guid
|
968
|
-
end
|
969
939
|
end
|
970
940
|
end
|
971
941
|
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 introduced and largely extracted from the transaction event aggregator
|
6
6
|
# when the synthetics container was extracted from it. Its purpose is to create the data
|
@@ -8,7 +8,8 @@
|
|
8
8
|
# the transaction event aggregator and the synthetics container.
|
9
9
|
|
10
10
|
require 'new_relic/agent/payload_metric_mapping'
|
11
|
-
require 'new_relic/agent/distributed_trace_payload'
|
11
|
+
require 'new_relic/agent/distributed_tracing/distributed_trace_payload'
|
12
|
+
require 'new_relic/agent/distributed_tracing/distributed_trace_attributes'
|
12
13
|
|
13
14
|
module NewRelic
|
14
15
|
module Agent
|
@@ -31,16 +32,17 @@ module NewRelic
|
|
31
32
|
SYNTHETICS_JOB_ID_KEY = "nr.syntheticsJobId".freeze
|
32
33
|
SYNTHETICS_MONITOR_ID_KEY = "nr.syntheticsMonitorId".freeze
|
33
34
|
PRIORITY_KEY = "priority".freeze
|
35
|
+
SPAN_ID_KEY = "spanId".freeze
|
34
36
|
|
35
|
-
def create noticed_error, payload
|
37
|
+
def create noticed_error, payload, span_id
|
36
38
|
[
|
37
|
-
intrinsic_attributes_for(noticed_error, payload),
|
39
|
+
intrinsic_attributes_for(noticed_error, payload, span_id),
|
38
40
|
noticed_error.custom_attributes,
|
39
41
|
noticed_error.agent_attributes
|
40
42
|
]
|
41
43
|
end
|
42
44
|
|
43
|
-
def intrinsic_attributes_for noticed_error, payload
|
45
|
+
def intrinsic_attributes_for noticed_error, payload, span_id
|
44
46
|
attrs = {
|
45
47
|
TYPE_KEY => SAMPLE_TYPE,
|
46
48
|
ERROR_CLASS_KEY => noticed_error.exception_class_name,
|
@@ -49,16 +51,17 @@ module NewRelic
|
|
49
51
|
TIMESTAMP_KEY => noticed_error.timestamp.to_f
|
50
52
|
}
|
51
53
|
|
54
|
+
attrs[SPAN_ID_KEY] = span_id if span_id
|
52
55
|
attrs[PORT_KEY] = noticed_error.request_port if noticed_error.request_port
|
53
56
|
|
54
57
|
if payload
|
55
58
|
attrs[NAME_KEY] = payload[:name]
|
56
59
|
attrs[DURATION_KEY] = payload[:duration]
|
57
|
-
attrs[SAMPLED_KEY] = payload[:
|
58
|
-
attrs[PRIORITY_KEY] = payload[:
|
60
|
+
attrs[SAMPLED_KEY] = payload[:sampled] if payload.key?(:sampled)
|
61
|
+
attrs[PRIORITY_KEY] = payload[:priority]
|
59
62
|
append_synthetics payload, attrs
|
60
63
|
append_cat payload, attrs
|
61
|
-
|
64
|
+
DistributedTraceAttributes.copy_to_hash payload, attrs
|
62
65
|
PayloadMetricMapping.append_mapped_metrics payload[:metrics], attrs
|
63
66
|
end
|
64
67
|
|
@@ -75,14 +78,6 @@ module NewRelic
|
|
75
78
|
sample[GUID_KEY] = payload[:guid] if payload[:guid]
|
76
79
|
sample[REFERRING_TRANSACTION_GUID_KEY] = payload[:referring_transaction_guid] if payload[:referring_transaction_guid]
|
77
80
|
end
|
78
|
-
|
79
|
-
def append_distributed_trace_intrinsics payload, sample
|
80
|
-
return unless Agent.config[:'distributed_tracing.enabled']
|
81
|
-
DistributedTracePayload::INTRINSIC_KEYS.each do |key|
|
82
|
-
value = payload[key]
|
83
|
-
sample[key] = value unless value.nil?
|
84
|
-
end
|
85
|
-
end
|
86
81
|
end
|
87
82
|
end
|
88
83
|
end
|