newrelic_rpm 8.2.0 → 8.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1936 -0
- data/CHANGELOG.md +17 -2
- data/CONTRIBUTING.md +14 -2
- data/Guardfile +8 -8
- data/Rakefile +5 -7
- data/bin/mongrel_rpm +8 -9
- data/bin/newrelic +1 -1
- data/bin/nrdebug +14 -14
- data/init.rb +0 -2
- data/lefthook.yml +9 -0
- data/lib/new_relic/agent/adaptive_sampler.rb +7 -3
- data/lib/new_relic/agent/agent.rb +38 -40
- data/lib/new_relic/agent/agent_logger.rb +8 -9
- data/lib/new_relic/agent/attribute_filter.rb +31 -31
- data/lib/new_relic/agent/attributes.rb +2 -2
- data/lib/new_relic/agent/autostart.rb +6 -7
- data/lib/new_relic/agent/commands/agent_command.rb +2 -2
- data/lib/new_relic/agent/commands/agent_command_router.rb +6 -5
- data/lib/new_relic/agent/commands/thread_profiler_session.rb +0 -3
- data/lib/new_relic/agent/configuration/default_source.rb +318 -324
- data/lib/new_relic/agent/configuration/dotted_hash.rb +3 -3
- data/lib/new_relic/agent/configuration/environment_source.rb +3 -4
- data/lib/new_relic/agent/configuration/event_harvest_config.rb +2 -4
- data/lib/new_relic/agent/configuration/high_security_source.rb +7 -7
- data/lib/new_relic/agent/configuration/manager.rb +57 -57
- 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 +10 -10
- data/lib/new_relic/agent/configuration/yaml_source.rb +9 -9
- data/lib/new_relic/agent/connect/request_builder.rb +13 -16
- data/lib/new_relic/agent/connect/response_handler.rb +0 -3
- data/lib/new_relic/agent/custom_event_aggregator.rb +9 -10
- data/lib/new_relic/agent/database/explain_plan_helpers.rb +3 -4
- data/lib/new_relic/agent/database/obfuscation_helpers.rb +12 -12
- data/lib/new_relic/agent/database/postgres_explain_obfuscator.rb +2 -2
- data/lib/new_relic/agent/database.rb +20 -24
- data/lib/new_relic/agent/datastores/metric_helper.rb +10 -10
- data/lib/new_relic/agent/datastores/mongo/event_formatter.rb +2 -3
- data/lib/new_relic/agent/datastores/mongo/metric_translator.rb +3 -5
- data/lib/new_relic/agent/datastores/mongo/obfuscator.rb +1 -2
- data/lib/new_relic/agent/datastores/redis.rb +2 -4
- data/lib/new_relic/agent/datastores.rb +1 -3
- data/lib/new_relic/agent/distributed_tracing/cross_app_payload.rb +5 -5
- data/lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb +11 -10
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_attributes.rb +10 -11
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb +41 -42
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_transport_type.rb +3 -3
- data/lib/new_relic/agent/distributed_tracing/trace_context.rb +41 -43
- data/lib/new_relic/agent/distributed_tracing/trace_context_payload.rb +23 -23
- data/lib/new_relic/agent/distributed_tracing.rb +17 -18
- data/lib/new_relic/agent/encoding_normalizer.rb +1 -1
- data/lib/new_relic/agent/error_collector.rb +17 -17
- data/lib/new_relic/agent/error_event_aggregator.rb +1 -1
- data/lib/new_relic/agent/error_filter.rb +6 -8
- data/lib/new_relic/agent/error_trace_aggregator.rb +1 -1
- data/lib/new_relic/agent/event_aggregator.rb +1 -1
- data/lib/new_relic/agent/event_buffer.rb +6 -7
- data/lib/new_relic/agent/event_listener.rb +0 -1
- data/lib/new_relic/agent/event_loop.rb +10 -10
- data/lib/new_relic/agent/external.rb +1 -2
- data/lib/new_relic/agent/guid_generator.rb +1 -3
- data/lib/new_relic/agent/harvester.rb +3 -4
- data/lib/new_relic/agent/heap.rb +1 -3
- data/lib/new_relic/agent/hostname.rb +3 -3
- data/lib/new_relic/agent/http_clients/abstract.rb +5 -7
- data/lib/new_relic/agent/http_clients/curb_wrappers.rb +1 -5
- data/lib/new_relic/agent/http_clients/excon_wrappers.rb +4 -4
- data/lib/new_relic/agent/http_clients/http_rb_wrappers.rb +3 -3
- data/lib/new_relic/agent/http_clients/httpclient_wrappers.rb +1 -2
- data/lib/new_relic/agent/http_clients/net_http_wrappers.rb +2 -3
- data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +2 -3
- data/lib/new_relic/agent/http_clients/uri_util.rb +0 -1
- data/lib/new_relic/agent/instrumentation/action_cable_subscriber.rb +2 -3
- data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +9 -10
- data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +5 -7
- data/lib/new_relic/agent/instrumentation/active_job.rb +4 -3
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +2 -2
- data/lib/new_relic/agent/instrumentation/active_record.rb +20 -18
- data/lib/new_relic/agent/instrumentation/active_record_helper.rb +36 -42
- data/lib/new_relic/agent/instrumentation/active_record_notifications.rb +28 -25
- data/lib/new_relic/agent/instrumentation/active_record_prepend.rb +3 -3
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +5 -6
- data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +8 -9
- data/lib/new_relic/agent/instrumentation/bunny/chain.rb +1 -1
- data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +7 -8
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +41 -41
- data/lib/new_relic/agent/instrumentation/curb/chain.rb +19 -20
- data/lib/new_relic/agent/instrumentation/curb/instrumentation.rb +34 -38
- data/lib/new_relic/agent/instrumentation/curb/prepend.rb +9 -10
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +10 -10
- data/lib/new_relic/agent/instrumentation/delayed_job/chain.rb +5 -7
- data/lib/new_relic/agent/instrumentation/delayed_job/instrumentation.rb +2 -6
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +4 -4
- data/lib/new_relic/agent/instrumentation/excon/middleware.rb +2 -2
- data/lib/new_relic/agent/instrumentation/excon.rb +0 -1
- data/lib/new_relic/agent/instrumentation/grape/chain.rb +1 -2
- data/lib/new_relic/agent/instrumentation/grape/instrumentation.rb +6 -7
- data/lib/new_relic/agent/instrumentation/grape.rb +2 -3
- data/lib/new_relic/agent/instrumentation/httpclient/chain.rb +2 -3
- data/lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb +0 -1
- data/lib/new_relic/agent/instrumentation/httpclient/prepend.rb +0 -2
- data/lib/new_relic/agent/instrumentation/httprb/chain.rb +2 -2
- data/lib/new_relic/agent/instrumentation/httprb/instrumentation.rb +6 -6
- data/lib/new_relic/agent/instrumentation/httprb/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/ignore_actions.rb +2 -3
- data/lib/new_relic/agent/instrumentation/logger/instrumentation.rb +0 -1
- data/lib/new_relic/agent/instrumentation/logger.rb +1 -1
- data/lib/new_relic/agent/instrumentation/memcache/dalli.rb +2 -1
- data/lib/new_relic/agent/instrumentation/memcache/helper.rb +0 -1
- data/lib/new_relic/agent/instrumentation/memcache/prepend.rb +1 -0
- data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +9 -10
- data/lib/new_relic/agent/instrumentation/middleware_tracing.rb +4 -5
- data/lib/new_relic/agent/instrumentation/mongodb_command_subscriber.rb +4 -4
- data/lib/new_relic/agent/instrumentation/net_http/chain.rb +3 -4
- data/lib/new_relic/agent/instrumentation/net_http/instrumentation.rb +5 -5
- data/lib/new_relic/agent/instrumentation/net_http/prepend.rb +4 -4
- data/lib/new_relic/agent/instrumentation/net_http.rb +1 -1
- data/lib/new_relic/agent/instrumentation/notifications_subscriber.rb +2 -3
- data/lib/new_relic/agent/instrumentation/padrino/instrumentation.rb +3 -2
- data/lib/new_relic/agent/instrumentation/padrino/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/padrino.rb +0 -5
- data/lib/new_relic/agent/instrumentation/queue_time.rb +5 -5
- data/lib/new_relic/agent/instrumentation/rack/chain.rb +5 -5
- data/lib/new_relic/agent/instrumentation/rack/helpers.rb +0 -1
- data/lib/new_relic/agent/instrumentation/rack/instrumentation.rb +4 -5
- data/lib/new_relic/agent/instrumentation/rack/prepend.rb +0 -1
- data/lib/new_relic/agent/instrumentation/rack.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +6 -6
- data/lib/new_relic/agent/instrumentation/rails_notifications/action_cable.rb +2 -2
- data/lib/new_relic/agent/instrumentation/rails_notifications/action_controller.rb +0 -1
- data/lib/new_relic/agent/instrumentation/rake/chain.rb +0 -5
- data/lib/new_relic/agent/instrumentation/rake/instrumentation.rb +6 -6
- data/lib/new_relic/agent/instrumentation/rake.rb +1 -1
- data/lib/new_relic/agent/instrumentation/redis/chain.rb +6 -6
- data/lib/new_relic/agent/instrumentation/redis/instrumentation.rb +2 -2
- data/lib/new_relic/agent/instrumentation/redis/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/redis.rb +1 -1
- data/lib/new_relic/agent/instrumentation/resque/chain.rb +2 -3
- data/lib/new_relic/agent/instrumentation/resque/helper.rb +1 -1
- data/lib/new_relic/agent/instrumentation/resque/instrumentation.rb +4 -4
- data/lib/new_relic/agent/instrumentation/resque/prepend.rb +1 -2
- data/lib/new_relic/agent/instrumentation/resque.rb +7 -7
- data/lib/new_relic/agent/instrumentation/sequel.rb +7 -9
- data/lib/new_relic/agent/instrumentation/sequel_helper.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sidekiq.rb +5 -4
- data/lib/new_relic/agent/instrumentation/sinatra/ignorer.rb +0 -1
- data/lib/new_relic/agent/instrumentation/sinatra/instrumentation.rb +4 -3
- data/lib/new_relic/agent/instrumentation/sunspot.rb +1 -1
- data/lib/new_relic/agent/instrumentation/tilt/instrumentation.rb +0 -1
- data/lib/new_relic/agent/instrumentation/typhoeus/chain.rb +4 -4
- data/lib/new_relic/agent/instrumentation/typhoeus/instrumentation.rb +3 -5
- data/lib/new_relic/agent/instrumentation/typhoeus/prepend.rb +1 -1
- data/lib/new_relic/agent/internal_agent_error.rb +1 -1
- data/lib/new_relic/agent/javascript_instrumentor.rb +28 -28
- data/lib/new_relic/agent/logging.rb +8 -4
- data/lib/new_relic/agent/memory_logger.rb +1 -1
- data/lib/new_relic/agent/messaging.rb +42 -43
- data/lib/new_relic/agent/method_tracer.rb +9 -12
- data/lib/new_relic/agent/method_tracer_helpers.rb +2 -2
- data/lib/new_relic/agent/monitors/cross_app_monitor.rb +13 -12
- data/lib/new_relic/agent/monitors/distributed_tracing_monitor.rb +2 -2
- data/lib/new_relic/agent/monitors/inbound_request_monitor.rb +0 -1
- data/lib/new_relic/agent/monitors/synthetics_monitor.rb +4 -7
- data/lib/new_relic/agent/monitors.rb +1 -2
- data/lib/new_relic/agent/new_relic_service/encoders.rb +4 -4
- data/lib/new_relic/agent/new_relic_service/json_marshaller.rb +1 -1
- data/lib/new_relic/agent/new_relic_service/marshaller.rb +1 -1
- data/lib/new_relic/agent/new_relic_service/security_policy_settings.rb +4 -3
- data/lib/new_relic/agent/new_relic_service.rb +20 -20
- data/lib/new_relic/agent/noticible_error.rb +0 -2
- data/lib/new_relic/agent/null_logger.rb +6 -2
- data/lib/new_relic/agent/obfuscator.rb +6 -8
- data/lib/new_relic/agent/parameter_filtering.rb +3 -5
- data/lib/new_relic/agent/payload_metric_mapping.rb +8 -9
- data/lib/new_relic/agent/pipe_channel_manager.rb +5 -6
- data/lib/new_relic/agent/pipe_service.rb +1 -1
- data/lib/new_relic/agent/priority_sampled_buffer.rb +4 -7
- data/lib/new_relic/agent/rules_engine/replacement_rule.rb +9 -9
- data/lib/new_relic/agent/rules_engine/segment_terms_rule.rb +12 -12
- data/lib/new_relic/agent/rules_engine.rb +2 -2
- data/lib/new_relic/agent/sampler.rb +2 -3
- data/lib/new_relic/agent/sampler_collection.rb +2 -3
- data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +3 -3
- data/lib/new_relic/agent/samplers/memory_sampler.rb +4 -3
- data/lib/new_relic/agent/samplers/vm_sampler.rb +18 -18
- data/lib/new_relic/agent/span_event_aggregator.rb +8 -8
- data/lib/new_relic/agent/span_event_primitive.rb +39 -39
- data/lib/new_relic/agent/sql_sampler.rb +9 -9
- data/lib/new_relic/agent/stats.rb +16 -16
- data/lib/new_relic/agent/stats_engine/gc_profiler.rb +7 -9
- data/lib/new_relic/agent/stats_engine/stats_hash.rb +8 -9
- data/lib/new_relic/agent/stats_engine.rb +6 -6
- data/lib/new_relic/agent/synthetics_event_aggregator.rb +0 -1
- data/lib/new_relic/agent/system_info.rb +22 -20
- data/lib/new_relic/agent/threading/agent_thread.rb +4 -5
- data/lib/new_relic/agent/threading/backtrace_node.rb +6 -9
- data/lib/new_relic/agent/threading/backtrace_service.rb +8 -8
- data/lib/new_relic/agent/threading/thread_profile.rb +15 -18
- data/lib/new_relic/agent/tracer.rb +37 -43
- data/lib/new_relic/agent/transaction/abstract_segment.rb +6 -6
- data/lib/new_relic/agent/transaction/datastore_segment.rb +5 -7
- data/lib/new_relic/agent/transaction/distributed_tracer.rb +7 -9
- data/lib/new_relic/agent/transaction/distributed_tracing.rb +21 -22
- data/lib/new_relic/agent/transaction/external_request_segment.rb +3 -5
- data/lib/new_relic/agent/transaction/message_broker_segment.rb +23 -23
- data/lib/new_relic/agent/transaction/request_attributes.rb +7 -7
- data/lib/new_relic/agent/transaction/segment.rb +3 -3
- data/lib/new_relic/agent/transaction/slowest_sample_buffer.rb +0 -2
- data/lib/new_relic/agent/transaction/trace.rb +8 -8
- data/lib/new_relic/agent/transaction/trace_context.rb +13 -15
- data/lib/new_relic/agent/transaction/trace_node.rb +16 -16
- data/lib/new_relic/agent/transaction/tracing.rb +1 -3
- data/lib/new_relic/agent/transaction/transaction_sample_buffer.rb +1 -2
- data/lib/new_relic/agent/transaction.rb +79 -81
- data/lib/new_relic/agent/transaction_error_primitive.rb +16 -16
- data/lib/new_relic/agent/transaction_event_aggregator.rb +5 -6
- data/lib/new_relic/agent/transaction_event_primitive.rb +29 -29
- data/lib/new_relic/agent/transaction_metrics.rb +3 -3
- data/lib/new_relic/agent/transaction_sampler.rb +0 -1
- data/lib/new_relic/agent/transaction_time_aggregator.rb +6 -6
- data/lib/new_relic/agent/utilization/azure.rb +1 -1
- data/lib/new_relic/agent/utilization_data.rb +3 -4
- data/lib/new_relic/agent/vm/monotonic_gc_profiler.rb +1 -1
- data/lib/new_relic/agent/vm/snapshot.rb +3 -3
- data/lib/new_relic/agent/worker_loop.rb +3 -5
- data/lib/new_relic/agent.rb +22 -22
- data/lib/new_relic/cli/command.rb +15 -17
- data/lib/new_relic/cli/commands/deployments.rb +20 -22
- data/lib/new_relic/cli/commands/install.rb +6 -10
- data/lib/new_relic/coerce.rb +5 -8
- data/lib/new_relic/collection_helper.rb +48 -47
- data/lib/new_relic/control/class_methods.rb +2 -2
- data/lib/new_relic/control/frameworks/external.rb +1 -1
- data/lib/new_relic/control/frameworks/rails.rb +5 -6
- data/lib/new_relic/control/frameworks/rails3.rb +2 -3
- data/lib/new_relic/control/frameworks/ruby.rb +2 -2
- data/lib/new_relic/control/instance_methods.rb +4 -5
- data/lib/new_relic/control/instrumentation.rb +4 -5
- data/lib/new_relic/control/server_methods.rb +2 -3
- data/lib/new_relic/control.rb +0 -1
- data/lib/new_relic/dependency_detection.rb +6 -8
- data/lib/new_relic/environment_report.rb +16 -18
- data/lib/new_relic/helper.rb +5 -5
- data/lib/new_relic/language_support.rb +1 -1
- data/lib/new_relic/latest_changes.rb +2 -2
- data/lib/new_relic/local_environment.rb +7 -7
- data/lib/new_relic/metric_data.rb +6 -7
- data/lib/new_relic/metric_spec.rb +3 -3
- data/lib/new_relic/noticed_error.rb +14 -15
- data/lib/new_relic/rack/agent_middleware.rb +2 -2
- data/lib/new_relic/rack/browser_monitoring.rb +9 -9
- data/lib/new_relic/recipes/capistrano3.rb +11 -13
- data/lib/new_relic/recipes/capistrano_legacy.rb +11 -14
- data/lib/new_relic/supportability_helper.rb +1 -2
- data/lib/new_relic/version.rb +3 -4
- data/lib/sequel/extensions/newrelic_instrumentation.rb +4 -7
- data/lib/sequel/plugins/newrelic_instrumentation.rb +3 -9
- data/lib/tasks/all.rb +1 -1
- data/lib/tasks/config.rake +21 -21
- data/lib/tasks/multiverse.rb +4 -6
- data/lib/tasks/tests.rake +3 -7
- data/newrelic_rpm.gemspec +13 -12
- data/recipes/newrelic.rb +1 -1
- data/test/agent_helper.rb +55 -55
- metadata +33 -4
@@ -24,33 +24,33 @@ module NewRelic
|
|
24
24
|
include Tracing
|
25
25
|
|
26
26
|
# for nested transactions
|
27
|
-
NESTED_TRANSACTION_PREFIX
|
28
|
-
CONTROLLER_PREFIX
|
29
|
-
MIDDLEWARE_PREFIX
|
30
|
-
OTHER_TRANSACTION_PREFIX
|
31
|
-
TASK_PREFIX
|
32
|
-
RAKE_PREFIX
|
33
|
-
MESSAGE_PREFIX
|
34
|
-
RACK_PREFIX
|
35
|
-
SINATRA_PREFIX
|
36
|
-
GRAPE_PREFIX
|
37
|
-
ACTION_CABLE_PREFIX
|
38
|
-
|
39
|
-
WEB_TRANSACTION_CATEGORIES
|
40
|
-
TRANSACTION_NAMING_SOURCES
|
41
|
-
|
42
|
-
MIDDLEWARE_SUMMARY_METRICS
|
43
|
-
WEB_SUMMARY_METRIC
|
44
|
-
OTHER_SUMMARY_METRIC
|
45
|
-
QUEUE_TIME_METRIC
|
46
|
-
|
47
|
-
APDEX_S
|
48
|
-
APDEX_T
|
49
|
-
APDEX_F
|
50
|
-
APDEX_ALL_METRIC
|
51
|
-
APDEX_METRIC
|
52
|
-
APDEX_OTHER_METRIC
|
53
|
-
APDEX_TXN_METRIC_PREFIX
|
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
|
+
TRANSACTION_NAMING_SOURCES = [:child, :api].freeze
|
41
|
+
|
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
54
|
APDEX_OTHER_TXN_METRIC_PREFIX = "ApdexOther/Transaction/"
|
55
55
|
|
56
56
|
JRUBY_CPU_TIME_ERROR = "Error calculating JRuby CPU Time"
|
@@ -67,27 +67,27 @@ module NewRelic
|
|
67
67
|
attr_accessor :apdex_start
|
68
68
|
|
69
69
|
attr_accessor :exceptions,
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
70
|
+
:filtered_params,
|
71
|
+
:jruby_cpu_start,
|
72
|
+
:process_cpu_start,
|
73
|
+
:http_response_code,
|
74
|
+
:response_content_length,
|
75
|
+
:response_content_type,
|
76
|
+
:parent_span_id
|
77
77
|
|
78
78
|
attr_reader :guid,
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
79
|
+
:metrics,
|
80
|
+
:gc_start_snapshot,
|
81
|
+
:category,
|
82
|
+
:attributes,
|
83
|
+
:payload,
|
84
|
+
:nesting_max_depth,
|
85
|
+
:segments,
|
86
|
+
:end_time,
|
87
|
+
:duration
|
88
88
|
|
89
89
|
attr_writer :sampled,
|
90
|
-
|
90
|
+
:priority
|
91
91
|
|
92
92
|
# Populated with the trace sample once this transaction is completed.
|
93
93
|
attr_reader :transaction_trace
|
@@ -100,13 +100,13 @@ module NewRelic
|
|
100
100
|
Tracer.current_transaction
|
101
101
|
end
|
102
102
|
|
103
|
-
def self.set_default_transaction_name(partial_name, category = nil) #THREAD_LOCAL_ACCESS
|
104
|
-
txn
|
103
|
+
def self.set_default_transaction_name(partial_name, category = nil) # THREAD_LOCAL_ACCESS
|
104
|
+
txn = tl_current
|
105
105
|
name = name_from_partial(partial_name, category || txn.category)
|
106
106
|
txn.set_default_transaction_name(name, category)
|
107
107
|
end
|
108
108
|
|
109
|
-
def self.set_overriding_transaction_name(partial_name, category = nil) #THREAD_LOCAL_ACCESS
|
109
|
+
def self.set_overriding_transaction_name(partial_name, category = nil) # THREAD_LOCAL_ACCESS
|
110
110
|
txn = tl_current
|
111
111
|
return unless txn
|
112
112
|
|
@@ -143,7 +143,7 @@ module NewRelic
|
|
143
143
|
end
|
144
144
|
|
145
145
|
# See NewRelic::Agent.notice_error for options and commentary
|
146
|
-
def self.notice_error(e, options={})
|
146
|
+
def self.notice_error(e, options = {})
|
147
147
|
if txn = Tracer.current_transaction
|
148
148
|
txn.notice_error(e, options)
|
149
149
|
elsif NewRelic::Agent.instance
|
@@ -156,7 +156,7 @@ module NewRelic
|
|
156
156
|
#
|
157
157
|
# @api public
|
158
158
|
#
|
159
|
-
def self.recording_web_transaction? #THREAD_LOCAL_ACCESS
|
159
|
+
def self.recording_web_transaction? # THREAD_LOCAL_ACCESS
|
160
160
|
NewRelic::Agent.record_api_supportability_metric(:recording_web_transaction?)
|
161
161
|
|
162
162
|
txn = tl_current
|
@@ -220,8 +220,8 @@ module NewRelic
|
|
220
220
|
@segments = []
|
221
221
|
|
222
222
|
self.default_name = options[:transaction_name]
|
223
|
-
@overridden_name
|
224
|
-
@frozen_name
|
223
|
+
@overridden_name = nil
|
224
|
+
@frozen_name = nil
|
225
225
|
|
226
226
|
@category = category
|
227
227
|
@start_time = Process.clock_gettime(Process::CLOCK_REALTIME)
|
@@ -352,9 +352,9 @@ module NewRelic
|
|
352
352
|
|
353
353
|
def best_name
|
354
354
|
@frozen_name ||
|
355
|
-
|
356
|
-
|
357
|
-
|
355
|
+
@overridden_name ||
|
356
|
+
@default_name ||
|
357
|
+
NewRelic::Agent::UNKNOWN_METRIC
|
358
358
|
end
|
359
359
|
|
360
360
|
# For common interface with Trace
|
@@ -546,8 +546,8 @@ module NewRelic
|
|
546
546
|
|
547
547
|
def assign_agent_attributes
|
548
548
|
default_destinations = AttributeFilter::DST_TRANSACTION_TRACER |
|
549
|
-
|
550
|
-
|
549
|
+
AttributeFilter::DST_TRANSACTION_EVENTS |
|
550
|
+
AttributeFilter::DST_ERROR_COLLECTOR
|
551
551
|
|
552
552
|
if http_response_code
|
553
553
|
add_agent_attribute(:'http.statusCode', http_response_code, default_destinations)
|
@@ -622,14 +622,14 @@ module NewRelic
|
|
622
622
|
|
623
623
|
def generate_payload
|
624
624
|
@payload = {
|
625
|
-
:name
|
626
|
-
:bucket
|
627
|
-
:start_timestamp
|
628
|
-
:duration
|
629
|
-
:metrics
|
630
|
-
:attributes
|
631
|
-
:error
|
632
|
-
:priority
|
625
|
+
:name => @frozen_name,
|
626
|
+
:bucket => recording_web_transaction? ? :request : :background,
|
627
|
+
:start_timestamp => start_time,
|
628
|
+
:duration => duration,
|
629
|
+
:metrics => @metrics,
|
630
|
+
:attributes => @attributes,
|
631
|
+
:error => false,
|
632
|
+
:priority => priority
|
633
633
|
}
|
634
634
|
|
635
635
|
distributed_tracer.append_payload(@payload)
|
@@ -683,7 +683,6 @@ module NewRelic
|
|
683
683
|
when :apdex_s then APDEX_S
|
684
684
|
when :apdex_t then APDEX_T
|
685
685
|
when :apdex_f then APDEX_F
|
686
|
-
else nil
|
687
686
|
end
|
688
687
|
payload[:apdex_perf_zone] = bucket_str if bucket_str
|
689
688
|
end
|
@@ -692,8 +691,8 @@ module NewRelic
|
|
692
691
|
return unless is_synthetics_request?
|
693
692
|
|
694
693
|
payload[:synthetics_resource_id] = synthetics_resource_id
|
695
|
-
payload[:synthetics_job_id]
|
696
|
-
payload[:synthetics_monitor_id]
|
694
|
+
payload[:synthetics_job_id] = synthetics_job_id
|
695
|
+
payload[:synthetics_monitor_id] = synthetics_monitor_id
|
697
696
|
end
|
698
697
|
|
699
698
|
def merge_metrics
|
@@ -703,9 +702,9 @@ module NewRelic
|
|
703
702
|
def record_exceptions
|
704
703
|
error_recorded = false
|
705
704
|
@exceptions.each do |exception, options|
|
706
|
-
options[:uri]
|
707
|
-
options[:port]
|
708
|
-
options[:metric]
|
705
|
+
options[:uri] ||= request_path if request_path
|
706
|
+
options[:port] = request_port if request_port
|
707
|
+
options[:metric] = best_name
|
709
708
|
options[:attributes] = @attributes
|
710
709
|
|
711
710
|
span_id = options.delete :span_id
|
@@ -715,8 +714,7 @@ module NewRelic
|
|
715
714
|
end
|
716
715
|
|
717
716
|
# Do not call this. Invoke the class method instead.
|
718
|
-
def notice_error(error, options={}) # :nodoc:
|
719
|
-
|
717
|
+
def notice_error(error, options = {}) # :nodoc:
|
720
718
|
# Only the last error is kept
|
721
719
|
if @current_segment
|
722
720
|
@current_segment.notice_error error, expected: options[:expected]
|
@@ -771,8 +769,8 @@ module NewRelic
|
|
771
769
|
record_apdex_metrics(APDEX_METRIC, APDEX_TXN_METRIC_PREFIX, apdex_t)
|
772
770
|
else
|
773
771
|
record_apdex_metrics(APDEX_OTHER_METRIC,
|
774
|
-
|
775
|
-
|
772
|
+
APDEX_OTHER_TXN_METRIC_PREFIX,
|
773
|
+
transaction_specific_apdex_t)
|
776
774
|
end
|
777
775
|
end
|
778
776
|
end
|
@@ -780,9 +778,9 @@ module NewRelic
|
|
780
778
|
def record_apdex_metrics(rollup_metric, transaction_prefix, current_apdex_t)
|
781
779
|
return unless current_apdex_t
|
782
780
|
|
783
|
-
total_duration
|
781
|
+
total_duration = end_time - apdex_start
|
784
782
|
apdex_bucket_global = apdex_bucket(total_duration, current_apdex_t)
|
785
|
-
apdex_bucket_txn
|
783
|
+
apdex_bucket_txn = apdex_bucket(duration, current_apdex_t)
|
786
784
|
|
787
785
|
@metrics.record_unscoped(rollup_metric, apdex_bucket_global, current_apdex_t)
|
788
786
|
@metrics.record_unscoped(APDEX_ALL_METRIC, apdex_bucket_global, current_apdex_t)
|
@@ -800,7 +798,7 @@ module NewRelic
|
|
800
798
|
end
|
801
799
|
|
802
800
|
def threshold
|
803
|
-
|
801
|
+
source_class = Agent.config.source(:'transaction_tracer.transaction_threshold').class
|
804
802
|
if source_class == Configuration::DefaultSource
|
805
803
|
apdex_t * 4
|
806
804
|
else
|
@@ -808,7 +806,7 @@ module NewRelic
|
|
808
806
|
end
|
809
807
|
end
|
810
808
|
|
811
|
-
def with_database_metric_name(model, method, product=nil)
|
809
|
+
def with_database_metric_name(model, method, product = nil)
|
812
810
|
previous = self.instrumentation_state[:datastore_override]
|
813
811
|
model_name = case model
|
814
812
|
when Class
|
@@ -817,7 +815,7 @@ module NewRelic
|
|
817
815
|
model
|
818
816
|
else
|
819
817
|
model.to_s
|
820
|
-
|
818
|
+
end
|
821
819
|
self.instrumentation_state[:datastore_override] = [method, model_name, product]
|
822
820
|
yield
|
823
821
|
ensure
|
@@ -895,9 +893,9 @@ module NewRelic
|
|
895
893
|
threadMBean = Java::JavaLangManagement::ManagementFactory.getThreadMXBean()
|
896
894
|
|
897
895
|
return nil unless threadMBean.isCurrentThreadCpuTimeSupported
|
898
|
-
java_utime = threadMBean.getCurrentThreadUserTime()
|
896
|
+
java_utime = threadMBean.getCurrentThreadUserTime() # ns
|
899
897
|
|
900
|
-
-1 == java_utime ? 0.0 : java_utime/1e9
|
898
|
+
-1 == java_utime ? 0.0 : java_utime / 1e9
|
901
899
|
rescue => e
|
902
900
|
::NewRelic::Agent.logger.log_once(:warn, :jruby_cpu_time, JRUBY_CPU_TIME_ERROR, e)
|
903
901
|
::NewRelic::Agent.logger.debug(JRUBY_CPU_TIME_ERROR, e)
|
@@ -16,23 +16,23 @@ module NewRelic
|
|
16
16
|
module TransactionErrorPrimitive
|
17
17
|
extend self
|
18
18
|
|
19
|
-
SAMPLE_TYPE
|
20
|
-
TYPE_KEY
|
21
|
-
ERROR_CLASS_KEY
|
22
|
-
ERROR_MESSAGE_KEY
|
23
|
-
ERROR_EXPECTED_KEY
|
24
|
-
TIMESTAMP_KEY
|
25
|
-
PORT_KEY
|
26
|
-
NAME_KEY
|
27
|
-
DURATION_KEY
|
28
|
-
SAMPLED_KEY
|
29
|
-
GUID_KEY
|
19
|
+
SAMPLE_TYPE = 'TransactionError'.freeze
|
20
|
+
TYPE_KEY = 'type'.freeze
|
21
|
+
ERROR_CLASS_KEY = 'error.class'.freeze
|
22
|
+
ERROR_MESSAGE_KEY = 'error.message'.freeze
|
23
|
+
ERROR_EXPECTED_KEY = 'error.expected'.freeze
|
24
|
+
TIMESTAMP_KEY = 'timestamp'.freeze
|
25
|
+
PORT_KEY = 'port'.freeze
|
26
|
+
NAME_KEY = 'transactionName'.freeze
|
27
|
+
DURATION_KEY = 'duration'.freeze
|
28
|
+
SAMPLED_KEY = 'sampled'.freeze
|
29
|
+
GUID_KEY = 'nr.transactionGuid'.freeze
|
30
30
|
REFERRING_TRANSACTION_GUID_KEY = 'nr.referringTransactionGuid'.freeze
|
31
|
-
SYNTHETICS_RESOURCE_ID_KEY
|
32
|
-
SYNTHETICS_JOB_ID_KEY
|
33
|
-
SYNTHETICS_MONITOR_ID_KEY
|
34
|
-
PRIORITY_KEY
|
35
|
-
SPAN_ID_KEY
|
31
|
+
SYNTHETICS_RESOURCE_ID_KEY = "nr.syntheticsResourceId".freeze
|
32
|
+
SYNTHETICS_JOB_ID_KEY = "nr.syntheticsJobId".freeze
|
33
|
+
SYNTHETICS_MONITOR_ID_KEY = "nr.syntheticsMonitorId".freeze
|
34
|
+
PRIORITY_KEY = "priority".freeze
|
35
|
+
SPAN_ID_KEY = "spanId".freeze
|
36
36
|
|
37
37
|
def create noticed_error, payload, span_id
|
38
38
|
[
|
@@ -3,22 +3,21 @@
|
|
3
3
|
# This file is distributed under New Relic's license terms.
|
4
4
|
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
5
5
|
|
6
|
-
require 'newrelic_rpm' unless defined?(
|
7
|
-
require 'new_relic/agent' unless defined?(
|
6
|
+
require 'newrelic_rpm' unless defined?(NewRelic)
|
7
|
+
require 'new_relic/agent' unless defined?(NewRelic::Agent)
|
8
8
|
require 'new_relic/agent/event_aggregator'
|
9
9
|
require 'new_relic/agent/priority_sampled_buffer'
|
10
10
|
|
11
11
|
module NewRelic
|
12
12
|
module Agent
|
13
13
|
class TransactionEventAggregator < EventAggregator
|
14
|
-
|
15
14
|
named :TransactionEventAggregator
|
16
15
|
capacity_key :'analytics_events.max_samples_stored'
|
17
16
|
enabled_key :'analytics_events.enabled'
|
18
17
|
buffer_class PrioritySampledBuffer
|
19
18
|
|
20
|
-
def record priority: nil, event:nil, &blk
|
21
|
-
unless
|
19
|
+
def record priority: nil, event: nil, &blk
|
20
|
+
unless event || priority && blk
|
22
21
|
raise ArgumentError, "Expected priority and block, or event"
|
23
22
|
end
|
24
23
|
|
@@ -37,7 +36,7 @@ module NewRelic
|
|
37
36
|
record_sampling_rate metadata
|
38
37
|
end
|
39
38
|
|
40
|
-
def record_sampling_rate(metadata) #THREAD_LOCAL_ACCESS
|
39
|
+
def record_sampling_rate(metadata) # THREAD_LOCAL_ACCESS
|
41
40
|
NewRelic::Agent.logger.debug("Sampled %d / %d (%.1f %%) requests this cycle, %d / %d (%.1f %%) since startup" % [
|
42
41
|
metadata[:captured],
|
43
42
|
metadata[:seen],
|
@@ -20,34 +20,34 @@ module NewRelic
|
|
20
20
|
COMMA = ','
|
21
21
|
|
22
22
|
# The type field of the sample
|
23
|
-
SAMPLE_TYPE
|
23
|
+
SAMPLE_TYPE = 'Transaction'
|
24
24
|
|
25
25
|
# Strings for static keys of the sample structure
|
26
|
-
TYPE_KEY
|
27
|
-
TIMESTAMP_KEY
|
28
|
-
NAME_KEY
|
29
|
-
DURATION_KEY
|
30
|
-
ERROR_KEY
|
31
|
-
SAMPLED_KEY
|
32
|
-
PRIORITY_KEY
|
33
|
-
GUID_KEY
|
26
|
+
TYPE_KEY = 'type'
|
27
|
+
TIMESTAMP_KEY = 'timestamp'
|
28
|
+
NAME_KEY = 'name'
|
29
|
+
DURATION_KEY = 'duration'
|
30
|
+
ERROR_KEY = 'error'
|
31
|
+
SAMPLED_KEY = 'sampled'
|
32
|
+
PRIORITY_KEY = 'priority'
|
33
|
+
GUID_KEY = 'nr.guid'
|
34
34
|
REFERRING_TRANSACTION_GUID_KEY = 'nr.referringTransactionGuid'
|
35
|
-
CAT_PATH_HASH_KEY
|
36
|
-
CAT_REFERRING_PATH_HASH_KEY
|
37
|
-
CAT_ALTERNATE_PATH_HASHES_KEY
|
38
|
-
APDEX_PERF_ZONE_KEY
|
39
|
-
SYNTHETICS_RESOURCE_ID_KEY
|
40
|
-
SYNTHETICS_JOB_ID_KEY
|
41
|
-
SYNTHETICS_MONITOR_ID_KEY
|
35
|
+
CAT_PATH_HASH_KEY = 'nr.pathHash'
|
36
|
+
CAT_REFERRING_PATH_HASH_KEY = 'nr.referringPathHash'
|
37
|
+
CAT_ALTERNATE_PATH_HASHES_KEY = 'nr.alternatePathHashes'
|
38
|
+
APDEX_PERF_ZONE_KEY = 'nr.apdexPerfZone'
|
39
|
+
SYNTHETICS_RESOURCE_ID_KEY = "nr.syntheticsResourceId"
|
40
|
+
SYNTHETICS_JOB_ID_KEY = "nr.syntheticsJobId"
|
41
|
+
SYNTHETICS_MONITOR_ID_KEY = "nr.syntheticsMonitorId"
|
42
42
|
|
43
43
|
def create(payload)
|
44
44
|
intrinsics = {
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
45
|
+
TIMESTAMP_KEY => float(payload[:start_timestamp]),
|
46
|
+
NAME_KEY => string(payload[:name]),
|
47
|
+
DURATION_KEY => float(payload[:duration]),
|
48
|
+
TYPE_KEY => SAMPLE_TYPE,
|
49
|
+
ERROR_KEY => payload[:error],
|
50
|
+
PRIORITY_KEY => payload[:priority]
|
51
51
|
}
|
52
52
|
|
53
53
|
intrinsics[SAMPLED_KEY] = payload[:sampled] if payload.key?(:sampled)
|
@@ -64,14 +64,14 @@ module NewRelic
|
|
64
64
|
private
|
65
65
|
|
66
66
|
def append_optional_attributes(sample, payload)
|
67
|
-
optionally_append(GUID_KEY,
|
67
|
+
optionally_append(GUID_KEY, :guid, sample, payload)
|
68
68
|
optionally_append(REFERRING_TRANSACTION_GUID_KEY, :referring_transaction_guid, sample, payload)
|
69
|
-
optionally_append(CAT_PATH_HASH_KEY,
|
70
|
-
optionally_append(CAT_REFERRING_PATH_HASH_KEY,
|
71
|
-
optionally_append(APDEX_PERF_ZONE_KEY,
|
72
|
-
optionally_append(SYNTHETICS_RESOURCE_ID_KEY,
|
73
|
-
optionally_append(SYNTHETICS_JOB_ID_KEY,
|
74
|
-
optionally_append(SYNTHETICS_MONITOR_ID_KEY,
|
69
|
+
optionally_append(CAT_PATH_HASH_KEY, :cat_path_hash, sample, payload)
|
70
|
+
optionally_append(CAT_REFERRING_PATH_HASH_KEY, :cat_referring_path_hash, sample, payload)
|
71
|
+
optionally_append(APDEX_PERF_ZONE_KEY, :apdex_perf_zone, sample, payload)
|
72
|
+
optionally_append(SYNTHETICS_RESOURCE_ID_KEY, :synthetics_resource_id, sample, payload)
|
73
|
+
optionally_append(SYNTHETICS_JOB_ID_KEY, :synthetics_job_id, sample, payload)
|
74
|
+
optionally_append(SYNTHETICS_MONITOR_ID_KEY, :synthetics_monitor_id, sample, payload)
|
75
75
|
append_cat_alternate_path_hashes(sample, payload)
|
76
76
|
end
|
77
77
|
|
@@ -14,7 +14,7 @@ module NewRelic
|
|
14
14
|
|
15
15
|
def initialize
|
16
16
|
@unscoped = Hash.new(&DEFAULT_PROC)
|
17
|
-
@scoped
|
17
|
+
@scoped = Hash.new(&DEFAULT_PROC)
|
18
18
|
end
|
19
19
|
|
20
20
|
# As a general rule, when recording a scoped metric, the corresponding
|
@@ -25,11 +25,11 @@ module NewRelic
|
|
25
25
|
# propagate them into unscoped metrics as well when instances of this
|
26
26
|
# class are merged into the global metric store.
|
27
27
|
#
|
28
|
-
def record_scoped_and_unscoped(names, value=nil, aux=nil, &blk)
|
28
|
+
def record_scoped_and_unscoped(names, value = nil, aux = nil, &blk)
|
29
29
|
_record_metrics(names, value, aux, @scoped, &blk)
|
30
30
|
end
|
31
31
|
|
32
|
-
def record_unscoped(names, value=nil, aux=nil, &blk)
|
32
|
+
def record_unscoped(names, value = nil, aux = nil, &blk)
|
33
33
|
_record_metrics(names, value, aux, @unscoped, &blk)
|
34
34
|
end
|
35
35
|
|
@@ -14,7 +14,7 @@ module NewRelic
|
|
14
14
|
module TransactionTimeAggregator
|
15
15
|
TransactionStats = Struct.new :transaction_started_at, :elapsed_transaction_time
|
16
16
|
|
17
|
-
@lock
|
17
|
+
@lock = Mutex.new
|
18
18
|
@harvest_cycle_started_at = Process.clock_gettime(Process::CLOCK_REALTIME)
|
19
19
|
|
20
20
|
@stats = Hash.new do |h, k|
|
@@ -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
|
@@ -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
|
@@ -7,9 +7,9 @@ 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
15
|
@taken_at = Process.clock_gettime(Process::CLOCK_REALTIME)
|
@@ -6,17 +6,15 @@ 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
19
|
@next_invocation_time = Process.clock_gettime(Process::CLOCK_REALTIME)
|
22
20
|
@period = 60.0
|
@@ -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?
|