newrelic_rpm 7.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/.gitignore +2 -0
- data/.rubocop.yml +1936 -0
- data/CHANGELOG.md +182 -9
- data/CONTRIBUTING.md +14 -2
- data/Guardfile +8 -8
- data/README.md +5 -1
- 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 +9 -5
- data/lib/new_relic/agent/agent.rb +44 -46
- 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 +7 -6
- data/lib/new_relic/agent/configuration/default_source.rb +352 -336
- 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 +30 -16
- data/lib/new_relic/agent/configuration/high_security_source.rb +7 -7
- data/lib/new_relic/agent/configuration/manager.rb +57 -58
- 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 +12 -11
- data/lib/new_relic/agent/configuration/yaml_source.rb +26 -5
- 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 -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 +25 -26
- 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/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 +17 -17
- data/lib/new_relic/agent/error_event_aggregator.rb +1 -1
- data/lib/new_relic/agent/error_filter.rb +16 -10
- 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 +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 +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 +10 -11
- 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 +3 -3
- 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 +8 -9
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +42 -42
- 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 +5 -9
- 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 +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 +25 -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 +4 -5
- 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 +1 -1
- 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 +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 +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/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 +7 -1
- 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/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 +30 -30
- 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 -61
- data/lib/new_relic/agent/method_tracer.rb +139 -143
- data/lib/new_relic/agent/method_tracer_helpers.rb +2 -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 +34 -41
- 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 +15 -12
- data/lib/new_relic/agent/pipe_service.rb +2 -2
- 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 +4 -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 +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 +7 -7
- 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 +12 -13
- data/lib/new_relic/agent/threading/thread_profile.rb +16 -19
- data/lib/new_relic/agent/tracer.rb +43 -71
- data/lib/new_relic/agent/transaction/abstract_segment.rb +9 -9
- 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 +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 +85 -108
- 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 +11 -11
- 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 +4 -4
- data/lib/new_relic/agent/worker_loop.rb +8 -10
- data/lib/new_relic/agent.rb +27 -27
- 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/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 +16 -17
- 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 +4 -5
- 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.rake +21 -21
- data/lib/tasks/multiverse.rb +4 -6
- data/lib/tasks/tests.rake +3 -7
- data/newrelic.yml +580 -3
- data/newrelic_rpm.gemspec +13 -12
- data/recipes/newrelic.rb +1 -1
- data/test/agent_helper.rb +80 -55
- metadata +42 -13
- 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
@@ -6,7 +6,7 @@ module NewRelic
|
|
6
6
|
module Agent
|
7
7
|
class NewRelicService
|
8
8
|
module SecurityPolicySettings
|
9
|
-
EXPECTED_SECURITY_POLICIES = %w
|
9
|
+
EXPECTED_SECURITY_POLICIES = %w[
|
10
10
|
record_sql
|
11
11
|
attributes_include
|
12
12
|
allow_raw_exception_messages
|
@@ -14,12 +14,13 @@ module NewRelic
|
|
14
14
|
custom_parameters
|
15
15
|
custom_instrumentation_editor
|
16
16
|
message_parameters
|
17
|
-
job_arguments
|
17
|
+
job_arguments
|
18
|
+
].map(&:freeze)
|
18
19
|
|
19
20
|
def self.preliminary_settings(security_policies)
|
20
21
|
enabled_key = 'enabled'.freeze
|
21
22
|
settings = EXPECTED_SECURITY_POLICIES.inject({}) do |memo, policy_name|
|
22
|
-
memo[policy_name] =
|
23
|
+
memo[policy_name] = {enabled_key => security_policies[policy_name][enabled_key]}
|
23
24
|
memo
|
24
25
|
end
|
25
26
|
{'security_policies' => settings}
|
@@ -35,7 +35,7 @@ module NewRelic
|
|
35
35
|
attr_accessor :request_timeout
|
36
36
|
attr_reader :collector, :marshaller, :agent_id
|
37
37
|
|
38
|
-
def initialize(license_key=nil, collector=control.server)
|
38
|
+
def initialize(license_key = nil, collector = control.server)
|
39
39
|
@license_key = license_key
|
40
40
|
@collector = collector
|
41
41
|
@configured_collector = collector
|
@@ -69,7 +69,7 @@ module NewRelic
|
|
69
69
|
@agent_id = id
|
70
70
|
end
|
71
71
|
|
72
|
-
def connect(settings={})
|
72
|
+
def connect(settings = {})
|
73
73
|
@request_headers_map = nil
|
74
74
|
security_policies = nil
|
75
75
|
if response = preconnect
|
@@ -128,11 +128,11 @@ module NewRelic
|
|
128
128
|
|
129
129
|
def metric_data(stats_hash)
|
130
130
|
timeslice_start = stats_hash.started_at
|
131
|
-
timeslice_end
|
131
|
+
timeslice_end = stats_hash.harvested_at || Process.clock_gettime(Process::CLOCK_REALTIME)
|
132
132
|
metric_data_array = build_metric_data_array(stats_hash)
|
133
133
|
result = invoke_remote(
|
134
134
|
:metric_data,
|
135
|
-
[@agent_id, timeslice_start
|
135
|
+
[@agent_id, timeslice_start, timeslice_end, metric_data_array],
|
136
136
|
:item_count => metric_data_array.size
|
137
137
|
)
|
138
138
|
result
|
@@ -215,7 +215,7 @@ module NewRelic
|
|
215
215
|
raise ArgumentError, "#{self.class}#shared_connection must be passed a block" unless block_given?
|
216
216
|
|
217
217
|
begin
|
218
|
-
t0 =
|
218
|
+
t0 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
219
219
|
@in_session = true
|
220
220
|
if NewRelic::Agent.config[:aggressive_keepalive]
|
221
221
|
session_with_keepalive(&block)
|
@@ -223,7 +223,7 @@ module NewRelic
|
|
223
223
|
session_without_keepalive(&block)
|
224
224
|
end
|
225
225
|
rescue *CONNECTION_ERRORS => e
|
226
|
-
elapsed =
|
226
|
+
elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - t0
|
227
227
|
raise NewRelic::Agent::ServerConnectionException, "Recoverable error connecting to #{@collector} after #{elapsed} seconds: #{e}"
|
228
228
|
ensure
|
229
229
|
@in_session = false
|
@@ -289,7 +289,7 @@ module NewRelic
|
|
289
289
|
# Jruby 1.6.8 requires a gem for full ssl support and will throw
|
290
290
|
# an error when use_ssl=(true) is called and jruby-openssl isn't
|
291
291
|
# installed
|
292
|
-
conn.use_ssl
|
292
|
+
conn.use_ssl = true
|
293
293
|
conn.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
294
294
|
set_cert_store(conn)
|
295
295
|
rescue StandardError, LoadError
|
@@ -299,7 +299,7 @@ module NewRelic
|
|
299
299
|
|
300
300
|
def set_cert_store(conn)
|
301
301
|
if NewRelic::Agent.config[:ca_bundle_path]
|
302
|
-
conn.cert_store
|
302
|
+
conn.cert_store = ssl_cert_store
|
303
303
|
else
|
304
304
|
::NewRelic::Agent.logger.debug("Using default security certificates")
|
305
305
|
end
|
@@ -388,15 +388,15 @@ module NewRelic
|
|
388
388
|
def generate_remote_method_uri(method)
|
389
389
|
params = {
|
390
390
|
'protocol_version' => PROTOCOL_VERSION,
|
391
|
-
'license_key'
|
392
|
-
'run_id'
|
393
|
-
'method'
|
394
|
-
'marshal_format'
|
395
|
-
|
391
|
+
'license_key' => license_key,
|
392
|
+
'run_id' => @agent_id,
|
393
|
+
'method' => method,
|
394
|
+
'marshal_format' => 'json' # Other formats are explicitly
|
395
|
+
# ruled out; see the initializer
|
396
396
|
}
|
397
397
|
|
398
398
|
uri = "/agent_listener/invoke_raw_method?"
|
399
|
-
uri << params.map do |k,v|
|
399
|
+
uri << params.map do |k, v|
|
400
400
|
next unless v
|
401
401
|
"#{k}=#{v}"
|
402
402
|
end.compact.join('&')
|
@@ -412,7 +412,7 @@ module NewRelic
|
|
412
412
|
# enough to be worth compressing, and handles any errors the
|
413
413
|
# server may return
|
414
414
|
def invoke_remote(method, payload = [], options = {})
|
415
|
-
start_ts =
|
415
|
+
start_ts = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
416
416
|
|
417
417
|
data, size, serialize_finish_ts, request_send_ts, response_check_ts = nil
|
418
418
|
begin
|
@@ -420,36 +420,29 @@ module NewRelic
|
|
420
420
|
rescue StandardError, SystemStackError => e
|
421
421
|
handle_serialization_error(method, e)
|
422
422
|
end
|
423
|
-
serialize_finish_ts =
|
423
|
+
serialize_finish_ts = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
424
424
|
|
425
425
|
data, encoding = compress_request_if_needed(data, method)
|
426
426
|
size = data.size
|
427
427
|
|
428
428
|
# Preconnect needs to always use the configured collector host, not the redirect host
|
429
|
-
#
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
endpoint_specific_collector = if method == :preconnect && (@configured_collector && @configured_collector.name != 'staging-collector.newrelic.com')
|
435
|
-
::NewRelic::Agent.logger.debug "Using configured collector for preconnect: #{@configured_collector}"
|
436
|
-
@configured_collector
|
437
|
-
else
|
438
|
-
::NewRelic::Agent.logger.debug "Using redirect host for collector: #{@collector}"
|
439
|
-
@collector
|
440
|
-
end
|
429
|
+
# We reset it here so we are always using the configured collector during our creation of the new connection
|
430
|
+
# and we also don't want to keep the previous redirect host around anymore
|
431
|
+
if method == :preconnect
|
432
|
+
@collector = @configured_collector
|
433
|
+
end
|
441
434
|
|
442
435
|
uri = remote_method_uri(method)
|
443
|
-
full_uri = "#{
|
436
|
+
full_uri = "#{@collector}#{uri}"
|
444
437
|
|
445
438
|
@audit_logger.log_request(full_uri, payload, @marshaller)
|
446
|
-
request_send_ts =
|
447
|
-
response = send_request(:data
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
response_check_ts =
|
439
|
+
request_send_ts = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
440
|
+
response = send_request(:data => data,
|
441
|
+
:uri => uri,
|
442
|
+
:encoding => encoding,
|
443
|
+
:collector => @collector,
|
444
|
+
:endpoint => method)
|
445
|
+
response_check_ts = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
453
446
|
@marshaller.load(decompress_response(response))
|
454
447
|
ensure
|
455
448
|
record_timing_supportability_metrics(method, start_ts, serialize_finish_ts, request_send_ts, response_check_ts)
|
@@ -469,7 +462,7 @@ module NewRelic
|
|
469
462
|
|
470
463
|
def record_timing_supportability_metrics(method, start_ts, serialize_finish_ts, request_send_ts, response_check_ts)
|
471
464
|
serialize_time = serialize_finish_ts && (serialize_finish_ts - start_ts)
|
472
|
-
request_duration = response_check_ts && (response_check_ts - request_send_ts)
|
465
|
+
request_duration = response_check_ts && (response_check_ts - request_send_ts)
|
473
466
|
if request_duration
|
474
467
|
NewRelic::Agent.record_metric("Supportability/Agent/Collector/#{method.to_s}/Duration", request_duration)
|
475
468
|
end
|
@@ -519,7 +512,7 @@ module NewRelic
|
|
519
512
|
def send_request(opts)
|
520
513
|
headers = {
|
521
514
|
'Content-Encoding' => opts[:encoding],
|
522
|
-
'Host'
|
515
|
+
'Host' => opts[:collector].name
|
523
516
|
}
|
524
517
|
headers.merge!(@request_headers_map) if @request_headers_map
|
525
518
|
|
@@ -533,10 +526,10 @@ module NewRelic
|
|
533
526
|
request.content_type = "application/octet-stream"
|
534
527
|
request.body = opts[:data]
|
535
528
|
|
536
|
-
response
|
537
|
-
attempts
|
529
|
+
response = nil
|
530
|
+
attempts = 0
|
538
531
|
max_attempts = 2
|
539
|
-
endpoint
|
532
|
+
endpoint = opts[:endpoint]
|
540
533
|
|
541
534
|
begin
|
542
535
|
attempts += 1
|
@@ -5,7 +5,6 @@
|
|
5
5
|
|
6
6
|
module NewRelic
|
7
7
|
module Agent
|
8
|
-
|
9
8
|
# This class is used for instrumentations that have exceptions or error classes
|
10
9
|
# not derived from Ruby's usual Exception or StandardError or in situations
|
11
10
|
# where we do not have such Exception object to work with.
|
@@ -17,6 +16,5 @@ module NewRelic
|
|
17
16
|
@message = message
|
18
17
|
end
|
19
18
|
end
|
20
|
-
|
21
19
|
end
|
22
20
|
end
|
@@ -8,9 +8,13 @@ module NewRelic
|
|
8
8
|
module Agent
|
9
9
|
class NullLogger
|
10
10
|
def fatal(*args); end
|
11
|
+
|
11
12
|
def error(*args); end
|
12
|
-
|
13
|
-
def
|
13
|
+
|
14
|
+
def warn(*args); end
|
15
|
+
|
16
|
+
def info(*args); end
|
17
|
+
|
14
18
|
def debug(*args); end
|
15
19
|
|
16
20
|
def method_missing(method, *args, &blk)
|
@@ -2,19 +2,18 @@
|
|
2
2
|
# This file is distributed under New Relic's license terms.
|
3
3
|
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
4
4
|
|
5
|
-
#require 'base64'
|
5
|
+
# require 'base64'
|
6
6
|
|
7
7
|
module NewRelic
|
8
8
|
module Agent
|
9
9
|
class Obfuscator
|
10
|
-
|
11
10
|
attr_reader :key_bytes
|
12
11
|
|
13
12
|
EMPTY_KEY_BYTES = [0]
|
14
13
|
PACK_FORMAT = 'm'
|
15
14
|
|
16
15
|
# RUM uses a shortened key, so just trim it up front
|
17
|
-
def initialize(key, length=nil)
|
16
|
+
def initialize(key, length = nil)
|
18
17
|
if key.nil? || key.empty?
|
19
18
|
@key_bytes = EMPTY_KEY_BYTES
|
20
19
|
else
|
@@ -24,26 +23,25 @@ module NewRelic
|
|
24
23
|
end
|
25
24
|
|
26
25
|
def obfuscate(text)
|
27
|
-
[
|
26
|
+
[encode(text)].pack(PACK_FORMAT).gsub(/\n/, '')
|
28
27
|
end
|
29
28
|
|
30
29
|
def deobfuscate(text)
|
31
|
-
encode(text.unpack(PACK_FORMAT).first
|
30
|
+
encode(text.unpack(PACK_FORMAT).first)
|
32
31
|
end
|
33
32
|
|
34
33
|
def encode(text)
|
35
34
|
return text unless key_bytes
|
36
35
|
|
37
36
|
encoded = ""
|
38
|
-
encoded.force_encoding('binary') if encoded.respond_to?(
|
37
|
+
encoded.force_encoding('binary') if encoded.respond_to?(:force_encoding)
|
39
38
|
index = 0
|
40
39
|
text.each_byte do |byte|
|
41
40
|
encoded.concat((byte ^ key_bytes[index % key_bytes.length]))
|
42
|
-
index+=1
|
41
|
+
index += 1
|
43
42
|
end
|
44
43
|
encoded
|
45
44
|
end
|
46
|
-
|
47
45
|
end
|
48
46
|
end
|
49
47
|
end
|
@@ -10,16 +10,14 @@ module NewRelic
|
|
10
10
|
ACTION_DISPATCH_PARAMETER_FILTER = "action_dispatch.parameter_filter".freeze
|
11
11
|
|
12
12
|
RAILS_FILTER_CLASS = if defined?(ActiveSupport::ParameterFilter)
|
13
|
-
|
13
|
+
ActiveSupport::ParameterFilter
|
14
14
|
elsif defined?(ActionDispatch::Http::ParameterFilter)
|
15
15
|
ActionDispatch::Http::ParameterFilter
|
16
|
-
else
|
17
|
-
nil
|
18
16
|
end
|
19
17
|
|
20
18
|
def apply_filters(env, params)
|
21
19
|
if filters = env[ACTION_DISPATCH_PARAMETER_FILTER]
|
22
|
-
params = filter_using_rails(params, filters)
|
20
|
+
params = filter_using_rails(params, filters)
|
23
21
|
end
|
24
22
|
params = filter_rack_file_data(env, params)
|
25
23
|
params
|
@@ -36,7 +34,7 @@ module NewRelic
|
|
36
34
|
content_type = env["CONTENT_TYPE"]
|
37
35
|
multipart = content_type && content_type.start_with?("multipart")
|
38
36
|
|
39
|
-
params.inject({}) do |memo, (k,v)|
|
37
|
+
params.inject({}) do |memo, (k, v)|
|
40
38
|
if multipart && v.is_a?(Hash) && v[:tempfile]
|
41
39
|
memo[k] = "[FILE]"
|
42
40
|
else
|
@@ -6,7 +6,6 @@
|
|
6
6
|
module NewRelic
|
7
7
|
module Agent
|
8
8
|
module PayloadMetricMapping
|
9
|
-
|
10
9
|
# this logic was extracted from TransactionEventAggregator for reuse by
|
11
10
|
# the ErrorEventAggregator
|
12
11
|
|
@@ -28,7 +27,7 @@ module NewRelic
|
|
28
27
|
|
29
28
|
private
|
30
29
|
|
31
|
-
def map_metric(metric_name, to_add={})
|
30
|
+
def map_metric(metric_name, to_add = {})
|
32
31
|
to_add.values.each(&:freeze)
|
33
32
|
|
34
33
|
mappings = SPEC_MAPPINGS.fetch(metric_name, {})
|
@@ -41,18 +40,18 @@ module NewRelic
|
|
41
40
|
# All Transactions
|
42
41
|
# Don't need to use the transaction-type specific metrics since this is
|
43
42
|
# scoped to just one transaction, so Datastore/all has what we want.
|
44
|
-
map_metric('Datastore/all',
|
45
|
-
map_metric('Datastore/all',
|
46
|
-
map_metric('GC/Transaction/all',
|
43
|
+
map_metric('Datastore/all', :total_call_time => 'databaseDuration')
|
44
|
+
map_metric('Datastore/all', :call_count => 'databaseCallCount')
|
45
|
+
map_metric('GC/Transaction/all', :total_call_time => 'gcCumulative')
|
47
46
|
|
48
47
|
# Web Metrics
|
49
48
|
map_metric('WebFrontend/QueueTime', :total_call_time => 'queueDuration')
|
50
|
-
map_metric('External/allWeb',
|
51
|
-
map_metric('External/allWeb',
|
49
|
+
map_metric('External/allWeb', :total_call_time => 'externalDuration')
|
50
|
+
map_metric('External/allWeb', :call_count => 'externalCallCount')
|
52
51
|
|
53
52
|
# Background Metrics
|
54
|
-
map_metric('External/allOther',
|
55
|
-
map_metric('External/allOther',
|
53
|
+
map_metric('External/allOther', :total_call_time => 'externalDuration')
|
54
|
+
map_metric('External/allOther', :call_count => 'externalCallCount')
|
56
55
|
end
|
57
56
|
end
|
58
57
|
end
|
@@ -6,7 +6,6 @@ require 'base64'
|
|
6
6
|
|
7
7
|
module NewRelic
|
8
8
|
module Agent
|
9
|
-
|
10
9
|
#--
|
11
10
|
# Manages the registering and servicing of pipes used by child
|
12
11
|
# processes to report data to their parent, rather than directly
|
@@ -67,7 +66,7 @@ module NewRelic
|
|
67
66
|
if defined?(::Encoding::ASCII_8BIT)
|
68
67
|
@in.set_encoding(::Encoding::ASCII_8BIT)
|
69
68
|
end
|
70
|
-
@last_read =
|
69
|
+
@last_read = Process.clock_gettime(Process::CLOCK_REALTIME)
|
71
70
|
@parent_pid = $$
|
72
71
|
end
|
73
72
|
|
@@ -92,7 +91,7 @@ module NewRelic
|
|
92
91
|
|
93
92
|
def read
|
94
93
|
@in.close unless @in.closed?
|
95
|
-
@last_read =
|
94
|
+
@last_read = Process.clock_gettime(Process::CLOCK_REALTIME)
|
96
95
|
length_bytes = @out.read(NUM_LENGTH_BYTES)
|
97
96
|
if length_bytes
|
98
97
|
message_length = deserialize_message_length(length_bytes)
|
@@ -128,7 +127,7 @@ module NewRelic
|
|
128
127
|
end
|
129
128
|
|
130
129
|
class Listener
|
131
|
-
attr_reader
|
130
|
+
attr_reader :thread
|
132
131
|
|
133
132
|
# This attr_accessor intentionally provides unsynchronized access to the
|
134
133
|
# @pipes hash. It is used to look up the write end of the pipe from
|
@@ -168,14 +167,18 @@ module NewRelic
|
|
168
167
|
clean_up_pipes
|
169
168
|
|
170
169
|
pipes_to_listen_to = @pipes_lock.synchronize do
|
171
|
-
@pipes.values.map{|pipe| pipe.out} + [wake.out]
|
170
|
+
@pipes.values.map { |pipe| pipe.out } + [wake.out]
|
172
171
|
end
|
173
172
|
|
174
|
-
|
175
|
-
(
|
173
|
+
if now
|
174
|
+
NewRelic::Agent.record_metric(
|
175
|
+
'Supportability/Listeners',
|
176
|
+
Process.clock_gettime(Process::CLOCK_REALTIME) - now
|
177
|
+
)
|
178
|
+
end
|
176
179
|
|
177
180
|
if ready = IO.select(pipes_to_listen_to, [], [], @select_timeout)
|
178
|
-
now =
|
181
|
+
now = Process.clock_gettime(Process::CLOCK_REALTIME)
|
179
182
|
|
180
183
|
ready_pipes = ready[0]
|
181
184
|
ready_pipes.each do |pipe|
|
@@ -251,23 +254,23 @@ module NewRelic
|
|
251
254
|
end
|
252
255
|
|
253
256
|
def should_keep_listening?
|
254
|
-
@started || @pipes_lock.synchronize { @pipes.values.find{|pipe| !pipe.in.closed?} }
|
257
|
+
@started || @pipes_lock.synchronize { @pipes.values.find { |pipe| !pipe.in.closed? } }
|
255
258
|
end
|
256
259
|
|
257
260
|
def clean_up_pipes
|
258
261
|
@pipes_lock.synchronize do
|
259
262
|
@pipes.values.each do |pipe|
|
260
|
-
if pipe.last_read
|
263
|
+
if pipe.last_read + @timeout < Process.clock_gettime(Process::CLOCK_REALTIME)
|
261
264
|
pipe.close unless pipe.closed?
|
262
265
|
end
|
263
266
|
end
|
264
|
-
@pipes.reject! {|id, pipe| pipe.out.closed? }
|
267
|
+
@pipes.reject! { |id, pipe| pipe.out.closed? }
|
265
268
|
end
|
266
269
|
end
|
267
270
|
|
268
271
|
def find_pipe_for_handle(out_handle)
|
269
272
|
@pipes_lock.synchronize do
|
270
|
-
@pipes.values.find{|pipe| pipe.out == out_handle }
|
273
|
+
@pipes.values.find { |pipe| pipe.out == out_handle }
|
271
274
|
end
|
272
275
|
end
|
273
276
|
end
|
@@ -11,7 +11,7 @@ module NewRelic
|
|
11
11
|
def initialize(channel_id)
|
12
12
|
@channel_id = channel_id
|
13
13
|
@collector = NewRelic::Control::Server.new(:name => 'parent',
|
14
|
-
|
14
|
+
:port => 0)
|
15
15
|
@pipe = NewRelic::Agent::PipeChannelManager.channels[@channel_id]
|
16
16
|
if @pipe && @pipe.parent_pid != $$
|
17
17
|
@pipe.after_fork_in_child
|
@@ -61,7 +61,7 @@ module NewRelic
|
|
61
61
|
write_to_pipe(:sql_trace_data, sql) if sql
|
62
62
|
end
|
63
63
|
|
64
|
-
def shutdown
|
64
|
+
def shutdown
|
65
65
|
@pipe.close if @pipe
|
66
66
|
end
|
67
67
|
|
@@ -15,12 +15,12 @@ module NewRelic
|
|
15
15
|
def initialize(capacity)
|
16
16
|
super
|
17
17
|
@captured_lifetime = 0
|
18
|
-
@seen_lifetime
|
18
|
+
@seen_lifetime = 0
|
19
19
|
end
|
20
20
|
|
21
21
|
def heapify_items_array
|
22
22
|
if @items.is_a?(Array)
|
23
|
-
@items = Heap.new(@items) { |x| priority_for(x) }
|
23
|
+
@items = Heap.new(@items) { |x| priority_for(x) }
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -38,8 +38,6 @@ module NewRelic
|
|
38
38
|
@items[0] = incoming
|
39
39
|
@items.fix(0)
|
40
40
|
incoming
|
41
|
-
else
|
42
|
-
nil
|
43
41
|
end
|
44
42
|
else
|
45
43
|
@items << (event || blk.call)
|
@@ -53,10 +51,10 @@ module NewRelic
|
|
53
51
|
def capacity=(new_capacity)
|
54
52
|
@capacity = new_capacity
|
55
53
|
old_items = @items.to_a
|
56
|
-
old_seen
|
54
|
+
old_seen = @seen
|
57
55
|
reset!
|
58
56
|
old_items.each { |i| append(event: i) }
|
59
|
-
@seen
|
57
|
+
@seen = old_seen
|
60
58
|
end
|
61
59
|
|
62
60
|
def to_a
|
@@ -92,4 +90,3 @@ module NewRelic
|
|
92
90
|
end
|
93
91
|
end
|
94
92
|
end
|
95
|
-
|
@@ -7,7 +7,7 @@ module NewRelic
|
|
7
7
|
class RulesEngine
|
8
8
|
class ReplacementRule
|
9
9
|
attr_reader(:terminate_chain, :each_segment, :ignore, :replace_all, :eval_order,
|
10
|
-
|
10
|
+
:match_expression, :replacement)
|
11
11
|
|
12
12
|
def initialize(options)
|
13
13
|
if !options['match_expression']
|
@@ -18,12 +18,12 @@ module NewRelic
|
|
18
18
|
end
|
19
19
|
|
20
20
|
@match_expression = Regexp.new(options['match_expression'], Regexp::IGNORECASE)
|
21
|
-
@replacement
|
22
|
-
@ignore
|
23
|
-
@eval_order
|
24
|
-
@replace_all
|
25
|
-
@each_segment
|
26
|
-
@terminate_chain
|
21
|
+
@replacement = options['replacement']
|
22
|
+
@ignore = options['ignore'] || false
|
23
|
+
@eval_order = options['eval_order'] || 0
|
24
|
+
@replace_all = options['replace_all'] || false
|
25
|
+
@each_segment = options['each_segment'] || false
|
26
|
+
@terminate_chain = options['terminate_chain'] || false
|
27
27
|
end
|
28
28
|
|
29
29
|
def terminal?
|
@@ -56,9 +56,9 @@ module NewRelic
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def apply_to_each_segment(string)
|
59
|
-
string
|
59
|
+
string = string.dup
|
60
60
|
leading_slash = string.slice!(LEADING_SLASH_REGEX)
|
61
|
-
segments
|
61
|
+
segments = string.split(SEGMENT_SEPARATOR)
|
62
62
|
|
63
63
|
segments.map! do |segment|
|
64
64
|
apply_replacement(segment)
|
@@ -6,19 +6,19 @@ module NewRelic
|
|
6
6
|
module Agent
|
7
7
|
class RulesEngine
|
8
8
|
class SegmentTermsRule
|
9
|
-
PREFIX_KEY
|
10
|
-
TERMS_KEY
|
11
|
-
SEGMENT_PLACEHOLDER
|
12
|
-
ADJACENT_PLACEHOLDERS_REGEX
|
9
|
+
PREFIX_KEY = 'prefix'.freeze
|
10
|
+
TERMS_KEY = 'terms'.freeze
|
11
|
+
SEGMENT_PLACEHOLDER = '*'.freeze
|
12
|
+
ADJACENT_PLACEHOLDERS_REGEX = %r{((?:^|/)\*)(?:/\*)*}.freeze
|
13
13
|
ADJACENT_PLACEHOLDERS_REPLACEMENT = '\1'.freeze
|
14
|
-
VALID_PREFIX_SEGMENT_COUNT
|
14
|
+
VALID_PREFIX_SEGMENT_COUNT = 2
|
15
15
|
|
16
16
|
attr_reader :prefix, :terms
|
17
17
|
|
18
18
|
def self.valid?(rule_spec)
|
19
19
|
rule_spec[PREFIX_KEY].kind_of?(String) &&
|
20
|
-
|
21
|
-
|
20
|
+
rule_spec[TERMS_KEY].kind_of?(Array) &&
|
21
|
+
valid_prefix_segment_count?(rule_spec[PREFIX_KEY])
|
22
22
|
end
|
23
23
|
|
24
24
|
def self.valid_prefix_segment_count?(prefix)
|
@@ -26,13 +26,13 @@ module NewRelic
|
|
26
26
|
rindex = prefix.rindex(SEGMENT_SEPARATOR)
|
27
27
|
|
28
28
|
(count == 2 && prefix[rindex + 1].nil?) ||
|
29
|
-
|
29
|
+
(count == 1 && !prefix[rindex + 1].nil?)
|
30
30
|
end
|
31
31
|
|
32
32
|
def initialize(options)
|
33
|
-
@prefix
|
34
|
-
@terms
|
35
|
-
@trim_range
|
33
|
+
@prefix = options[PREFIX_KEY]
|
34
|
+
@terms = options[TERMS_KEY]
|
35
|
+
@trim_range = (@prefix.size..-1)
|
36
36
|
end
|
37
37
|
|
38
38
|
def terminal?
|
@@ -50,7 +50,7 @@ module NewRelic
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def apply(string)
|
53
|
-
rest
|
53
|
+
rest = string[@trim_range]
|
54
54
|
leading_slash = rest.slice!(LEADING_SLASH_REGEX)
|
55
55
|
segments = rest.split(SEGMENT_SEPARATOR, -1)
|
56
56
|
segments.map! { |s| @terms.include?(s) ? s : SEGMENT_PLACEHOLDER }
|
@@ -24,7 +24,7 @@ module NewRelic
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def self.create_transaction_rules(connect_response)
|
27
|
-
txn_name_specs
|
27
|
+
txn_name_specs = connect_response['transaction_name_rules'] || []
|
28
28
|
segment_rule_specs = connect_response['transaction_segment_terms'] || []
|
29
29
|
|
30
30
|
txn_name_rules = txn_name_specs.map { |s| ReplacementRule.new(s) }
|
@@ -54,7 +54,7 @@ module NewRelic
|
|
54
54
|
rules.uniq! { |rule| rule.prefix }
|
55
55
|
end
|
56
56
|
|
57
|
-
def initialize(rules=[], segment_term_rules=[])
|
57
|
+
def initialize(rules = [], segment_term_rules = [])
|
58
58
|
@rules = rules.sort
|
59
59
|
@segment_term_rules = segment_term_rules
|
60
60
|
end
|
@@ -12,9 +12,8 @@
|
|
12
12
|
module NewRelic
|
13
13
|
module Agent
|
14
14
|
class Sampler
|
15
|
-
|
16
15
|
# Exception denotes a sampler is not available and it will not be registered.
|
17
|
-
class Unsupported < StandardError;
|
16
|
+
class Unsupported < StandardError; end
|
18
17
|
|
19
18
|
attr_reader :id
|
20
19
|
@sampler_classes = []
|
@@ -52,7 +51,7 @@ module NewRelic
|
|
52
51
|
# The ID passed in here is unused by our code, but is preserved in case
|
53
52
|
# we have clients who are defining their own subclasses of this class, and
|
54
53
|
# expecting to be able to call super with an ID.
|
55
|
-
def initialize(id=nil)
|
54
|
+
def initialize(id = nil)
|
56
55
|
@id = id || self.class.shorthand_name
|
57
56
|
end
|
58
57
|
|
@@ -17,7 +17,7 @@ module NewRelic
|
|
17
17
|
@samplers.each(&blk)
|
18
18
|
end
|
19
19
|
|
20
|
-
def clear
|
20
|
+
def clear
|
21
21
|
@samplers.clear
|
22
22
|
end
|
23
23
|
|
@@ -34,7 +34,6 @@ module NewRelic
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
|
38
37
|
def poll_samplers
|
39
38
|
@samplers.delete_if do |sampler|
|
40
39
|
begin
|
@@ -49,7 +48,7 @@ module NewRelic
|
|
49
48
|
|
50
49
|
def add_sampler(sampler_class)
|
51
50
|
supported = sampler_class.supported_on_this_platform?
|
52
|
-
enabled
|
51
|
+
enabled = sampler_class.enabled?
|
53
52
|
if supported && enabled
|
54
53
|
if !sampler_class_registered?(sampler_class)
|
55
54
|
sampler = sampler_class.new
|