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
@@ -10,8 +10,7 @@ module NewRelic
|
|
10
10
|
|
11
11
|
def initialize(channel_id)
|
12
12
|
@channel_id = channel_id
|
13
|
-
@collector = NewRelic::Control::Server.new(:
|
14
|
-
:port => 0)
|
13
|
+
@collector = NewRelic::Control::Server.new({name: 'parent', port: 0})
|
15
14
|
@pipe = NewRelic::Agent::PipeChannelManager.channels[@channel_id]
|
16
15
|
if @pipe && @pipe.parent_pid != $$
|
17
16
|
@pipe.after_fork_in_child
|
@@ -61,7 +60,11 @@ module NewRelic
|
|
61
60
|
write_to_pipe(:sql_trace_data, sql) if sql
|
62
61
|
end
|
63
62
|
|
64
|
-
def
|
63
|
+
def log_event_data(logs)
|
64
|
+
write_to_pipe(:log_event_data, logs) if logs
|
65
|
+
end
|
66
|
+
|
67
|
+
def shutdown
|
65
68
|
@pipe.close if @pipe
|
66
69
|
end
|
67
70
|
|
@@ -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
|
@@ -62,9 +62,12 @@ module NewRelic
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def poll
|
65
|
-
|
66
|
-
|
67
|
-
|
65
|
+
# Wrapping these queries within the same connection avoids deadlocks
|
66
|
+
ActiveRecord::Base.connection_pool.with_connection do
|
67
|
+
record_failed_jobs(failed_jobs)
|
68
|
+
record_locked_jobs(locked_jobs)
|
69
|
+
record_queue_length_metrics
|
70
|
+
end
|
68
71
|
end
|
69
72
|
|
70
73
|
private
|
@@ -97,11 +100,11 @@ module NewRelic
|
|
97
100
|
# here that's valid on 2.x through 4.1, so split it up.
|
98
101
|
result = if ::ActiveRecord::VERSION::MAJOR.to_i < 4
|
99
102
|
::Delayed::Job.count(:group => column_name,
|
100
|
-
|
103
|
+
:conditions => [QUEUE_QUERY_CONDITION, now])
|
101
104
|
else
|
102
|
-
::Delayed::Job.where(QUEUE_QUERY_CONDITION, now)
|
103
|
-
|
104
|
-
|
105
|
+
::Delayed::Job.where(QUEUE_QUERY_CONDITION, now)
|
106
|
+
.group(column_name)
|
107
|
+
.count
|
105
108
|
end
|
106
109
|
result.to_a
|
107
110
|
end
|
@@ -3,11 +3,11 @@
|
|
3
3
|
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
4
4
|
|
5
5
|
require 'new_relic/agent/sampler'
|
6
|
+
require 'new_relic/helper'
|
6
7
|
|
7
8
|
module NewRelic
|
8
9
|
module Agent
|
9
10
|
module Samplers
|
10
|
-
|
11
11
|
class MemorySampler < NewRelic::Agent::Sampler
|
12
12
|
named :memory
|
13
13
|
|
@@ -47,11 +47,16 @@ module NewRelic
|
|
47
47
|
|
48
48
|
def self.platform
|
49
49
|
if RUBY_PLATFORM =~ /java/
|
50
|
-
|
50
|
+
begin
|
51
|
+
NewRelic::Helper.run_command('uname -s').downcase
|
52
|
+
rescue NewRelic::CommandRunFailedError, NewRelic::CommandExecutableNotFoundError
|
53
|
+
'unknown'
|
54
|
+
end
|
51
55
|
else
|
52
56
|
RUBY_PLATFORM.downcase
|
53
57
|
end
|
54
58
|
end
|
59
|
+
|
55
60
|
def platform
|
56
61
|
NewRelic::Agent::Samplers::MemorySampler.platform
|
57
62
|
end
|
@@ -118,6 +123,7 @@ module NewRelic
|
|
118
123
|
raise "Faulty command: `#{@command} #{process}`" if memory.nil? || memory <= 0
|
119
124
|
memory
|
120
125
|
end
|
126
|
+
|
121
127
|
def to_s
|
122
128
|
"shell command sampler: #{@command}"
|
123
129
|
end
|
@@ -130,7 +136,7 @@ module NewRelic
|
|
130
136
|
class ProcStatus < Base
|
131
137
|
# Returns the amount of resident memory this process is using in MB
|
132
138
|
def get_memory
|
133
|
-
proc_status = File.open(proc_status_file, "r") {|f| f.read_nonblock(4096).strip }
|
139
|
+
proc_status = File.open(proc_status_file, "r") { |f| f.read_nonblock(4096).strip }
|
134
140
|
if proc_status =~ /RSS:\s*(\d+) kB/i
|
135
141
|
return $1.to_f / 1024.0
|
136
142
|
end
|
@@ -9,14 +9,14 @@ module NewRelic
|
|
9
9
|
module Agent
|
10
10
|
module Samplers
|
11
11
|
class VMSampler < Sampler
|
12
|
-
GC_RUNS_METRIC
|
13
|
-
HEAP_LIVE_METRIC
|
14
|
-
HEAP_FREE_METRIC
|
15
|
-
THREAD_COUNT_METRIC
|
16
|
-
OBJECT_ALLOCATIONS_METRIC
|
17
|
-
MAJOR_GC_METRIC
|
18
|
-
MINOR_GC_METRIC
|
19
|
-
METHOD_INVALIDATIONS_METRIC
|
12
|
+
GC_RUNS_METRIC = 'RubyVM/GC/runs'.freeze
|
13
|
+
HEAP_LIVE_METRIC = 'RubyVM/GC/heap_live'.freeze
|
14
|
+
HEAP_FREE_METRIC = 'RubyVM/GC/heap_free'.freeze
|
15
|
+
THREAD_COUNT_METRIC = 'RubyVM/Threads/all'.freeze
|
16
|
+
OBJECT_ALLOCATIONS_METRIC = 'RubyVM/GC/total_allocated_object'.freeze
|
17
|
+
MAJOR_GC_METRIC = 'RubyVM/GC/major_gc_count'.freeze
|
18
|
+
MINOR_GC_METRIC = 'RubyVM/GC/minor_gc_count'.freeze
|
19
|
+
METHOD_INVALIDATIONS_METRIC = 'RubyVM/CacheInvalidations/method'.freeze
|
20
20
|
CONSTANT_INVALIDATIONS_METRIC = 'RubyVM/CacheInvalidations/constant'.freeze
|
21
21
|
|
22
22
|
attr_reader :transaction_count
|
@@ -49,7 +49,7 @@ module NewRelic
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
def record_gc_runs_metric(snapshot, txn_count) #THREAD_LOCAL_ACCESS
|
52
|
+
def record_gc_runs_metric(snapshot, txn_count) # THREAD_LOCAL_ACCESS
|
53
53
|
if snapshot.gc_total_time || snapshot.gc_runs
|
54
54
|
if snapshot.gc_total_time
|
55
55
|
gc_time = snapshot.gc_total_time - @last_snapshot.gc_total_time.to_f
|
@@ -59,30 +59,30 @@ module NewRelic
|
|
59
59
|
end
|
60
60
|
wall_clock_time = snapshot.taken_at - @last_snapshot.taken_at
|
61
61
|
NewRelic::Agent.agent.stats_engine.tl_record_unscoped_metrics(GC_RUNS_METRIC) do |stats|
|
62
|
-
stats.call_count
|
63
|
-
stats.total_call_time
|
62
|
+
stats.call_count += txn_count
|
63
|
+
stats.total_call_time += gc_runs if gc_runs
|
64
64
|
stats.total_exclusive_time += gc_time if gc_time
|
65
|
-
stats.max_call_time
|
66
|
-
stats.sum_of_squares
|
65
|
+
stats.max_call_time = (gc_time.nil? ? 0 : 1)
|
66
|
+
stats.sum_of_squares += wall_clock_time
|
67
67
|
end
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
def record_delta(snapshot, key, metric, txn_count) #THREAD_LOCAL_ACCESS
|
71
|
+
def record_delta(snapshot, key, metric, txn_count) # THREAD_LOCAL_ACCESS
|
72
72
|
value = snapshot.send(key)
|
73
73
|
if value
|
74
74
|
delta = value - @last_snapshot.send(key)
|
75
75
|
NewRelic::Agent.agent.stats_engine.tl_record_unscoped_metrics(metric) do |stats|
|
76
|
-
stats.call_count
|
76
|
+
stats.call_count += txn_count
|
77
77
|
stats.total_call_time += delta
|
78
78
|
end
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
-
def record_gauge_metric(metric_name, value) #THREAD_LOCAL_ACCESS
|
82
|
+
def record_gauge_metric(metric_name, value) # THREAD_LOCAL_ACCESS
|
83
83
|
NewRelic::Agent.agent.stats_engine.tl_record_unscoped_metrics(metric_name) do |stats|
|
84
|
-
stats.call_count
|
85
|
-
stats.sum_of_squares
|
84
|
+
stats.call_count = value
|
85
|
+
stats.sum_of_squares = 1
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
@@ -2,8 +2,8 @@
|
|
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 'newrelic_rpm' unless defined?(
|
6
|
-
require 'new_relic/agent' unless defined?(
|
5
|
+
require 'newrelic_rpm' unless defined?(NewRelic)
|
6
|
+
require 'new_relic/agent' unless defined?(NewRelic::Agent)
|
7
7
|
require 'new_relic/agent/event_aggregator'
|
8
8
|
require 'new_relic/agent/priority_sampled_buffer'
|
9
9
|
|
@@ -14,10 +14,10 @@ module NewRelic
|
|
14
14
|
capacity_key :'span_events.max_samples_stored'
|
15
15
|
|
16
16
|
enabled_keys :'span_events.enabled',
|
17
|
-
|
17
|
+
:'distributed_tracing.enabled'
|
18
18
|
|
19
|
-
def record
|
20
|
-
unless
|
19
|
+
def record(priority: nil, event: nil, &blk)
|
20
|
+
unless event || priority && blk
|
21
21
|
raise ArgumentError, "Expected priority and block, or event"
|
22
22
|
end
|
23
23
|
|
@@ -31,16 +31,16 @@ module NewRelic
|
|
31
31
|
|
32
32
|
SUPPORTABILITY_TOTAL_SEEN = "Supportability/SpanEvent/TotalEventsSeen".freeze
|
33
33
|
SUPPORTABILITY_TOTAL_SENT = "Supportability/SpanEvent/TotalEventsSent".freeze
|
34
|
-
SUPPORTABILITY_DISCARDED
|
34
|
+
SUPPORTABILITY_DISCARDED = "Supportability/SpanEvent/Discarded".freeze
|
35
35
|
|
36
|
-
def after_harvest
|
37
|
-
seen
|
38
|
-
sent
|
36
|
+
def after_harvest(metadata)
|
37
|
+
seen = metadata[:seen]
|
38
|
+
sent = metadata[:captured]
|
39
39
|
discarded = seen - sent
|
40
40
|
|
41
41
|
::NewRelic::Agent.record_metric(SUPPORTABILITY_TOTAL_SEEN, count: seen)
|
42
42
|
::NewRelic::Agent.record_metric(SUPPORTABILITY_TOTAL_SENT, count: sent)
|
43
|
-
::NewRelic::Agent.record_metric(SUPPORTABILITY_DISCARDED,
|
43
|
+
::NewRelic::Agent.record_metric(SUPPORTABILITY_DISCARDED, count: discarded)
|
44
44
|
|
45
45
|
super
|
46
46
|
end
|
@@ -16,39 +16,39 @@ module NewRelic
|
|
16
16
|
extend self
|
17
17
|
|
18
18
|
# Strings for static keys of the event structure
|
19
|
-
ELLIPSIS
|
20
|
-
TYPE_KEY
|
21
|
-
TRACE_ID_KEY
|
22
|
-
GUID_KEY
|
23
|
-
PARENT_ID_KEY
|
24
|
-
GRANDPARENT_ID_KEY
|
25
|
-
TRANSACTION_ID_KEY
|
26
|
-
SAMPLED_KEY
|
27
|
-
PRIORITY_KEY
|
28
|
-
TIMESTAMP_KEY
|
29
|
-
DURATION_KEY
|
30
|
-
NAME_KEY
|
31
|
-
CATEGORY_KEY
|
32
|
-
HTTP_URL_KEY
|
33
|
-
HTTP_METHOD_KEY
|
19
|
+
ELLIPSIS = '...'
|
20
|
+
TYPE_KEY = 'type'
|
21
|
+
TRACE_ID_KEY = 'traceId'
|
22
|
+
GUID_KEY = 'guid'
|
23
|
+
PARENT_ID_KEY = 'parentId'
|
24
|
+
GRANDPARENT_ID_KEY = 'grandparentId'
|
25
|
+
TRANSACTION_ID_KEY = 'transactionId'
|
26
|
+
SAMPLED_KEY = 'sampled'
|
27
|
+
PRIORITY_KEY = 'priority'
|
28
|
+
TIMESTAMP_KEY = 'timestamp'
|
29
|
+
DURATION_KEY = 'duration'
|
30
|
+
NAME_KEY = 'name'
|
31
|
+
CATEGORY_KEY = 'category'
|
32
|
+
HTTP_URL_KEY = 'http.url'
|
33
|
+
HTTP_METHOD_KEY = 'http.method'
|
34
34
|
HTTP_STATUS_CODE_KEY = 'http.statusCode'
|
35
|
-
COMPONENT_KEY
|
36
|
-
DB_INSTANCE_KEY
|
37
|
-
DB_STATEMENT_KEY
|
38
|
-
PEER_ADDRESS_KEY
|
39
|
-
PEER_HOSTNAME_KEY
|
40
|
-
SPAN_KIND_KEY
|
41
|
-
ENTRY_POINT_KEY
|
42
|
-
TRUSTED_PARENT_KEY
|
43
|
-
TRACING_VENDORS_KEY
|
35
|
+
COMPONENT_KEY = 'component'
|
36
|
+
DB_INSTANCE_KEY = 'db.instance'
|
37
|
+
DB_STATEMENT_KEY = 'db.statement'
|
38
|
+
PEER_ADDRESS_KEY = 'peer.address'
|
39
|
+
PEER_HOSTNAME_KEY = 'peer.hostname'
|
40
|
+
SPAN_KIND_KEY = 'span.kind'
|
41
|
+
ENTRY_POINT_KEY = 'nr.entryPoint'
|
42
|
+
TRUSTED_PARENT_KEY = "trustedParentId"
|
43
|
+
TRACING_VENDORS_KEY = "tracingVendors"
|
44
44
|
TRANSACTION_NAME_KEY = 'transaction.name'
|
45
45
|
|
46
46
|
# Strings for static values of the event structure
|
47
|
-
EVENT_TYPE
|
48
|
-
GENERIC_CATEGORY
|
49
|
-
HTTP_CATEGORY
|
47
|
+
EVENT_TYPE = 'Span'
|
48
|
+
GENERIC_CATEGORY = 'generic'
|
49
|
+
HTTP_CATEGORY = 'http'
|
50
50
|
DATASTORE_CATEGORY = 'datastore'
|
51
|
-
CLIENT
|
51
|
+
CLIENT = 'client'
|
52
52
|
|
53
53
|
# Builds a Hash of error attributes as well as the Span ID when
|
54
54
|
# an error is present. Otherwise, returns nil when no error present.
|
@@ -68,11 +68,11 @@ module NewRelic
|
|
68
68
|
def for_external_request_segment segment
|
69
69
|
intrinsics = intrinsics_for(segment)
|
70
70
|
|
71
|
-
intrinsics[COMPONENT_KEY]
|
71
|
+
intrinsics[COMPONENT_KEY] = segment.library
|
72
72
|
intrinsics[HTTP_METHOD_KEY] = segment.procedure
|
73
73
|
intrinsics[HTTP_STATUS_CODE_KEY] = segment.http_status_code if segment.http_status_code
|
74
|
-
intrinsics[CATEGORY_KEY]
|
75
|
-
intrinsics[SPAN_KIND_KEY]
|
74
|
+
intrinsics[CATEGORY_KEY] = HTTP_CATEGORY
|
75
|
+
intrinsics[SPAN_KIND_KEY] = CLIENT
|
76
76
|
|
77
77
|
agent_attributes = error_attributes(segment) || {}
|
78
78
|
|
@@ -115,14 +115,14 @@ module NewRelic
|
|
115
115
|
|
116
116
|
def intrinsics_for segment
|
117
117
|
intrinsics = {
|
118
|
-
TYPE_KEY
|
119
|
-
TRACE_ID_KEY
|
120
|
-
GUID_KEY
|
118
|
+
TYPE_KEY => EVENT_TYPE,
|
119
|
+
TRACE_ID_KEY => segment.transaction.trace_id,
|
120
|
+
GUID_KEY => segment.guid,
|
121
121
|
TRANSACTION_ID_KEY => segment.transaction.guid,
|
122
|
-
PRIORITY_KEY
|
123
|
-
TIMESTAMP_KEY
|
124
|
-
DURATION_KEY
|
125
|
-
NAME_KEY
|
122
|
+
PRIORITY_KEY => segment.transaction.priority,
|
123
|
+
TIMESTAMP_KEY => milliseconds_since_epoch(segment),
|
124
|
+
DURATION_KEY => segment.duration,
|
125
|
+
NAME_KEY => segment.name
|
126
126
|
}
|
127
127
|
|
128
128
|
# with infinite-tracing, transactions may or may not be sampled!
|
@@ -165,18 +165,21 @@ module NewRelic
|
|
165
165
|
end
|
166
166
|
end
|
167
167
|
|
168
|
-
def
|
169
|
-
return
|
170
|
-
return
|
171
|
-
|
168
|
+
def merge_hashes(hash1, hash2)
|
169
|
+
return hash1 if hash2.nil? || hash2.empty?
|
170
|
+
return hash2 if hash1.nil? || hash1.empty?
|
171
|
+
|
172
|
+
hash1.merge!(hash2)
|
172
173
|
end
|
173
174
|
|
174
175
|
def agent_attributes segment
|
175
176
|
agent_attributes = segment.attributes
|
176
177
|
.agent_attributes_for(NewRelic::Agent::AttributeFilter::DST_SPAN_EVENTS)
|
177
178
|
error_attributes = error_attributes(segment)
|
178
|
-
|
179
|
-
|
179
|
+
code_attributes = segment.code_attributes
|
180
|
+
agent_attributes = merge_hashes(agent_attributes, error_attributes)
|
181
|
+
agent_attributes = merge_hashes(agent_attributes, code_attributes)
|
182
|
+
agent_attributes.freeze
|
180
183
|
end
|
181
184
|
|
182
185
|
def parent_guid segment
|
@@ -191,7 +194,7 @@ module NewRelic
|
|
191
194
|
Integer(segment.start_time.to_f * 1000.0)
|
192
195
|
end
|
193
196
|
|
194
|
-
def truncate value, max_size=255
|
197
|
+
def truncate value, max_size = 255
|
195
198
|
value = value.to_s
|
196
199
|
if value.bytesize > max_size
|
197
200
|
value.byteslice(0, max_size - 2).chop! << ELLIPSIS
|
@@ -46,7 +46,7 @@ module NewRelic
|
|
46
46
|
NewRelic::Agent::Database.should_record_sql?(:slow_sql)
|
47
47
|
end
|
48
48
|
|
49
|
-
def on_start_transaction(state,
|
49
|
+
def on_start_transaction(state, uri = nil)
|
50
50
|
return unless enabled?
|
51
51
|
|
52
52
|
state.sql_sampler_transaction_data = TransactionSqlData.new
|
@@ -83,7 +83,7 @@ module NewRelic
|
|
83
83
|
# this should always be called under the @samples_lock
|
84
84
|
def save_slow_sql(transaction_sql_data)
|
85
85
|
path = transaction_sql_data.path
|
86
|
-
uri
|
86
|
+
uri = transaction_sql_data.uri
|
87
87
|
|
88
88
|
transaction_sql_data.sql_data.each do |sql_item|
|
89
89
|
normalized_sql = sql_item.normalize
|
@@ -140,7 +140,7 @@ module NewRelic
|
|
140
140
|
# @api public
|
141
141
|
# @deprecated Use {Datastores.notice_sql} instead.
|
142
142
|
#
|
143
|
-
def notice_sql(sql, metric_name, config, duration, state=nil, explainer=nil, binds=nil, name=nil) #THREAD_LOCAL_ACCESS sometimes
|
143
|
+
def notice_sql(sql, metric_name, config, duration, state = nil, explainer = nil, binds = nil, name = nil) # THREAD_LOCAL_ACCESS sometimes
|
144
144
|
state ||= Tracer.state
|
145
145
|
data = state.sql_sampler_transaction_data
|
146
146
|
return unless data
|
@@ -203,7 +203,7 @@ module NewRelic
|
|
203
203
|
slowest = @sql_traces.values
|
204
204
|
@sql_traces = {}
|
205
205
|
end
|
206
|
-
slowest.each {|trace| trace.prepare_to_send }
|
206
|
+
slowest.each { |trace| trace.prepare_to_send }
|
207
207
|
slowest
|
208
208
|
end
|
209
209
|
|
@@ -240,7 +240,7 @@ module NewRelic
|
|
240
240
|
attr_reader :duration
|
241
241
|
attr_reader :backtrace
|
242
242
|
|
243
|
-
def initialize(statement, metric_name, duration, backtrace=nil, params=nil)
|
243
|
+
def initialize(statement, metric_name, duration, backtrace = nil, params = nil)
|
244
244
|
@statement = statement
|
245
245
|
@metric_name = metric_name
|
246
246
|
@duration = duration
|
@@ -342,7 +342,7 @@ module NewRelic
|
|
342
342
|
include NewRelic::Coerce
|
343
343
|
|
344
344
|
def to_collector_array(encoder)
|
345
|
-
[
|
345
|
+
[string(@path),
|
346
346
|
string(@url),
|
347
347
|
int(@sql_id),
|
348
348
|
string(@sql),
|
@@ -351,7 +351,7 @@ module NewRelic
|
|
351
351
|
Helper.time_to_millis(@total_call_time),
|
352
352
|
Helper.time_to_millis(@min_call_time),
|
353
353
|
Helper.time_to_millis(@max_call_time),
|
354
|
-
encoder.encode(@params)
|
354
|
+
encoder.encode(@params)]
|
355
355
|
end
|
356
356
|
|
357
357
|
private
|
@@ -359,10 +359,10 @@ module NewRelic
|
|
359
359
|
# need to hash the same way in every process, to be able to aggregate slow SQL traces
|
360
360
|
def consistent_hash(string)
|
361
361
|
if NewRelic::Agent.config[:'slow_sql.use_longer_sql_id']
|
362
|
-
Digest::
|
362
|
+
Digest::SHA1.hexdigest(string).hex.modulo(2**63 - 1)
|
363
363
|
else
|
364
364
|
# from when sql_id needed to fit in an INT(11)
|
365
|
-
Digest::
|
365
|
+
Digest::SHA1.hexdigest(string).hex.modulo(2**31 - 1)
|
366
366
|
end
|
367
367
|
end
|
368
368
|
end
|