newrelic_rpm 6.2.0.354 → 6.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +8 -0
- data/CHANGELOG.md +646 -6
- data/CONTRIBUTING.md +106 -19
- data/Gemfile +6 -2
- data/Guardfile +18 -1
- data/LICENSE +208 -38
- data/README.md +81 -85
- 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 +168 -185
- 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 +20 -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 +234 -51
- 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 +14 -10
- 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 +37 -3
- 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 +1 -1
- 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 -1
- data/lib/new_relic/agent/datastores.rb +1 -1
- 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} +25 -102
- 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 +156 -7
- data/lib/new_relic/agent/encoding_normalizer.rb +1 -1
- data/lib/new_relic/agent/error_collector.rb +36 -19
- 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 +8 -8
- 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 +9 -3
- 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 -46
- data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +51 -75
- data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +81 -56
- data/lib/new_relic/agent/instrumentation/active_job.rb +1 -1
- 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 +168 -0
- data/lib/new_relic/agent/instrumentation/active_record_prepend.rb +35 -11
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +46 -48
- data/lib/new_relic/agent/instrumentation/active_storage.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_storage_subscriber.rb +12 -8
- 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 +48 -29
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/curb.rb +66 -19
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +4 -2
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +3 -1
- data/lib/new_relic/agent/instrumentation/excon/connection.rb +7 -4
- data/lib/new_relic/agent/instrumentation/excon/middleware.rb +3 -2
- data/lib/new_relic/agent/instrumentation/excon.rb +2 -2
- data/lib/new_relic/agent/instrumentation/grape.rb +8 -14
- data/lib/new_relic/agent/instrumentation/http.rb +7 -4
- data/lib/new_relic/agent/instrumentation/httpclient.rb +6 -4
- data/lib/new_relic/agent/instrumentation/ignore_actions.rb +1 -1
- data/lib/new_relic/agent/instrumentation/memcache/dalli.rb +7 -3
- data/lib/new_relic/agent/instrumentation/memcache.rb +4 -2
- 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 +1 -1
- data/lib/new_relic/agent/instrumentation/middleware_tracing.rb +9 -7
- data/lib/new_relic/agent/instrumentation/mongo.rb +10 -4
- data/lib/new_relic/agent/instrumentation/mongodb_command_subscriber.rb +36 -3
- data/lib/new_relic/agent/instrumentation/net.rb +48 -28
- data/lib/new_relic/agent/instrumentation/net_prepend.rb +40 -0
- data/lib/new_relic/agent/instrumentation/notifications_subscriber.rb +100 -0
- data/lib/new_relic/agent/instrumentation/padrino.rb +3 -1
- 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 +3 -1
- 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/{rails5 → 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 +2 -1
- data/lib/new_relic/agent/instrumentation/redis.rb +12 -6
- data/lib/new_relic/agent/instrumentation/resque.rb +4 -1
- 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/ignorer.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sinatra/transaction_namer.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sinatra.rb +1 -2
- data/lib/new_relic/agent/instrumentation/sunspot.rb +1 -1
- data/lib/new_relic/agent/instrumentation/typhoeus.rb +24 -7
- 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 +2 -2
- 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 +6 -74
- data/lib/new_relic/agent/method_tracer.rb +10 -8
- data/lib/new_relic/agent/method_tracer_helpers.rb +3 -3
- 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} +3 -5
- 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 -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 +1 -1
- data/lib/new_relic/agent/new_relic_service.rb +34 -14
- 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 +6 -6
- 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 +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 +13 -4
- data/lib/new_relic/agent/threading/agent_thread.rb +1 -1
- 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 +66 -19
- data/lib/new_relic/agent/transaction/abstract_segment.rb +32 -5
- 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 +58 -147
- 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 -1
- data/lib/new_relic/agent/transaction/transaction_sample_buffer.rb +1 -1
- data/lib/new_relic/agent/transaction.rb +104 -84
- 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 +1 -1
- 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 +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/vm.rb +1 -1
- data/lib/new_relic/agent/worker_loop.rb +1 -1
- data/lib/new_relic/agent.rb +98 -8
- 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 +1 -1
- 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 +11 -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 +9 -5
- 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 +39 -18
- data/lib/new_relic/rack/agent_hooks.rb +1 -1
- data/lib/new_relic/rack/agent_middleware.rb +1 -1
- 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 +17 -1
- data/lib/new_relic/version.rb +2 -2
- 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 -10
- data/recipes/newrelic.rb +1 -1
- data/test/agent_helper.rb +356 -76
- metadata +116 -52
- data/.travis.yml +0 -153
- 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 -40
- 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/rails4/action_controller.rb +0 -32
- data/lib/new_relic/agent/instrumentation/rails4/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/build.rb +0 -2
- data/lib/new_relic/control/frameworks/rails6.rb +0 -14
- 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,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
|
module NewRelic
|
6
6
|
module Agent
|
@@ -22,12 +22,17 @@ module NewRelic
|
|
22
22
|
@metric_name = metric_name || UNKNOWN_NODE_NAME
|
23
23
|
@exit_timestamp = relative_end
|
24
24
|
@children = nil
|
25
|
-
@params = params
|
26
|
-
NewRelic::Agent.instance.attribute_filter.allows_key? p, AttributeFilter::DST_TRANSACTION_SEGMENTS
|
27
|
-
end if params
|
25
|
+
@params = select_allowed_params(params)
|
28
26
|
@parent_node = parent
|
29
27
|
end
|
30
28
|
|
29
|
+
def select_allowed_params params
|
30
|
+
return unless params
|
31
|
+
params.select do |p|
|
32
|
+
NewRelic::Agent.instance.attribute_filter.allows_key? p, AttributeFilter::DST_TRANSACTION_SEGMENTS
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
31
36
|
# sets the final timestamp on a node to indicate the exit
|
32
37
|
# point of the node
|
33
38
|
def end_trace(timestamp)
|
@@ -38,16 +43,13 @@ module NewRelic
|
|
38
43
|
to_debug_str(0)
|
39
44
|
end
|
40
45
|
|
41
|
-
EMPTY_HASH = {}.freeze
|
42
|
-
EMPTY_ARRAY = [].freeze
|
43
|
-
|
44
46
|
def to_array
|
45
|
-
params = @params ? @params : EMPTY_HASH
|
47
|
+
params = @params ? @params : NewRelic::EMPTY_HASH
|
46
48
|
[ NewRelic::Helper.time_to_millis(@entry_timestamp),
|
47
49
|
NewRelic::Helper.time_to_millis(@exit_timestamp),
|
48
50
|
NewRelic::Coerce.string(@metric_name),
|
49
51
|
params ] +
|
50
|
-
[ (@children ? @children.map{|s| s.to_array} : EMPTY_ARRAY) ]
|
52
|
+
[ (@children ? @children.map{|s| s.to_array} : NewRelic::EMPTY_ARRAY) ]
|
51
53
|
end
|
52
54
|
|
53
55
|
def path_string
|
@@ -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
|
module NewRelic
|
6
6
|
module Agent
|
@@ -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
|
module NewRelic
|
6
6
|
module Agent
|
@@ -1,17 +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
14
|
require 'new_relic/agent/deprecator'
|
15
|
+
require 'new_relic/agent/guid_generator'
|
15
16
|
|
16
17
|
module NewRelic
|
17
18
|
module Agent
|
@@ -21,26 +22,38 @@ module NewRelic
|
|
21
22
|
# @api public
|
22
23
|
class Transaction
|
23
24
|
include Tracing
|
24
|
-
include DistributedTracing
|
25
|
-
include CrossAppTracing
|
26
25
|
|
27
26
|
# for nested transactions
|
28
|
-
|
29
|
-
CONTROLLER_PREFIX =
|
30
|
-
MIDDLEWARE_PREFIX =
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
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/"
|
39
38
|
|
40
39
|
WEB_TRANSACTION_CATEGORIES = [:web, :controller, :uri, :rack, :sinatra, :grape, :middleware, :action_cable].freeze
|
41
40
|
TRANSACTION_NAMING_SOURCES = [:child, :api].freeze
|
42
41
|
|
43
|
-
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"
|
44
57
|
|
45
58
|
# reference to the transaction state managing this transaction
|
46
59
|
attr_accessor :state
|
@@ -59,7 +72,8 @@ module NewRelic
|
|
59
72
|
:process_cpu_start,
|
60
73
|
:http_response_code,
|
61
74
|
:response_content_length,
|
62
|
-
:response_content_type
|
75
|
+
:response_content_type,
|
76
|
+
:parent_span_id
|
63
77
|
|
64
78
|
attr_reader :guid,
|
65
79
|
:metrics,
|
@@ -137,23 +151,22 @@ module NewRelic
|
|
137
151
|
|
138
152
|
def self.nested_transaction_name(name)
|
139
153
|
if name.start_with?(CONTROLLER_PREFIX) || name.start_with?(OTHER_TRANSACTION_PREFIX)
|
140
|
-
"#{
|
154
|
+
"#{NESTED_TRANSACTION_PREFIX}#{name}"
|
141
155
|
else
|
142
156
|
name
|
143
157
|
end
|
144
158
|
end
|
145
159
|
|
146
|
-
#
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
160
|
+
# discards the currently saved transaction information
|
161
|
+
def self.abort_transaction!
|
162
|
+
if txn = Tracer.current_transaction
|
163
|
+
txn.abort_transaction!
|
164
|
+
end
|
151
165
|
end
|
152
166
|
|
153
167
|
# See NewRelic::Agent.notice_error for options and commentary
|
154
|
-
def self.notice_error(e, options={})
|
155
|
-
txn = Tracer.current_transaction
|
156
|
-
if txn
|
168
|
+
def self.notice_error(e, options={})
|
169
|
+
if txn = Tracer.current_transaction
|
157
170
|
txn.notice_error(e, options)
|
158
171
|
elsif NewRelic::Agent.instance
|
159
172
|
NewRelic::Agent.instance.error_collector.notice_error(e, options)
|
@@ -195,6 +208,7 @@ module NewRelic
|
|
195
208
|
|
196
209
|
def add_agent_attribute(key, value, default_destinations)
|
197
210
|
@attributes.add_agent_attribute(key, value, default_destinations)
|
211
|
+
current_segment.add_agent_attribute(key, value) if current_segment
|
198
212
|
end
|
199
213
|
|
200
214
|
def self.merge_untrusted_agent_attributes(attributes, prefix, default_destinations)
|
@@ -207,6 +221,7 @@ module NewRelic
|
|
207
221
|
|
208
222
|
def merge_untrusted_agent_attributes(attributes, prefix, default_destinations)
|
209
223
|
@attributes.merge_untrusted_agent_attributes(attributes, prefix, default_destinations)
|
224
|
+
current_segment.merge_untrusted_agent_attributes(attributes, prefix, default_destinations) if current_segment
|
210
225
|
end
|
211
226
|
|
212
227
|
@@java_classes_loaded = false
|
@@ -242,7 +257,7 @@ module NewRelic
|
|
242
257
|
|
243
258
|
@exceptions = {}
|
244
259
|
@metrics = TransactionMetrics.new
|
245
|
-
@guid = generate_guid
|
260
|
+
@guid = NewRelic::Agent::GuidGenerator.generate_guid
|
246
261
|
|
247
262
|
@ignore_this_transaction = false
|
248
263
|
@ignore_apdex = options.fetch(:ignore_apdex, false)
|
@@ -265,6 +280,10 @@ module NewRelic
|
|
265
280
|
end
|
266
281
|
end
|
267
282
|
|
283
|
+
def distributed_tracer
|
284
|
+
@distributed_tracer ||= DistributedTracer.new(self)
|
285
|
+
end
|
286
|
+
|
268
287
|
def sampled?
|
269
288
|
return unless Agent.config[:'distributed_tracing.enabled']
|
270
289
|
if @sampled.nil?
|
@@ -273,12 +292,16 @@ module NewRelic
|
|
273
292
|
@sampled
|
274
293
|
end
|
275
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
|
+
|
276
303
|
def priority
|
277
|
-
|
278
|
-
@priority = rand.round(6)
|
279
|
-
@priority += 1 if sampled?
|
280
|
-
end
|
281
|
-
@priority
|
304
|
+
@priority ||= (sampled? ? 1.0 + rand : rand).round(NewRelic::PRIORITY_PRECISION)
|
282
305
|
end
|
283
306
|
|
284
307
|
def referer
|
@@ -349,14 +372,14 @@ module NewRelic
|
|
349
372
|
end
|
350
373
|
|
351
374
|
def best_name
|
352
|
-
@frozen_name
|
353
|
-
|
375
|
+
@frozen_name ||
|
376
|
+
@overridden_name ||
|
377
|
+
@default_name ||
|
378
|
+
NewRelic::Agent::UNKNOWN_METRIC
|
354
379
|
end
|
355
380
|
|
356
381
|
# For common interface with Trace
|
357
382
|
alias_method :transaction_name, :best_name
|
358
|
-
|
359
|
-
attr_accessor :xray_session_id
|
360
383
|
# End common interface
|
361
384
|
|
362
385
|
def promoted_transaction_name(name)
|
@@ -400,6 +423,10 @@ module NewRelic
|
|
400
423
|
ignore! if user_defined_rules_ignore?
|
401
424
|
|
402
425
|
create_initial_segment
|
426
|
+
Segment.merge_untrusted_agent_attributes \
|
427
|
+
@filtered_params,
|
428
|
+
:'request.parameters',
|
429
|
+
AttributeFilter::DST_SPAN_EVENTS
|
403
430
|
end
|
404
431
|
|
405
432
|
def initial_segment
|
@@ -439,9 +466,9 @@ module NewRelic
|
|
439
466
|
|
440
467
|
nest_initial_segment if nesting_max_depth == 1
|
441
468
|
nested_name = self.class.nested_transaction_name options[:transaction_name]
|
442
|
-
|
469
|
+
segment = create_segment nested_name
|
443
470
|
set_default_transaction_name(options[:transaction_name], category)
|
444
|
-
|
471
|
+
segment
|
445
472
|
end
|
446
473
|
|
447
474
|
def nest_initial_segment
|
@@ -455,9 +482,6 @@ module NewRelic
|
|
455
482
|
@ignore_trace = true
|
456
483
|
end
|
457
484
|
|
458
|
-
WEB_SUMMARY_METRIC = 'HttpDispatcher'.freeze
|
459
|
-
OTHER_SUMMARY_METRIC = 'OtherTransaction/all'.freeze
|
460
|
-
|
461
485
|
def summary_metrics
|
462
486
|
if @frozen_name.start_with?(CONTROLLER_PREFIX)
|
463
487
|
[WEB_SUMMARY_METRIC]
|
@@ -489,6 +513,9 @@ module NewRelic
|
|
489
513
|
initial_segment.name = @frozen_name
|
490
514
|
end
|
491
515
|
|
516
|
+
initial_segment.transaction_name = @frozen_name
|
517
|
+
assign_segment_dt_attributes
|
518
|
+
assign_agent_attributes
|
492
519
|
initial_segment.finish
|
493
520
|
|
494
521
|
NewRelic::Agent::TransactionTimeAggregator.transaction_stop(@end_time, @starting_thread_id)
|
@@ -512,8 +539,6 @@ module NewRelic
|
|
512
539
|
|
513
540
|
def commit!(outermost_node_name)
|
514
541
|
generate_payload
|
515
|
-
|
516
|
-
assign_agent_attributes
|
517
542
|
assign_intrinsics
|
518
543
|
|
519
544
|
finalize_segments
|
@@ -525,8 +550,7 @@ module NewRelic
|
|
525
550
|
record_total_time_metrics
|
526
551
|
record_apdex unless ignore_apdex?
|
527
552
|
record_queue_time
|
528
|
-
|
529
|
-
record_distributed_tracing_metrics
|
553
|
+
distributed_tracer.record_metrics
|
530
554
|
|
531
555
|
record_exceptions
|
532
556
|
record_transaction_event
|
@@ -534,6 +558,13 @@ module NewRelic
|
|
534
558
|
send_transaction_finished_event
|
535
559
|
end
|
536
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
|
+
|
537
568
|
def assign_agent_attributes
|
538
569
|
default_destinations = AttributeFilter::DST_TRANSACTION_TRACER |
|
539
570
|
AttributeFilter::DST_TRANSACTION_EVENTS |
|
@@ -541,6 +572,9 @@ module NewRelic
|
|
541
572
|
|
542
573
|
if http_response_code
|
543
574
|
add_agent_attribute(:httpResponseCode, http_response_code.to_s, default_destinations)
|
575
|
+
# Sending status code as an int with http.statusCode key is correct
|
576
|
+
# The above attribute is deprecated and should be removed in agent version 7.0.0
|
577
|
+
add_agent_attribute(:'http.statusCode', http_response_code, default_destinations)
|
544
578
|
end
|
545
579
|
|
546
580
|
if response_content_length
|
@@ -578,11 +612,7 @@ module NewRelic
|
|
578
612
|
attributes.add_intrinsic_attribute(:synthetics_monitor_id, synthetics_monitor_id)
|
579
613
|
end
|
580
614
|
|
581
|
-
|
582
|
-
assign_distributed_trace_intrinsics
|
583
|
-
elsif is_cross_app?
|
584
|
-
assign_cross_app_intrinsics
|
585
|
-
end
|
615
|
+
distributed_tracer.assign_intrinsics
|
586
616
|
end
|
587
617
|
|
588
618
|
def calculate_gc_time
|
@@ -590,6 +620,16 @@ module NewRelic
|
|
590
620
|
NewRelic::Agent::StatsEngine::GCProfiler.record_delta(gc_start_snapshot, gc_stop_snapshot)
|
591
621
|
end
|
592
622
|
|
623
|
+
# This method returns transport_duration in seconds. Transport duration
|
624
|
+
# is stored in milliseconds on the payload, but it's needed in seconds
|
625
|
+
# for metrics and intrinsics.
|
626
|
+
def calculate_transport_duration distributed_trace_payload
|
627
|
+
return unless distributed_trace_payload
|
628
|
+
|
629
|
+
duration = (start_time.to_f * 1000 - distributed_trace_payload.timestamp) / 1000
|
630
|
+
duration < 0 ? 0 : duration
|
631
|
+
end
|
632
|
+
|
593
633
|
# The summary metrics recorded by this method all end up with a duration
|
594
634
|
# equal to the transaction itself, and an exclusive time of zero.
|
595
635
|
def record_summary_metrics(outermost_node_name)
|
@@ -616,14 +656,13 @@ module NewRelic
|
|
616
656
|
:priority => priority
|
617
657
|
}
|
618
658
|
|
619
|
-
|
620
|
-
append_distributed_trace_info(@payload)
|
659
|
+
distributed_tracer.append_payload(@payload)
|
621
660
|
append_apdex_perf_zone(@payload)
|
622
661
|
append_synthetics_to(@payload)
|
623
662
|
end
|
624
663
|
|
625
664
|
def include_guid?
|
626
|
-
is_cross_app? || is_synthetics_request?
|
665
|
+
distributed_tracer.is_cross_app? || is_synthetics_request?
|
627
666
|
end
|
628
667
|
|
629
668
|
def is_synthetics_request?
|
@@ -655,10 +694,6 @@ module NewRelic
|
|
655
694
|
info[4]
|
656
695
|
end
|
657
696
|
|
658
|
-
APDEX_S = 'S'.freeze
|
659
|
-
APDEX_T = 'T'.freeze
|
660
|
-
APDEX_F = 'F'.freeze
|
661
|
-
|
662
697
|
def append_apdex_perf_zone(payload)
|
663
698
|
if recording_web_transaction?
|
664
699
|
bucket = apdex_bucket(duration, apdex_t)
|
@@ -697,13 +732,21 @@ module NewRelic
|
|
697
732
|
options[:metric] = best_name
|
698
733
|
options[:attributes] = @attributes
|
699
734
|
|
700
|
-
|
735
|
+
span_id = options.delete :span_id
|
736
|
+
error_recorded = !!agent.error_collector.notice_error(exception, options, span_id) || error_recorded
|
701
737
|
end
|
702
738
|
payload[:error] = error_recorded if payload
|
703
739
|
end
|
704
740
|
|
705
741
|
# Do not call this. Invoke the class method instead.
|
706
742
|
def notice_error(error, options={}) # :nodoc:
|
743
|
+
|
744
|
+
# Only the last error is kept
|
745
|
+
if @current_segment
|
746
|
+
@current_segment.notice_error error, expected: options[:expected]
|
747
|
+
options[:span_id] = @current_segment.guid
|
748
|
+
end
|
749
|
+
|
707
750
|
if @exceptions[error]
|
708
751
|
@exceptions[error].merge! options
|
709
752
|
else
|
@@ -715,8 +758,6 @@ module NewRelic
|
|
715
758
|
agent.transaction_event_recorder.record payload
|
716
759
|
end
|
717
760
|
|
718
|
-
QUEUE_TIME_METRIC = 'WebFrontend/QueueTime'.freeze
|
719
|
-
|
720
761
|
def queue_time
|
721
762
|
@apdex_start ? @start_time - @apdex_start : 0
|
722
763
|
end
|
@@ -732,17 +773,9 @@ module NewRelic
|
|
732
773
|
end
|
733
774
|
end
|
734
775
|
|
735
|
-
APDEX_ALL_METRIC = 'ApdexAll'.freeze
|
736
|
-
|
737
|
-
APDEX_METRIC = 'Apdex'.freeze
|
738
|
-
APDEX_OTHER_METRIC = 'ApdexOther'.freeze
|
739
|
-
|
740
|
-
APDEX_TXN_METRIC_PREFIX = 'Apdex/'.freeze
|
741
|
-
APDEX_OTHER_TXN_METRIC_PREFIX = 'ApdexOther/Transaction/'.freeze
|
742
|
-
|
743
776
|
def had_error_affecting_apdex?
|
744
777
|
@exceptions.each do |exception, options|
|
745
|
-
ignored
|
778
|
+
ignored = NewRelic::Agent.instance.error_collector.error_is_ignored?(exception)
|
746
779
|
expected = options[:expected]
|
747
780
|
|
748
781
|
return true unless ignored || expected
|
@@ -881,7 +914,6 @@ module NewRelic
|
|
881
914
|
p.stime + p.utime
|
882
915
|
end
|
883
916
|
|
884
|
-
JRUBY_CPU_TIME_ERROR = "Error calculating JRuby CPU Time".freeze
|
885
917
|
def jruby_cpu_time
|
886
918
|
return nil unless @@java_classes_loaded
|
887
919
|
threadMBean = Java::JavaLangManagement::ManagementFactory.getThreadMXBean()
|
@@ -907,18 +939,6 @@ module NewRelic
|
|
907
939
|
def sql_sampler
|
908
940
|
agent.sql_sampler
|
909
941
|
end
|
910
|
-
|
911
|
-
HEX_DIGITS = (0..15).map{|i| i.to_s(16)}
|
912
|
-
GUID_LENGTH = 16
|
913
|
-
|
914
|
-
# generate a random 64 bit uuid
|
915
|
-
def generate_guid
|
916
|
-
guid = ''
|
917
|
-
GUID_LENGTH.times do |a|
|
918
|
-
guid << HEX_DIGITS[rand(16)]
|
919
|
-
end
|
920
|
-
guid
|
921
|
-
end
|
922
942
|
end
|
923
943
|
end
|
924
944
|
end
|