newrelic_rpm 7.0.0 → 8.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -1
- data/.rubocop.yml +1941 -0
- data/.yardopts +1 -0
- data/Brewfile +10 -0
- data/CHANGELOG.md +431 -1
- data/CONTRIBUTING.md +32 -5
- data/DOCKER.md +167 -0
- data/Dockerfile +10 -0
- data/Guardfile +8 -8
- data/LICENSE +0 -6
- data/README.md +20 -18
- data/Rakefile +39 -29
- data/THIRD_PARTY_NOTICES.md +14 -199
- data/bin/mongrel_rpm +8 -9
- data/bin/newrelic +1 -1
- data/bin/nrdebug +14 -14
- data/docker-compose.yml +85 -0
- data/init.rb +0 -2
- data/lefthook.yml +9 -0
- data/lib/new_relic/agent/adaptive_sampler.rb +9 -5
- data/lib/new_relic/agent/agent.rb +72 -49
- data/lib/new_relic/agent/agent_logger.rb +15 -9
- data/lib/new_relic/agent/attribute_filter.rb +31 -31
- data/lib/new_relic/agent/attributes.rb +2 -2
- data/lib/new_relic/agent/audit_logger.rb +4 -0
- data/lib/new_relic/agent/autostart.rb +19 -17
- data/lib/new_relic/agent/commands/agent_command.rb +2 -2
- data/lib/new_relic/agent/commands/agent_command_router.rb +6 -5
- data/lib/new_relic/agent/commands/thread_profiler_session.rb +7 -6
- data/lib/new_relic/agent/configuration/default_source.rb +731 -476
- data/lib/new_relic/agent/configuration/dotted_hash.rb +3 -3
- data/lib/new_relic/agent/configuration/environment_source.rb +5 -4
- data/lib/new_relic/agent/configuration/event_harvest_config.rb +39 -16
- data/lib/new_relic/agent/configuration/high_security_source.rb +7 -7
- data/lib/new_relic/agent/configuration/manager.rb +74 -64
- data/lib/new_relic/agent/configuration/mask_defaults.rb +1 -1
- data/lib/new_relic/agent/configuration/security_policy_source.rb +73 -73
- data/lib/new_relic/agent/configuration/server_source.rb +14 -12
- data/lib/new_relic/agent/configuration/yaml_source.rb +26 -5
- data/lib/new_relic/agent/connect/request_builder.rb +14 -15
- data/lib/new_relic/agent/connect/response_handler.rb +0 -3
- data/lib/new_relic/agent/custom_event_aggregator.rb +9 -9
- data/lib/new_relic/agent/database/explain_plan_helpers.rb +3 -4
- data/lib/new_relic/agent/database/obfuscation_helpers.rb +12 -12
- data/lib/new_relic/agent/database/postgres_explain_obfuscator.rb +2 -2
- data/lib/new_relic/agent/database.rb +30 -31
- data/lib/new_relic/agent/datastores/metric_helper.rb +13 -11
- data/lib/new_relic/agent/datastores/mongo/event_formatter.rb +2 -3
- data/lib/new_relic/agent/datastores/mongo/metric_translator.rb +3 -5
- data/lib/new_relic/agent/datastores/mongo/obfuscator.rb +1 -2
- data/lib/new_relic/agent/datastores/mongo.rb +5 -10
- data/lib/new_relic/agent/datastores/redis.rb +2 -4
- data/lib/new_relic/agent/datastores.rb +7 -9
- data/lib/new_relic/agent/distributed_tracing/cross_app_payload.rb +9 -9
- data/lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb +21 -16
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_attributes.rb +10 -12
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb +42 -43
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_transport_type.rb +3 -3
- data/lib/new_relic/agent/distributed_tracing/trace_context.rb +41 -43
- data/lib/new_relic/agent/distributed_tracing/trace_context_payload.rb +25 -25
- data/lib/new_relic/agent/distributed_tracing.rb +17 -18
- data/lib/new_relic/agent/encoding_normalizer.rb +1 -1
- data/lib/new_relic/agent/error_collector.rb +65 -50
- data/lib/new_relic/agent/error_event_aggregator.rb +1 -1
- data/lib/new_relic/agent/error_filter.rb +173 -0
- data/lib/new_relic/agent/error_trace_aggregator.rb +1 -1
- data/lib/new_relic/agent/event_aggregator.rb +1 -1
- data/lib/new_relic/agent/event_buffer.rb +6 -7
- data/lib/new_relic/agent/event_listener.rb +0 -1
- data/lib/new_relic/agent/event_loop.rb +14 -14
- data/lib/new_relic/agent/external.rb +1 -34
- data/lib/new_relic/agent/guid_generator.rb +2 -9
- data/lib/new_relic/agent/harvester.rb +3 -4
- data/lib/new_relic/agent/heap.rb +1 -3
- data/lib/new_relic/agent/hostname.rb +16 -10
- data/lib/new_relic/agent/http_clients/abstract.rb +7 -9
- data/lib/new_relic/agent/http_clients/curb_wrappers.rb +1 -5
- data/lib/new_relic/agent/http_clients/excon_wrappers.rb +4 -4
- data/lib/new_relic/agent/http_clients/http_rb_wrappers.rb +3 -3
- data/lib/new_relic/agent/http_clients/httpclient_wrappers.rb +1 -2
- data/lib/new_relic/agent/http_clients/net_http_wrappers.rb +8 -3
- data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +2 -3
- data/lib/new_relic/agent/http_clients/uri_util.rb +0 -1
- data/lib/new_relic/agent/instrumentation/action_cable_subscriber.rb +2 -3
- data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +28 -26
- data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +5 -7
- data/lib/new_relic/agent/instrumentation/active_job.rb +12 -5
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +17 -3
- data/lib/new_relic/agent/instrumentation/active_record.rb +20 -18
- data/lib/new_relic/agent/instrumentation/active_record_helper.rb +56 -46
- data/lib/new_relic/agent/instrumentation/active_record_notifications.rb +28 -25
- data/lib/new_relic/agent/instrumentation/active_record_prepend.rb +3 -3
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +22 -16
- data/lib/new_relic/agent/instrumentation/active_storage.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_support_logger/chain.rb +23 -0
- data/lib/new_relic/agent/instrumentation/active_support_logger/instrumentation.rb +20 -0
- data/lib/new_relic/agent/instrumentation/active_support_logger/prepend.rb +12 -0
- data/lib/new_relic/agent/instrumentation/active_support_logger.rb +24 -0
- data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +18 -9
- data/lib/new_relic/agent/instrumentation/authlogic.rb +10 -0
- data/lib/new_relic/agent/instrumentation/bunny/chain.rb +1 -1
- data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +8 -9
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +52 -46
- data/lib/new_relic/agent/instrumentation/curb/chain.rb +20 -21
- data/lib/new_relic/agent/instrumentation/curb/instrumentation.rb +34 -38
- data/lib/new_relic/agent/instrumentation/curb/prepend.rb +10 -11
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +22 -10
- data/lib/new_relic/agent/instrumentation/delayed_job/chain.rb +5 -7
- data/lib/new_relic/agent/instrumentation/delayed_job/instrumentation.rb +5 -9
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +23 -4
- data/lib/new_relic/agent/instrumentation/excon/middleware.rb +2 -2
- data/lib/new_relic/agent/instrumentation/excon.rb +3 -23
- data/lib/new_relic/agent/instrumentation/grape/chain.rb +1 -2
- data/lib/new_relic/agent/instrumentation/grape/instrumentation.rb +6 -7
- data/lib/new_relic/agent/instrumentation/grape.rb +2 -3
- data/lib/new_relic/agent/instrumentation/httpclient/chain.rb +2 -3
- data/lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb +0 -1
- data/lib/new_relic/agent/instrumentation/httpclient/prepend.rb +0 -2
- data/lib/new_relic/agent/instrumentation/httprb/chain.rb +2 -2
- data/lib/new_relic/agent/instrumentation/httprb/instrumentation.rb +6 -6
- data/lib/new_relic/agent/instrumentation/httprb/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/ignore_actions.rb +2 -3
- data/lib/new_relic/agent/instrumentation/logger/chain.rb +21 -0
- data/lib/new_relic/agent/instrumentation/logger/instrumentation.rb +58 -0
- data/lib/new_relic/agent/instrumentation/logger/prepend.rb +13 -0
- data/lib/new_relic/agent/instrumentation/logger.rb +26 -0
- data/lib/new_relic/agent/instrumentation/memcache/dalli.rb +7 -2
- data/lib/new_relic/agent/instrumentation/memcache/helper.rb +5 -1
- data/lib/new_relic/agent/instrumentation/memcache/prepend.rb +9 -2
- data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +9 -10
- data/lib/new_relic/agent/instrumentation/middleware_tracing.rb +5 -6
- data/lib/new_relic/agent/instrumentation/mongo.rb +3 -141
- data/lib/new_relic/agent/instrumentation/mongodb_command_subscriber.rb +4 -4
- data/lib/new_relic/agent/instrumentation/net_http/chain.rb +3 -4
- data/lib/new_relic/agent/instrumentation/net_http/instrumentation.rb +5 -5
- data/lib/new_relic/agent/instrumentation/net_http/prepend.rb +4 -4
- data/lib/new_relic/agent/instrumentation/net_http.rb +7 -2
- data/lib/new_relic/agent/instrumentation/notifications_subscriber.rb +2 -3
- data/lib/new_relic/agent/instrumentation/padrino/chain.rb +23 -19
- data/lib/new_relic/agent/instrumentation/padrino/instrumentation.rb +3 -2
- data/lib/new_relic/agent/instrumentation/padrino/prepend.rb +2 -2
- data/lib/new_relic/agent/instrumentation/padrino.rb +2 -5
- data/lib/new_relic/agent/instrumentation/queue_time.rb +8 -8
- data/lib/new_relic/agent/instrumentation/rack/chain.rb +8 -7
- data/lib/new_relic/agent/instrumentation/rack/helpers.rb +2 -1
- data/lib/new_relic/agent/instrumentation/rack/instrumentation.rb +4 -5
- data/lib/new_relic/agent/instrumentation/rack/prepend.rb +2 -2
- data/lib/new_relic/agent/instrumentation/rack.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +11 -47
- data/lib/new_relic/agent/instrumentation/rails_notifications/action_cable.rb +2 -2
- data/lib/new_relic/agent/instrumentation/rails_notifications/action_controller.rb +0 -1
- data/lib/new_relic/agent/instrumentation/rainbows_instrumentation.rb +11 -0
- data/lib/new_relic/agent/instrumentation/rake/chain.rb +0 -5
- data/lib/new_relic/agent/instrumentation/rake/instrumentation.rb +6 -6
- data/lib/new_relic/agent/instrumentation/rake.rb +1 -1
- data/lib/new_relic/agent/instrumentation/redis/chain.rb +6 -6
- data/lib/new_relic/agent/instrumentation/redis/instrumentation.rb +2 -2
- data/lib/new_relic/agent/instrumentation/redis/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/redis.rb +5 -1
- data/lib/new_relic/agent/instrumentation/resque/chain.rb +2 -3
- data/lib/new_relic/agent/instrumentation/resque/helper.rb +19 -0
- data/lib/new_relic/agent/instrumentation/resque/instrumentation.rb +9 -7
- data/lib/new_relic/agent/instrumentation/resque/prepend.rb +1 -2
- data/lib/new_relic/agent/instrumentation/resque.rb +17 -8
- data/lib/new_relic/agent/instrumentation/sequel.rb +7 -9
- data/lib/new_relic/agent/instrumentation/sequel_helper.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sidekiq.rb +22 -1
- data/lib/new_relic/agent/instrumentation/sinatra/ignorer.rb +0 -1
- data/lib/new_relic/agent/instrumentation/sinatra/instrumentation.rb +12 -5
- data/lib/new_relic/agent/instrumentation/sinatra.rb +21 -11
- data/lib/new_relic/agent/instrumentation/sunspot.rb +11 -1
- data/lib/new_relic/agent/instrumentation/thread/chain.rb +24 -0
- data/lib/new_relic/agent/instrumentation/thread/instrumentation.rb +27 -0
- data/lib/new_relic/agent/instrumentation/thread/prepend.rb +22 -0
- data/lib/new_relic/agent/instrumentation/thread.rb +20 -0
- data/lib/new_relic/agent/instrumentation/tilt/chain.rb +24 -0
- data/lib/new_relic/agent/instrumentation/tilt/instrumentation.rb +40 -0
- data/lib/new_relic/agent/instrumentation/tilt/prepend.rb +13 -0
- data/lib/new_relic/agent/instrumentation/tilt.rb +25 -0
- data/lib/new_relic/agent/instrumentation/typhoeus/chain.rb +4 -4
- data/lib/new_relic/agent/instrumentation/typhoeus/instrumentation.rb +3 -5
- data/lib/new_relic/agent/instrumentation/typhoeus/prepend.rb +1 -1
- data/lib/new_relic/agent/internal_agent_error.rb +1 -1
- data/lib/new_relic/agent/javascript_instrumentor.rb +38 -33
- data/lib/new_relic/agent/linking_metadata.rb +45 -0
- data/lib/new_relic/agent/local_log_decorator.rb +37 -0
- data/lib/new_relic/agent/log_event_aggregator.rb +234 -0
- data/lib/new_relic/agent/log_priority.rb +20 -0
- data/lib/new_relic/agent/logging.rb +11 -8
- data/lib/new_relic/agent/memory_logger.rb +1 -1
- data/lib/new_relic/agent/messaging.rb +46 -62
- data/lib/new_relic/agent/method_tracer.rb +145 -144
- data/lib/new_relic/agent/method_tracer_helpers.rb +82 -2
- data/lib/new_relic/agent/monitors/cross_app_monitor.rb +21 -13
- data/lib/new_relic/agent/monitors/distributed_tracing_monitor.rb +2 -2
- data/lib/new_relic/agent/monitors/inbound_request_monitor.rb +0 -1
- data/lib/new_relic/agent/monitors/synthetics_monitor.rb +4 -7
- data/lib/new_relic/agent/monitors.rb +1 -2
- data/lib/new_relic/agent/new_relic_service/encoders.rb +4 -4
- data/lib/new_relic/agent/new_relic_service/json_marshaller.rb +1 -1
- data/lib/new_relic/agent/new_relic_service/marshaller.rb +1 -1
- data/lib/new_relic/agent/new_relic_service/security_policy_settings.rb +4 -3
- data/lib/new_relic/agent/new_relic_service.rb +61 -53
- data/lib/new_relic/agent/noticible_error.rb +0 -2
- data/lib/new_relic/agent/null_logger.rb +6 -2
- data/lib/new_relic/agent/obfuscator.rb +6 -8
- data/lib/new_relic/agent/parameter_filtering.rb +16 -8
- data/lib/new_relic/agent/payload_metric_mapping.rb +8 -9
- data/lib/new_relic/agent/pipe_channel_manager.rb +15 -12
- data/lib/new_relic/agent/pipe_service.rb +6 -3
- data/lib/new_relic/agent/priority_sampled_buffer.rb +4 -7
- data/lib/new_relic/agent/rules_engine/replacement_rule.rb +9 -9
- data/lib/new_relic/agent/rules_engine/segment_terms_rule.rb +12 -12
- data/lib/new_relic/agent/rules_engine.rb +2 -2
- data/lib/new_relic/agent/sampler.rb +2 -3
- data/lib/new_relic/agent/sampler_collection.rb +2 -3
- data/lib/new_relic/agent/samplers/cpu_sampler.rb +1 -1
- data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +10 -7
- data/lib/new_relic/agent/samplers/memory_sampler.rb +9 -3
- data/lib/new_relic/agent/samplers/vm_sampler.rb +18 -18
- data/lib/new_relic/agent/span_event_aggregator.rb +10 -10
- data/lib/new_relic/agent/span_event_primitive.rb +48 -45
- data/lib/new_relic/agent/sql_sampler.rb +9 -9
- data/lib/new_relic/agent/stats.rb +62 -37
- data/lib/new_relic/agent/stats_engine/gc_profiler.rb +7 -9
- data/lib/new_relic/agent/stats_engine/stats_hash.rb +8 -9
- data/lib/new_relic/agent/stats_engine.rb +7 -7
- data/lib/new_relic/agent/synthetics_event_aggregator.rb +1 -2
- data/lib/new_relic/agent/system_info.rb +22 -20
- data/lib/new_relic/agent/threading/agent_thread.rb +4 -5
- data/lib/new_relic/agent/threading/backtrace_node.rb +6 -9
- data/lib/new_relic/agent/threading/backtrace_service.rb +12 -13
- data/lib/new_relic/agent/threading/thread_profile.rb +16 -19
- data/lib/new_relic/agent/tracer.rb +57 -72
- data/lib/new_relic/agent/transaction/abstract_segment.rb +38 -10
- data/lib/new_relic/agent/transaction/datastore_segment.rb +7 -6
- data/lib/new_relic/agent/transaction/distributed_tracer.rb +8 -9
- data/lib/new_relic/agent/transaction/distributed_tracing.rb +21 -22
- data/lib/new_relic/agent/transaction/external_request_segment.rb +6 -5
- data/lib/new_relic/agent/transaction/message_broker_segment.rb +24 -30
- data/lib/new_relic/agent/transaction/request_attributes.rb +7 -7
- data/lib/new_relic/agent/transaction/segment.rb +6 -3
- data/lib/new_relic/agent/transaction/slowest_sample_buffer.rb +0 -2
- data/lib/new_relic/agent/transaction/trace.rb +8 -8
- data/lib/new_relic/agent/transaction/trace_context.rb +14 -16
- data/lib/new_relic/agent/transaction/trace_node.rb +16 -16
- data/lib/new_relic/agent/transaction/tracing.rb +9 -6
- data/lib/new_relic/agent/transaction/transaction_sample_buffer.rb +1 -2
- data/lib/new_relic/agent/transaction.rb +132 -119
- data/lib/new_relic/agent/transaction_error_primitive.rb +18 -16
- data/lib/new_relic/agent/transaction_event_aggregator.rb +7 -8
- data/lib/new_relic/agent/transaction_event_primitive.rb +29 -29
- data/lib/new_relic/agent/transaction_event_recorder.rb +1 -1
- data/lib/new_relic/agent/transaction_metrics.rb +8 -7
- data/lib/new_relic/agent/transaction_sampler.rb +0 -1
- data/lib/new_relic/agent/transaction_time_aggregator.rb +11 -11
- data/lib/new_relic/agent/utilization/aws.rb +32 -2
- data/lib/new_relic/agent/utilization/azure.rb +1 -1
- data/lib/new_relic/agent/utilization/vendor.rb +15 -2
- data/lib/new_relic/agent/utilization_data.rb +3 -4
- data/lib/new_relic/agent/vm/monotonic_gc_profiler.rb +1 -1
- data/lib/new_relic/agent/vm/mri_vm.rb +13 -1
- data/lib/new_relic/agent/vm/snapshot.rb +4 -4
- data/lib/new_relic/agent/worker_loop.rb +8 -10
- data/lib/new_relic/agent.rb +36 -41
- data/lib/new_relic/cli/command.rb +15 -17
- data/lib/new_relic/cli/commands/deployments.rb +21 -23
- data/lib/new_relic/cli/commands/install.rb +6 -10
- data/lib/new_relic/coerce.rb +5 -8
- data/lib/new_relic/collection_helper.rb +48 -47
- data/lib/new_relic/constants.rb +0 -4
- data/lib/new_relic/control/class_methods.rb +2 -2
- data/lib/new_relic/control/frameworks/external.rb +1 -1
- data/lib/new_relic/control/frameworks/rails.rb +5 -6
- data/lib/new_relic/control/frameworks/rails3.rb +2 -3
- data/lib/new_relic/control/frameworks/ruby.rb +2 -2
- data/lib/new_relic/control/frameworks/sinatra.rb +6 -0
- data/lib/new_relic/control/instance_methods.rb +4 -5
- data/lib/new_relic/control/instrumentation.rb +35 -5
- data/lib/new_relic/control/server_methods.rb +2 -3
- data/lib/new_relic/control.rb +0 -1
- data/lib/new_relic/dependency_detection.rb +7 -9
- data/lib/new_relic/environment_report.rb +16 -18
- data/lib/new_relic/helper.rb +45 -5
- data/lib/new_relic/language_support.rb +20 -2
- data/lib/new_relic/latest_changes.rb +2 -2
- data/lib/new_relic/local_environment.rb +9 -7
- data/lib/new_relic/metric_data.rb +6 -7
- data/lib/new_relic/metric_spec.rb +3 -3
- data/lib/new_relic/noticed_error.rb +18 -19
- data/lib/new_relic/rack/agent_middleware.rb +2 -2
- data/lib/new_relic/rack/browser_monitoring.rb +9 -9
- data/lib/new_relic/recipes/capistrano3.rb +11 -13
- data/lib/new_relic/recipes/capistrano_legacy.rb +11 -14
- data/lib/new_relic/supportability_helper.rb +2 -2
- data/lib/new_relic/traced_thread.rb +35 -0
- data/lib/new_relic/version.rb +5 -16
- data/lib/newrelic_rpm.rb +10 -34
- data/lib/sequel/extensions/newrelic_instrumentation.rb +4 -7
- data/lib/sequel/plugins/newrelic_instrumentation.rb +3 -9
- data/lib/tasks/all.rb +2 -2
- data/lib/tasks/config.html.erb +14 -25
- data/lib/tasks/config.rake +36 -27
- data/lib/tasks/multiverse.rb +4 -6
- data/lib/tasks/tests.rake +3 -7
- data/newrelic.yml +610 -3
- data/newrelic_rpm.gemspec +14 -14
- data/recipes/newrelic.rb +1 -1
- data/test/agent_helper.rb +98 -59
- metadata +69 -20
- data/ROADMAP.md +0 -24
- data/lib/new_relic/agent/datastores/mongo/statement_formatter.rb +0 -53
- data/lib/new_relic/agent/instrumentation/excon/connection.rb +0 -49
- data/lib/new_relic/agent/instrumentation/merb/controller.rb +0 -44
- data/lib/new_relic/agent/instrumentation/merb/errors.rb +0 -33
- data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +0 -125
- data/lib/new_relic/agent/instrumentation/rails/action_web_service.rb +0 -46
- data/lib/new_relic/agent/supported_versions.rb +0 -275
- data/lib/new_relic/control/frameworks/merb.rb +0 -29
@@ -13,8 +13,9 @@ module NewRelic
|
|
13
13
|
DEFAULT_PROC = Proc.new { |hash, name| hash[name] = NewRelic::Agent::Stats.new }
|
14
14
|
|
15
15
|
def initialize
|
16
|
+
@lock = Mutex.new
|
16
17
|
@unscoped = Hash.new(&DEFAULT_PROC)
|
17
|
-
@scoped
|
18
|
+
@scoped = Hash.new(&DEFAULT_PROC)
|
18
19
|
end
|
19
20
|
|
20
21
|
# As a general rule, when recording a scoped metric, the corresponding
|
@@ -25,11 +26,11 @@ module NewRelic
|
|
25
26
|
# propagate them into unscoped metrics as well when instances of this
|
26
27
|
# class are merged into the global metric store.
|
27
28
|
#
|
28
|
-
def record_scoped_and_unscoped(names, value=nil, aux=nil, &blk)
|
29
|
+
def record_scoped_and_unscoped(names, value = nil, aux = nil, &blk)
|
29
30
|
_record_metrics(names, value, aux, @scoped, &blk)
|
30
31
|
end
|
31
32
|
|
32
|
-
def record_unscoped(names, value=nil, aux=nil, &blk)
|
33
|
+
def record_unscoped(names, value = nil, aux = nil, &blk)
|
33
34
|
_record_metrics(names, value, aux, @unscoped, &blk)
|
34
35
|
end
|
35
36
|
|
@@ -42,11 +43,11 @@ module NewRelic
|
|
42
43
|
end
|
43
44
|
|
44
45
|
def each_unscoped
|
45
|
-
@unscoped.each { |name, stats| yield name, stats }
|
46
|
+
@lock.synchronize { @unscoped.each { |name, stats| yield name, stats } }
|
46
47
|
end
|
47
48
|
|
48
49
|
def each_scoped
|
49
|
-
@scoped.each { |name, stats| yield name, stats }
|
50
|
+
@lock.synchronize { @scoped.each { |name, stats| yield name, stats } }
|
50
51
|
end
|
51
52
|
|
52
53
|
def _record_metrics(names, value, aux, target, &blk)
|
@@ -54,10 +55,10 @@ module NewRelic
|
|
54
55
|
case names
|
55
56
|
when Array
|
56
57
|
names.each do |name|
|
57
|
-
target[name].record(value, aux, &blk)
|
58
|
+
@lock.synchronize { target[name].record(value, aux, &blk) }
|
58
59
|
end
|
59
60
|
else
|
60
|
-
target[names].record(value, aux, &blk)
|
61
|
+
@lock.synchronize { target[names].record(value, aux, &blk) }
|
61
62
|
end
|
62
63
|
end
|
63
64
|
end
|
@@ -14,25 +14,25 @@ module NewRelic
|
|
14
14
|
module TransactionTimeAggregator
|
15
15
|
TransactionStats = Struct.new :transaction_started_at, :elapsed_transaction_time
|
16
16
|
|
17
|
-
@lock
|
18
|
-
@harvest_cycle_started_at =
|
17
|
+
@lock = Mutex.new
|
18
|
+
@harvest_cycle_started_at = Process.clock_gettime(Process::CLOCK_REALTIME)
|
19
19
|
|
20
20
|
@stats = Hash.new do |h, k|
|
21
21
|
h[k] = TransactionStats.new nil, 0.0
|
22
22
|
end
|
23
23
|
|
24
|
-
def reset!(timestamp =
|
24
|
+
def reset!(timestamp = Process.clock_gettime(Process::CLOCK_REALTIME))
|
25
25
|
@harvest_cycle_started_at = timestamp
|
26
26
|
@stats.clear
|
27
27
|
end
|
28
28
|
|
29
|
-
def transaction_start(timestamp =
|
29
|
+
def transaction_start(timestamp = Process.clock_gettime(Process::CLOCK_REALTIME))
|
30
30
|
@lock.synchronize do
|
31
31
|
set_transaction_start_time timestamp
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
def transaction_stop(timestamp =
|
35
|
+
def transaction_stop(timestamp = Process.clock_gettime(Process::CLOCK_REALTIME), starting_thread_id = current_thread)
|
36
36
|
@lock.synchronize do
|
37
37
|
record_elapsed_transaction_time_until timestamp, starting_thread_id
|
38
38
|
set_transaction_start_time nil, starting_thread_id
|
@@ -41,7 +41,7 @@ module NewRelic
|
|
41
41
|
|
42
42
|
INSTANCE_BUSY_METRIC = 'Instance/Busy'.freeze
|
43
43
|
|
44
|
-
def harvest!(timestamp =
|
44
|
+
def harvest!(timestamp = Process.clock_gettime(Process::CLOCK_REALTIME))
|
45
45
|
active_threads = 0
|
46
46
|
result = @lock.synchronize do
|
47
47
|
# Sum up the transaction times spent in each thread
|
@@ -50,7 +50,7 @@ module NewRelic
|
|
50
50
|
end
|
51
51
|
|
52
52
|
active_threads = @stats.size
|
53
|
-
elapsed_harvest_time
|
53
|
+
elapsed_harvest_time = (timestamp - @harvest_cycle_started_at) * active_threads
|
54
54
|
@harvest_cycle_started_at = timestamp
|
55
55
|
|
56
56
|
# Clear out the stats for all threads, _except_ the live ones
|
@@ -75,9 +75,9 @@ module NewRelic
|
|
75
75
|
end
|
76
76
|
|
77
77
|
module_function :reset!,
|
78
|
-
|
79
|
-
|
80
|
-
|
78
|
+
:transaction_start,
|
79
|
+
:transaction_stop,
|
80
|
+
:harvest!
|
81
81
|
|
82
82
|
class << self
|
83
83
|
private
|
@@ -146,7 +146,7 @@ module NewRelic
|
|
146
146
|
def log_missing_elapsed_transaction_time
|
147
147
|
transaction_name = Tracer.current_transaction &&
|
148
148
|
Tracer.current_transaction.best_name ||
|
149
|
-
|
149
|
+
"unknown"
|
150
150
|
NewRelic::Agent.logger.warn("Unable to calculate elapsed transaction time for #{transaction_name}")
|
151
151
|
end
|
152
152
|
end
|
@@ -8,9 +8,39 @@ module NewRelic
|
|
8
8
|
module Agent
|
9
9
|
module Utilization
|
10
10
|
class AWS < Vendor
|
11
|
+
IMDS_BASE_URL = 'http://169.254.169.254/latest'.freeze
|
12
|
+
IMDS_KEYS = %w[instanceId instanceType availabilityZone].freeze
|
13
|
+
IMDS_TOKEN_TTL_SECS = '60'.freeze
|
14
|
+
TOKEN_OPEN_TIMEOUT_SECS = 1.freeze
|
15
|
+
TOKEN_READ_TIMEOUT_SECS = 1.freeze
|
16
|
+
|
17
|
+
class << self
|
18
|
+
def imds_token
|
19
|
+
uri = URI.parse("#{IMDS_BASE_URL}/api/token")
|
20
|
+
http = Net::HTTP.new(uri.hostname)
|
21
|
+
http.open_timeout = TOKEN_OPEN_TIMEOUT_SECS
|
22
|
+
http.read_timeout = TOKEN_READ_TIMEOUT_SECS
|
23
|
+
response = http.send_request('PUT',
|
24
|
+
uri.path,
|
25
|
+
'',
|
26
|
+
{'X-aws-ec2-metadata-token-ttl-seconds' => IMDS_TOKEN_TTL_SECS})
|
27
|
+
unless response.code == Vendor::SUCCESS
|
28
|
+
NewRelic::Agent.logger.debug 'Failed to obtain an AWS token for use with IMDS - encountered ' \
|
29
|
+
"#{response.class} with HTTP response code #{response.code} - " \
|
30
|
+
'assuming non AWS'
|
31
|
+
return
|
32
|
+
end
|
33
|
+
|
34
|
+
response.body
|
35
|
+
rescue Net::OpenTimeout
|
36
|
+
NewRelic::Agent.logger.debug 'Timed out waiting for AWS IMDS - assuming non AWS'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
11
40
|
vendor_name "aws"
|
12
|
-
endpoint "
|
13
|
-
keys
|
41
|
+
endpoint "#{IMDS_BASE_URL}/dynamic/instance-identity/document"
|
42
|
+
keys IMDS_KEYS
|
43
|
+
headers 'X-aws-ec2-metadata-token' => -> { imds_token }
|
14
44
|
key_transforms :to_sym
|
15
45
|
end
|
16
46
|
end
|
@@ -18,7 +18,7 @@ module NewRelic
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def headers headers = nil
|
21
|
-
headers ? @headers = headers.freeze :
|
21
|
+
headers ? @headers = headers.freeze : processed_headers
|
22
22
|
end
|
23
23
|
|
24
24
|
def keys keys = nil
|
@@ -28,6 +28,16 @@ module NewRelic
|
|
28
28
|
def key_transforms key_transforms = nil
|
29
29
|
key_transforms ? @key_transforms = Array(key_transforms).freeze : @key_transforms
|
30
30
|
end
|
31
|
+
|
32
|
+
def processed_headers
|
33
|
+
return unless @headers
|
34
|
+
|
35
|
+
@headers.each_with_object({}) do |(key, value), processed_hash|
|
36
|
+
# Header lambdas are expected to return string values. If nil comes back, replace it with :error
|
37
|
+
# to signify that the call failed.
|
38
|
+
processed_hash[key] = value.class.eql?(Proc) ? value.call || :error : value
|
39
|
+
end
|
40
|
+
end
|
31
41
|
end
|
32
42
|
|
33
43
|
attr_reader :metadata
|
@@ -62,10 +72,13 @@ module NewRelic
|
|
62
72
|
private
|
63
73
|
|
64
74
|
def request_metadata
|
75
|
+
processed_headers = headers
|
76
|
+
raise if processed_headers.values.include?(:error)
|
77
|
+
|
65
78
|
Timeout.timeout 1 do
|
66
79
|
response = nil
|
67
80
|
Net::HTTP.start endpoint.host, endpoint.port do |http|
|
68
|
-
req = Net::HTTP::Get.new endpoint,
|
81
|
+
req = Net::HTTP::Get.new endpoint, processed_headers
|
69
82
|
response = http.request req
|
70
83
|
end
|
71
84
|
response
|
@@ -7,17 +7,16 @@ require 'new_relic/agent/utilization/gcp'
|
|
7
7
|
require 'new_relic/agent/utilization/azure'
|
8
8
|
require 'new_relic/agent/utilization/pcf'
|
9
9
|
|
10
|
-
|
11
10
|
module NewRelic
|
12
11
|
module Agent
|
13
12
|
class UtilizationData
|
14
13
|
METADATA_VERSION = 5
|
15
14
|
|
16
15
|
VENDORS = {
|
17
|
-
Utilization::AWS
|
18
|
-
Utilization::GCP
|
16
|
+
Utilization::AWS => :'utilization.detect_aws',
|
17
|
+
Utilization::GCP => :'utilization.detect_gcp',
|
19
18
|
Utilization::Azure => :'utilization.detect_azure',
|
20
|
-
Utilization::PCF
|
19
|
+
Utilization::PCF => :'utilization.detect_pcf'
|
21
20
|
}
|
22
21
|
|
23
22
|
def hostname
|
@@ -49,7 +49,19 @@ module NewRelic
|
|
49
49
|
end
|
50
50
|
|
51
51
|
if supports?(:constant_cache_invalidations)
|
52
|
-
snap.constant_cache_invalidations =
|
52
|
+
snap.constant_cache_invalidations = gather_constant_cache_invalidations
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def gather_constant_cache_invalidations
|
57
|
+
# Ruby >= 3.2 uses :constant_cache
|
58
|
+
# see: https://github.com/ruby/ruby/pull/5433 and https://bugs.ruby-lang.org/issues/18589
|
59
|
+
# TODO: now that 3.2+ provides more granual cache invalidation data, should we report it instead of summing?
|
60
|
+
if RUBY_VERSION >= '3.2.0'
|
61
|
+
RubyVM.stat[:constant_cache].values.sum
|
62
|
+
# Ruby < 3.2 uses :global_constant_state
|
63
|
+
else
|
64
|
+
RubyVM.stat[:global_constant_state]
|
53
65
|
end
|
54
66
|
end
|
55
67
|
|
@@ -7,12 +7,12 @@ module NewRelic
|
|
7
7
|
module VM
|
8
8
|
class Snapshot
|
9
9
|
attr_accessor :gc_total_time, :gc_runs, :major_gc_count, :minor_gc_count,
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
:total_allocated_object, :heap_live, :heap_free,
|
11
|
+
:method_cache_invalidations, :constant_cache_invalidations,
|
12
|
+
:thread_count, :taken_at
|
13
13
|
|
14
14
|
def initialize
|
15
|
-
@taken_at =
|
15
|
+
@taken_at = Process.clock_gettime(Process::CLOCK_REALTIME)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -6,19 +6,17 @@ require 'thread'
|
|
6
6
|
|
7
7
|
module NewRelic
|
8
8
|
module Agent
|
9
|
-
|
10
9
|
# A worker loop executes a set of registered tasks on a single thread.
|
11
10
|
# A task is a proc or block with a specified call period in seconds.
|
12
11
|
class WorkerLoop
|
13
|
-
|
14
12
|
attr_accessor :period, :propagate_errors
|
15
13
|
attr_reader :iterations
|
16
14
|
|
17
15
|
# Optional argument :duration (in seconds) for how long the worker loop runs
|
18
16
|
# or :limit (integer) for max number of iterations
|
19
|
-
def initialize(opts={})
|
17
|
+
def initialize(opts = {})
|
20
18
|
@should_run = true
|
21
|
-
@next_invocation_time =
|
19
|
+
@next_invocation_time = Process.clock_gettime(Process::CLOCK_REALTIME)
|
22
20
|
@period = 60.0
|
23
21
|
@duration = opts[:duration]
|
24
22
|
@limit = opts[:limit]
|
@@ -34,7 +32,7 @@ module NewRelic
|
|
34
32
|
@should_run = true
|
35
33
|
@iterations = 0
|
36
34
|
|
37
|
-
now =
|
35
|
+
now = Process.clock_gettime(Process::CLOCK_REALTIME)
|
38
36
|
@deadline = now + @duration if @duration
|
39
37
|
@next_invocation_time = (now + @period)
|
40
38
|
end
|
@@ -42,9 +40,9 @@ module NewRelic
|
|
42
40
|
# Run infinitely, calling the registered tasks at their specified
|
43
41
|
# call periods. The caller is responsible for creating the thread
|
44
42
|
# that runs this worker loop. This will run the task immediately.
|
45
|
-
def run(period=nil, &block)
|
43
|
+
def run(period = nil, &block)
|
46
44
|
setup(period, block)
|
47
|
-
while keep_running?
|
45
|
+
while keep_running?
|
48
46
|
sleep_time = schedule_next_invocation
|
49
47
|
sleep(sleep_time) if sleep_time > 0
|
50
48
|
run_task if keep_running?
|
@@ -53,11 +51,11 @@ module NewRelic
|
|
53
51
|
end
|
54
52
|
|
55
53
|
def schedule_next_invocation
|
56
|
-
now =
|
54
|
+
now = Process.clock_gettime(Process::CLOCK_REALTIME)
|
57
55
|
while @next_invocation_time <= now && @period > 0
|
58
56
|
@next_invocation_time += @period
|
59
57
|
end
|
60
|
-
@next_invocation_time -
|
58
|
+
@next_invocation_time - Process.clock_gettime(Process::CLOCK_REALTIME)
|
61
59
|
end
|
62
60
|
|
63
61
|
# a simple accessor for @should_run
|
@@ -66,7 +64,7 @@ module NewRelic
|
|
66
64
|
end
|
67
65
|
|
68
66
|
def under_duration?
|
69
|
-
!@deadline ||
|
67
|
+
!@deadline || Process.clock_gettime(Process::CLOCK_REALTIME) < @deadline
|
70
68
|
end
|
71
69
|
|
72
70
|
def under_limit?
|
data/lib/new_relic/agent.rb
CHANGED
@@ -44,6 +44,7 @@ module NewRelic
|
|
44
44
|
require 'new_relic/agent/sql_sampler'
|
45
45
|
require 'new_relic/agent/commands/thread_profiler_session'
|
46
46
|
require 'new_relic/agent/error_collector'
|
47
|
+
require 'new_relic/agent/error_filter'
|
47
48
|
require 'new_relic/agent/sampler'
|
48
49
|
require 'new_relic/agent/database'
|
49
50
|
require 'new_relic/agent/database_adapter'
|
@@ -58,6 +59,8 @@ module NewRelic
|
|
58
59
|
require 'new_relic/agent/logging'
|
59
60
|
require 'new_relic/agent/distributed_tracing'
|
60
61
|
require 'new_relic/agent/attribute_processing'
|
62
|
+
require 'new_relic/agent/linking_metadata'
|
63
|
+
require 'new_relic/agent/local_log_decorator'
|
61
64
|
|
62
65
|
require 'new_relic/agent/instrumentation/controller_instrumentation'
|
63
66
|
|
@@ -110,19 +113,19 @@ module NewRelic
|
|
110
113
|
@tracer_queue = []
|
111
114
|
|
112
115
|
# The singleton Agent instance. Used internally.
|
113
|
-
def agent
|
116
|
+
def agent # :nodoc:
|
114
117
|
return @agent if @agent
|
115
118
|
NewRelic::Agent.logger.warn("Agent unavailable as it hasn't been started.")
|
116
119
|
NewRelic::Agent.logger.warn(caller.join("\n"))
|
117
120
|
nil
|
118
121
|
end
|
119
122
|
|
120
|
-
def agent=(new_instance)
|
123
|
+
def agent=(new_instance) # :nodoc:
|
121
124
|
@agent = new_instance
|
122
125
|
add_deferred_method_tracers_now
|
123
126
|
end
|
124
127
|
|
125
|
-
alias instance agent
|
128
|
+
alias instance agent # :nodoc:
|
126
129
|
|
127
130
|
# Primary interface to logging is fronted by this accessor
|
128
131
|
# Access via ::NewRelic::Agent.logger
|
@@ -138,20 +141,22 @@ module NewRelic
|
|
138
141
|
# is initialized; these methods enable us to defer these calls
|
139
142
|
# until we have started up and can process them.
|
140
143
|
#
|
141
|
-
def add_or_defer_method_tracer(receiver, method_name,
|
144
|
+
def add_or_defer_method_tracer(receiver, method_name, metric_name, options)
|
142
145
|
@tracer_lock.synchronize do
|
146
|
+
options[:code_information] = NewRelic::Agent::MethodTracerHelpers.code_information(receiver, method_name)
|
147
|
+
|
143
148
|
if @agent
|
144
|
-
receiver.send(:
|
149
|
+
receiver.send(:_nr_add_method_tracer_now, method_name, metric_name, options)
|
145
150
|
else
|
146
|
-
@tracer_queue << [receiver, method_name,
|
151
|
+
@tracer_queue << [receiver, method_name, metric_name, options]
|
147
152
|
end
|
148
153
|
end
|
149
154
|
end
|
150
155
|
|
151
156
|
def add_deferred_method_tracers_now
|
152
157
|
@tracer_lock.synchronize do
|
153
|
-
@tracer_queue.each do |receiver, method_name,
|
154
|
-
receiver.send(:
|
158
|
+
@tracer_queue.each do |receiver, method_name, metric_name, options|
|
159
|
+
receiver.send(:_nr_add_method_tracer_now, method_name, metric_name, options)
|
155
160
|
end
|
156
161
|
|
157
162
|
@tracer_queue = []
|
@@ -186,7 +191,7 @@ module NewRelic
|
|
186
191
|
# This method is safe to use from any thread.
|
187
192
|
#
|
188
193
|
# @api public
|
189
|
-
def record_metric(metric_name, value) #THREAD_LOCAL_ACCESS
|
194
|
+
def record_metric(metric_name, value) # THREAD_LOCAL_ACCESS
|
190
195
|
record_api_supportability_metric(:record_metric)
|
191
196
|
|
192
197
|
return unless agent
|
@@ -216,14 +221,14 @@ module NewRelic
|
|
216
221
|
|
217
222
|
SUPPORTABILITY_INCREMENT_METRIC = 'Supportability/API/increment_metric'.freeze
|
218
223
|
|
219
|
-
def increment_metric(metric_name, amount=1) #THREAD_LOCAL_ACCESS
|
224
|
+
def increment_metric(metric_name, amount = 1) # THREAD_LOCAL_ACCESS
|
220
225
|
return unless agent
|
221
226
|
if amount == 1
|
222
227
|
metrics = [metric_name, SUPPORTABILITY_INCREMENT_METRIC]
|
223
|
-
agent.stats_engine.tl_record_unscoped_metrics(metrics) {|stats| stats.increment_count}
|
228
|
+
agent.stats_engine.tl_record_unscoped_metrics(metrics) { |stats| stats.increment_count }
|
224
229
|
else
|
225
|
-
agent.stats_engine.tl_record_unscoped_metrics(metric_name) {|stats| stats.increment_count(amount)}
|
226
|
-
agent.stats_engine.tl_record_unscoped_metrics(SUPPORTABILITY_INCREMENT_METRIC) {|stats| stats.increment_count}
|
230
|
+
agent.stats_engine.tl_record_unscoped_metrics(metric_name) { |stats| stats.increment_count(amount) }
|
231
|
+
agent.stats_engine.tl_record_unscoped_metrics(SUPPORTABILITY_INCREMENT_METRIC) { |stats| stats.increment_count }
|
227
232
|
end
|
228
233
|
end
|
229
234
|
|
@@ -280,7 +285,7 @@ module NewRelic
|
|
280
285
|
#
|
281
286
|
# @api public
|
282
287
|
#
|
283
|
-
def notice_error(exception, options={})
|
288
|
+
def notice_error(exception, options = {})
|
284
289
|
record_api_supportability_metric(:notice_error)
|
285
290
|
|
286
291
|
Transaction.notice_error(exception, options)
|
@@ -346,9 +351,9 @@ module NewRelic
|
|
346
351
|
#
|
347
352
|
# @api public
|
348
353
|
#
|
349
|
-
def manual_start(options={})
|
354
|
+
def manual_start(options = {})
|
350
355
|
raise "Options must be a hash" unless Hash === options
|
351
|
-
NewRelic::Control.instance.init_plugin({
|
356
|
+
NewRelic::Control.instance.init_plugin({:agent_enabled => true, :sync_startup => true}.merge(options))
|
352
357
|
record_api_supportability_metric(:manual_start)
|
353
358
|
end
|
354
359
|
|
@@ -377,7 +382,7 @@ module NewRelic
|
|
377
382
|
#
|
378
383
|
# @api public
|
379
384
|
#
|
380
|
-
def after_fork(options={})
|
385
|
+
def after_fork(options = {})
|
381
386
|
record_api_supportability_metric(:after_fork)
|
382
387
|
agent.after_fork(options) if agent
|
383
388
|
end
|
@@ -389,7 +394,7 @@ module NewRelic
|
|
389
394
|
#
|
390
395
|
# @api public
|
391
396
|
#
|
392
|
-
def shutdown(options={})
|
397
|
+
def shutdown(options = {})
|
393
398
|
record_api_supportability_metric(:shutdown)
|
394
399
|
agent.shutdown if agent
|
395
400
|
end
|
@@ -511,7 +516,7 @@ module NewRelic
|
|
511
516
|
#
|
512
517
|
def disable_transaction_tracing
|
513
518
|
Deprecator.deprecate :disable_transaction_tracing,
|
514
|
-
|
519
|
+
'disable_all_tracing or ignore_transaction'
|
515
520
|
record_api_supportability_metric(:disable_transaction_tracing)
|
516
521
|
yield
|
517
522
|
end
|
@@ -571,7 +576,7 @@ module NewRelic
|
|
571
576
|
#
|
572
577
|
# @api public
|
573
578
|
#
|
574
|
-
def add_custom_attributes(params) #THREAD_LOCAL_ACCESS
|
579
|
+
def add_custom_attributes(params) # THREAD_LOCAL_ACCESS
|
575
580
|
record_api_supportability_metric(:add_custom_attributes)
|
576
581
|
|
577
582
|
if params.is_a? Hash
|
@@ -643,7 +648,7 @@ module NewRelic
|
|
643
648
|
#
|
644
649
|
# @api public
|
645
650
|
#
|
646
|
-
def set_transaction_name(name, options={})
|
651
|
+
def set_transaction_name(name, options = {})
|
647
652
|
record_api_supportability_metric(:set_transaction_name)
|
648
653
|
Transaction.set_overriding_transaction_name(name, options[:category])
|
649
654
|
end
|
@@ -653,7 +658,7 @@ module NewRelic
|
|
653
658
|
#
|
654
659
|
# @api public
|
655
660
|
#
|
656
|
-
def get_transaction_name #THREAD_LOCAL_ACCESS
|
661
|
+
def get_transaction_name # THREAD_LOCAL_ACCESS
|
657
662
|
record_api_supportability_metric(:get_transaction_name)
|
658
663
|
|
659
664
|
txn = Transaction.tl_current
|
@@ -685,13 +690,13 @@ module NewRelic
|
|
685
690
|
# Subscribe to events of +event_type+, calling the given +handler+
|
686
691
|
# when one is sent.
|
687
692
|
def subscribe(event_type, &handler)
|
688
|
-
agent.events.subscribe(
|
693
|
+
agent.events.subscribe(event_type, &handler)
|
689
694
|
end
|
690
695
|
|
691
696
|
# Fire an event of the specified +event_type+, passing it an the given +args+
|
692
697
|
# to any registered handlers.
|
693
698
|
def notify(event_type, *args)
|
694
|
-
agent.events.notify(
|
699
|
+
agent.events.notify(event_type, *args)
|
695
700
|
rescue
|
696
701
|
NewRelic::Agent.logger.debug "Ignoring exception during %p event notification" % [event_type]
|
697
702
|
end
|
@@ -725,24 +730,12 @@ module NewRelic
|
|
725
730
|
# @api public
|
726
731
|
def linking_metadata
|
727
732
|
metadata = Hash.new
|
728
|
-
metadata
|
729
|
-
metadata
|
730
|
-
metadata[HOSTNAME_KEY] = Hostname.get
|
731
|
-
|
732
|
-
if entity_guid = config[:entity_guid]
|
733
|
-
metadata[ENTITY_GUID_KEY] = entity_guid
|
734
|
-
end
|
735
|
-
|
736
|
-
if trace_id = Tracer.current_trace_id
|
737
|
-
metadata[TRACE_ID_KEY] = trace_id
|
738
|
-
end
|
739
|
-
if span_id = Tracer.current_span_id
|
740
|
-
metadata[SPAN_ID_KEY] = span_id
|
741
|
-
end
|
733
|
+
LinkingMetadata.append_service_linking_metadata(metadata)
|
734
|
+
LinkingMetadata.append_trace_linking_metadata(metadata)
|
742
735
|
metadata
|
743
736
|
end
|
744
737
|
|
745
|
-
|
738
|
+
# @!endgroup
|
746
739
|
|
747
740
|
# @!group Manual browser monitoring configuration
|
748
741
|
|
@@ -758,13 +751,15 @@ module NewRelic
|
|
758
751
|
# In previous agents there was a corresponding footer required, but all the
|
759
752
|
# work is now done by this single method.
|
760
753
|
#
|
754
|
+
# @param [String] nonce The nonce to use in the javascript tag for browser instrumentation
|
755
|
+
#
|
761
756
|
# @api public
|
762
757
|
#
|
763
|
-
def browser_timing_header
|
758
|
+
def browser_timing_header(nonce = nil)
|
764
759
|
record_api_supportability_metric(:browser_timing_header)
|
765
760
|
|
766
761
|
return "" unless agent
|
767
|
-
agent.javascript_instrumentor.browser_timing_header
|
762
|
+
agent.javascript_instrumentor.browser_timing_header(nonce)
|
768
763
|
end
|
769
764
|
|
770
765
|
# @!endgroup
|
@@ -15,7 +15,7 @@ module NewRelic
|
|
15
15
|
# Capture a failure to execute the command.
|
16
16
|
class CommandFailure < StandardError
|
17
17
|
attr_reader :options
|
18
|
-
def initialize message, opt_parser=nil
|
18
|
+
def initialize message, opt_parser = nil
|
19
19
|
super message
|
20
20
|
@options = opt_parser
|
21
21
|
end
|
@@ -32,13 +32,13 @@ module NewRelic
|
|
32
32
|
def initialize(command_line_args)
|
33
33
|
if Hash === command_line_args
|
34
34
|
# command line args is an options hash
|
35
|
-
command_line_args.each do |
|
35
|
+
command_line_args.each do |key, value|
|
36
36
|
instance_variable_set "@#{key}", value.to_s if value
|
37
37
|
end
|
38
38
|
else
|
39
39
|
# parse command line args. Throw an exception on a bad arg.
|
40
|
-
@options = options do |
|
41
|
-
opts.on("-h", "Show this help") {
|
40
|
+
@options = options do |opts|
|
41
|
+
opts.on("-h", "Show this help") { raise CommandFailure, opts.to_s }
|
42
42
|
end
|
43
43
|
@leftover = @options.parse(command_line_args)
|
44
44
|
end
|
@@ -55,8 +55,7 @@ module NewRelic
|
|
55
55
|
Dir[cmds].each { |command| require command }
|
56
56
|
|
57
57
|
def self.run
|
58
|
-
|
59
|
-
@command_names = @commands.map{ |c| c.command }
|
58
|
+
@command_names = @commands.map { |c| c.command }
|
60
59
|
|
61
60
|
extra = []
|
62
61
|
options = ARGV.options do |opts|
|
@@ -65,7 +64,7 @@ module NewRelic
|
|
65
64
|
$stdout.puts "warning: the 'newrelic_cmd' script has been renamed 'newrelic'"
|
66
65
|
script_name = 'newrelic'
|
67
66
|
end
|
68
|
-
opts.banner = "Usage: #{script_name} [ #{
|
67
|
+
opts.banner = "Usage: #{script_name} [ #{@command_names.join(" | ")} ] [options]"
|
69
68
|
opts.separator "use '#{script_name} <command> -h' to see detailed command options"
|
70
69
|
opts
|
71
70
|
end
|
@@ -73,19 +72,18 @@ module NewRelic
|
|
73
72
|
command = extra.shift
|
74
73
|
# just make it a little easier on them
|
75
74
|
command = 'deployments' if command =~ /deploy/
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
75
|
+
if command.nil?
|
76
|
+
STDERR.puts options
|
77
|
+
elsif !@command_names.include?(command)
|
78
|
+
STDERR.puts "Unrecognized command: #{command}"
|
79
|
+
STDERR.puts options
|
80
|
+
else
|
81
|
+
command_class = @commands.find { |c| c.command == command }
|
82
|
+
command_class.new(extra).run
|
83
|
+
end
|
85
84
|
rescue OptionParser::InvalidOption => e
|
86
85
|
raise NewRelic::Cli::Command::CommandFailure, e.message
|
87
86
|
end
|
88
87
|
end
|
89
|
-
|
90
88
|
end
|
91
89
|
end
|