newrelic_rpm 8.15.0 → 9.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.build_ignore +26 -0
- data/CHANGELOG.md +538 -44
- data/CONTRIBUTING.md +1 -1
- data/Gemfile +1 -1
- data/README.md +11 -6
- data/Rakefile +9 -9
- data/Thorfile +1 -1
- data/bin/newrelic +1 -0
- data/bin/newrelic_cmd +1 -0
- data/bin/nrdebug +36 -36
- data/init.rb +1 -1
- data/lib/new_relic/agent/agent.rb +3 -16
- data/lib/new_relic/agent/agent_helpers/connect.rb +5 -10
- data/lib/new_relic/agent/agent_helpers/harvest.rb +4 -4
- data/lib/new_relic/agent/agent_helpers/shutdown.rb +5 -5
- data/lib/new_relic/agent/agent_helpers/special_startup.rb +3 -4
- data/lib/new_relic/agent/agent_helpers/start_worker_thread.rb +47 -39
- data/lib/new_relic/agent/agent_helpers/startup.rb +13 -13
- data/lib/new_relic/agent/agent_helpers/transmit.rb +6 -6
- data/lib/new_relic/agent/agent_logger.rb +9 -9
- data/lib/new_relic/agent/attribute_filter.rb +2 -4
- data/lib/new_relic/agent/attribute_pre_filtering.rb +109 -0
- data/lib/new_relic/agent/attribute_processing.rb +2 -2
- data/lib/new_relic/agent/audit_logger.rb +5 -5
- data/lib/new_relic/agent/autostart.rb +1 -1
- data/lib/new_relic/agent/commands/agent_command.rb +2 -2
- data/lib/new_relic/agent/commands/agent_command_router.rb +5 -4
- data/lib/new_relic/agent/commands/thread_profiler_session.rb +8 -8
- data/lib/new_relic/agent/configuration/default_source.rb +428 -586
- data/lib/new_relic/agent/configuration/environment_source.rb +2 -2
- data/lib/new_relic/agent/configuration/high_security_source.rb +3 -5
- data/lib/new_relic/agent/configuration/manager.rb +16 -2
- data/lib/new_relic/agent/configuration/security_policy_source.rb +10 -26
- data/lib/new_relic/agent/configuration/server_source.rb +24 -24
- data/lib/new_relic/agent/configuration/yaml_source.rb +17 -4
- data/lib/new_relic/agent/connect/request_builder.rb +1 -1
- data/lib/new_relic/agent/connect/response_handler.rb +1 -1
- data/lib/new_relic/agent/custom_event_aggregator.rb +4 -4
- data/lib/new_relic/agent/database/explain_plan_helpers.rb +1 -1
- data/lib/new_relic/agent/database/obfuscation_helpers.rb +2 -2
- data/lib/new_relic/agent/database/obfuscator.rb +2 -2
- data/lib/new_relic/agent/database.rb +4 -18
- data/lib/new_relic/agent/datastores/metric_helper.rb +5 -5
- data/lib/new_relic/agent/datastores/mongo/metric_translator.rb +11 -11
- data/lib/new_relic/agent/datastores/redis.rb +6 -6
- data/lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb +8 -10
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_attributes.rb +10 -10
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_metrics.rb +7 -7
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb +1 -1
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_transport_type.rb +6 -6
- data/lib/new_relic/agent/distributed_tracing/trace_context.rb +7 -7
- data/lib/new_relic/agent/distributed_tracing/trace_context_payload.rb +4 -4
- data/lib/new_relic/agent/distributed_tracing.rb +6 -6
- data/lib/new_relic/agent/error_collector.rb +36 -8
- data/lib/new_relic/agent/error_filter.rb +5 -5
- data/lib/new_relic/agent/error_trace_aggregator.rb +5 -4
- data/lib/new_relic/agent/event_loop.rb +3 -3
- data/lib/new_relic/agent/external.rb +1 -1
- data/lib/new_relic/agent/harvester.rb +1 -3
- data/lib/new_relic/agent/heap.rb +2 -1
- data/lib/new_relic/agent/hostname.rb +1 -1
- data/lib/new_relic/agent/http_clients/abstract.rb +9 -21
- data/lib/new_relic/agent/http_clients/async_http_wrappers.rb +83 -0
- data/lib/new_relic/agent/http_clients/curb_wrappers.rb +7 -3
- data/lib/new_relic/agent/http_clients/ethon_wrappers.rb +111 -0
- data/lib/new_relic/agent/http_clients/excon_wrappers.rb +7 -5
- data/lib/new_relic/agent/http_clients/http_rb_wrappers.rb +4 -0
- data/lib/new_relic/agent/http_clients/httpclient_wrappers.rb +6 -2
- data/lib/new_relic/agent/http_clients/httpx_wrappers.rb +93 -0
- data/lib/new_relic/agent/http_clients/net_http_wrappers.rb +5 -1
- data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +8 -5
- data/lib/new_relic/agent/http_clients/uri_util.rb +2 -2
- data/lib/new_relic/agent/instrumentation/action_cable_subscriber.rb +6 -19
- data/lib/new_relic/agent/instrumentation/action_controller_other_subscriber.rb +42 -0
- data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +3 -2
- data/lib/new_relic/agent/instrumentation/action_dispatch.rb +31 -0
- data/lib/new_relic/agent/instrumentation/action_dispatch_subscriber.rb +64 -0
- data/lib/new_relic/agent/instrumentation/action_mailbox.rb +30 -0
- data/lib/new_relic/agent/instrumentation/action_mailbox_subscriber.rb +33 -0
- data/lib/new_relic/agent/instrumentation/action_mailer.rb +30 -0
- data/lib/new_relic/agent/instrumentation/action_mailer_subscriber.rb +85 -0
- data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +10 -10
- data/lib/new_relic/agent/instrumentation/active_job.rb +16 -3
- data/lib/new_relic/agent/instrumentation/active_job_subscriber.rb +41 -0
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +3 -3
- data/lib/new_relic/agent/instrumentation/active_record.rb +4 -3
- data/lib/new_relic/agent/instrumentation/active_record_helper.rb +38 -36
- data/lib/new_relic/agent/instrumentation/active_record_notifications.rb +5 -4
- data/lib/new_relic/agent/instrumentation/active_record_prepend.rb +2 -2
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +3 -2
- data/lib/new_relic/agent/instrumentation/active_storage.rb +4 -0
- data/lib/new_relic/agent/instrumentation/active_storage_subscriber.rb +2 -30
- data/lib/new_relic/agent/instrumentation/active_support.rb +21 -6
- data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/chain.rb +69 -0
- data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/instrumentation.rb +13 -0
- data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/prepend.rb +37 -0
- data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger.rb +23 -0
- data/lib/new_relic/agent/instrumentation/active_support_logger/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/active_support_logger.rb +3 -1
- data/lib/new_relic/agent/instrumentation/active_support_subscriber.rb +41 -0
- data/lib/new_relic/agent/instrumentation/async_http/chain.rb +23 -0
- data/lib/new_relic/agent/instrumentation/async_http/instrumentation.rb +37 -0
- data/lib/new_relic/agent/instrumentation/async_http/prepend.rb +15 -0
- data/lib/new_relic/agent/instrumentation/async_http.rb +26 -0
- data/lib/new_relic/agent/instrumentation/bunny/chain.rb +1 -1
- data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +12 -3
- data/lib/new_relic/agent/instrumentation/bunny.rb +1 -1
- data/lib/new_relic/agent/instrumentation/concurrent_ruby/chain.rb +1 -1
- data/lib/new_relic/agent/instrumentation/concurrent_ruby/instrumentation.rb +3 -4
- data/lib/new_relic/agent/instrumentation/concurrent_ruby/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +7 -6
- data/lib/new_relic/agent/instrumentation/curb/chain.rb +1 -1
- data/lib/new_relic/agent/instrumentation/curb/instrumentation.rb +9 -5
- data/lib/new_relic/agent/instrumentation/curb.rb +1 -1
- data/lib/new_relic/agent/instrumentation/custom_events.rb +12 -0
- data/lib/new_relic/agent/instrumentation/custom_events_subscriber.rb +2 -1
- data/lib/new_relic/agent/instrumentation/delayed_job/chain.rb +1 -0
- data/lib/new_relic/agent/instrumentation/delayed_job/instrumentation.rb +4 -1
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +2 -1
- data/lib/new_relic/agent/instrumentation/elasticsearch/chain.rb +2 -2
- data/lib/new_relic/agent/instrumentation/elasticsearch/instrumentation.rb +8 -4
- data/lib/new_relic/agent/instrumentation/elasticsearch.rb +2 -2
- data/lib/new_relic/agent/instrumentation/ethon/chain.rb +39 -0
- data/lib/new_relic/agent/instrumentation/ethon/instrumentation.rb +105 -0
- data/lib/new_relic/agent/instrumentation/ethon/prepend.rb +35 -0
- data/lib/new_relic/agent/instrumentation/ethon.rb +39 -0
- data/lib/new_relic/agent/instrumentation/excon/middleware.rb +5 -1
- data/lib/new_relic/agent/instrumentation/excon.rb +3 -3
- data/lib/new_relic/agent/instrumentation/fiber/chain.rb +27 -0
- data/lib/new_relic/agent/instrumentation/fiber/instrumentation.rb +23 -0
- data/lib/new_relic/agent/instrumentation/fiber/prepend.rb +25 -0
- data/lib/new_relic/agent/instrumentation/fiber.rb +25 -0
- data/lib/new_relic/agent/instrumentation/grape/instrumentation.rb +8 -4
- data/lib/new_relic/agent/instrumentation/grape.rb +4 -4
- data/lib/new_relic/agent/instrumentation/grpc/client/chain.rb +1 -1
- data/lib/new_relic/agent/instrumentation/grpc/client/instrumentation.rb +7 -2
- data/lib/new_relic/agent/instrumentation/grpc/client/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/grpc/client/request_wrapper.rb +1 -1
- data/lib/new_relic/agent/instrumentation/grpc/server/instrumentation.rb +8 -4
- data/lib/new_relic/agent/instrumentation/grpc_client.rb +2 -2
- data/lib/new_relic/agent/instrumentation/grpc_server.rb +2 -2
- data/lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/httprb/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/httprb.rb +1 -1
- data/lib/new_relic/agent/instrumentation/httpx/chain.rb +20 -0
- data/lib/new_relic/agent/instrumentation/httpx/instrumentation.rb +51 -0
- data/lib/new_relic/agent/instrumentation/httpx/prepend.rb +15 -0
- data/lib/new_relic/agent/instrumentation/httpx.rb +27 -0
- data/lib/new_relic/agent/instrumentation/ignore_actions.rb +1 -1
- data/lib/new_relic/agent/instrumentation/logger/instrumentation.rb +3 -0
- data/lib/new_relic/agent/instrumentation/logger.rb +1 -1
- data/lib/new_relic/agent/instrumentation/memcache/dalli.rb +3 -1
- data/lib/new_relic/agent/instrumentation/memcache/instrumentation.rb +14 -5
- data/lib/new_relic/agent/instrumentation/memcache/prepend.rb +3 -1
- data/lib/new_relic/agent/instrumentation/memcache.rb +12 -12
- data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +3 -3
- data/lib/new_relic/agent/instrumentation/middleware_tracing.rb +1 -1
- data/lib/new_relic/agent/instrumentation/mongodb_command_subscriber.rb +6 -8
- data/lib/new_relic/agent/instrumentation/net_http/instrumentation.rb +5 -1
- data/lib/new_relic/agent/instrumentation/net_http.rb +2 -2
- data/lib/new_relic/agent/instrumentation/notifications_subscriber.rb +46 -1
- data/lib/new_relic/agent/instrumentation/padrino/instrumentation.rb +7 -3
- data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +2 -2
- data/lib/new_relic/agent/instrumentation/queue_time.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rack/instrumentation.rb +7 -1
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +7 -2
- data/lib/new_relic/agent/instrumentation/rails_middleware.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rails_notifications/action_cable.rb +4 -4
- data/lib/new_relic/agent/instrumentation/rails_notifications/action_controller.rb +14 -1
- data/lib/new_relic/agent/instrumentation/rake/instrumentation.rb +12 -15
- data/lib/new_relic/agent/instrumentation/rake.rb +3 -3
- data/lib/new_relic/agent/instrumentation/redis/constants.rb +1 -1
- data/lib/new_relic/agent/instrumentation/redis/instrumentation.rb +6 -1
- data/lib/new_relic/agent/instrumentation/redis.rb +1 -1
- data/lib/new_relic/agent/instrumentation/resque/helper.rb +1 -1
- data/lib/new_relic/agent/instrumentation/resque/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/resque.rb +1 -1
- data/lib/new_relic/agent/instrumentation/roda/chain.rb +43 -0
- data/lib/new_relic/agent/instrumentation/roda/ignorer.rb +45 -0
- data/lib/new_relic/agent/instrumentation/roda/instrumentation.rb +68 -0
- data/lib/new_relic/agent/instrumentation/roda/prepend.rb +24 -0
- data/lib/new_relic/agent/instrumentation/roda/roda_transaction_namer.rb +29 -0
- data/lib/new_relic/agent/instrumentation/roda.rb +36 -0
- data/lib/new_relic/agent/instrumentation/sequel.rb +8 -9
- data/lib/new_relic/agent/instrumentation/sequel_helper.rb +10 -10
- data/lib/new_relic/agent/instrumentation/sidekiq/client.rb +4 -0
- data/lib/new_relic/agent/instrumentation/sidekiq/extensions/delayed_class.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sidekiq/server.rb +26 -3
- data/lib/new_relic/agent/instrumentation/sidekiq.rb +6 -3
- data/lib/new_relic/agent/instrumentation/sinatra/ignorer.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sinatra/instrumentation.rb +10 -5
- data/lib/new_relic/agent/instrumentation/sinatra/transaction_namer.rb +2 -4
- data/lib/new_relic/agent/instrumentation/stripe.rb +28 -0
- data/lib/new_relic/agent/instrumentation/stripe_subscriber.rb +77 -0
- data/lib/new_relic/agent/instrumentation/thread/chain.rb +1 -1
- data/lib/new_relic/agent/instrumentation/thread/instrumentation.rb +3 -8
- data/lib/new_relic/agent/instrumentation/thread/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/tilt/instrumentation.rb +6 -1
- data/lib/new_relic/agent/instrumentation/typhoeus/instrumentation.rb +10 -6
- data/lib/new_relic/agent/javascript_instrumentor.rb +29 -24
- data/lib/new_relic/agent/linking_metadata.rb +2 -2
- data/lib/new_relic/agent/log_event_aggregator.rb +64 -17
- data/lib/new_relic/agent/log_event_attributes.rb +115 -0
- data/lib/new_relic/agent/logging.rb +77 -37
- data/lib/new_relic/agent/messaging.rb +9 -7
- data/lib/new_relic/agent/method_tracer.rb +7 -7
- data/lib/new_relic/agent/method_tracer_helpers.rb +27 -6
- data/lib/new_relic/agent/monitors/cross_app_monitor.rb +4 -5
- data/lib/new_relic/agent/monitors/distributed_tracing_monitor.rb +1 -1
- data/lib/new_relic/agent/monitors/synthetics_monitor.rb +12 -1
- data/lib/new_relic/agent/new_relic_service/encoders.rb +1 -1
- data/lib/new_relic/agent/new_relic_service/json_marshaller.rb +2 -2
- data/lib/new_relic/agent/new_relic_service/security_policy_settings.rb +0 -1
- data/lib/new_relic/agent/new_relic_service.rb +47 -32
- data/lib/new_relic/agent/obfuscator.rb +1 -1
- data/lib/new_relic/agent/parameter_filtering.rb +6 -6
- data/lib/new_relic/agent/pipe_channel_manager.rb +7 -6
- data/lib/new_relic/agent/pipe_service.rb +5 -3
- data/lib/new_relic/agent/priority_sampled_buffer.rb +1 -1
- data/lib/new_relic/agent/rules_engine/segment_terms_rule.rb +0 -1
- data/lib/new_relic/agent/rules_engine.rb +1 -1
- data/lib/new_relic/agent/sampler.rb +2 -1
- data/lib/new_relic/agent/sampler_collection.rb +1 -1
- data/lib/new_relic/agent/samplers/cpu_sampler.rb +5 -5
- data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +9 -9
- data/lib/new_relic/agent/samplers/memory_sampler.rb +9 -9
- data/lib/new_relic/agent/samplers/object_sampler.rb +1 -1
- data/lib/new_relic/agent/span_event_aggregator.rb +4 -4
- data/lib/new_relic/agent/span_event_primitive.rb +18 -6
- data/lib/new_relic/agent/sql_sampler.rb +2 -2
- data/lib/new_relic/agent/stats.rb +1 -1
- data/lib/new_relic/agent/synthetics_event_aggregator.rb +1 -1
- data/lib/new_relic/agent/system_info.rb +36 -10
- data/lib/new_relic/agent/threading/agent_thread.rb +1 -1
- data/lib/new_relic/agent/threading/backtrace_node.rb +3 -3
- data/lib/new_relic/agent/threading/backtrace_service.rb +3 -7
- data/lib/new_relic/agent/threading/thread_profile.rb +5 -5
- data/lib/new_relic/agent/timestamp_sampled_buffer.rb +1 -1
- data/lib/new_relic/agent/tracer.rb +25 -16
- data/lib/new_relic/agent/transaction/abstract_segment.rb +109 -48
- data/lib/new_relic/agent/transaction/datastore_segment.rb +1 -1
- data/lib/new_relic/agent/transaction/distributed_tracer.rb +7 -6
- data/lib/new_relic/agent/transaction/distributed_tracing.rb +13 -14
- data/lib/new_relic/agent/transaction/external_request_segment.rb +16 -13
- data/lib/new_relic/agent/transaction/message_broker_segment.rb +2 -3
- data/lib/new_relic/agent/transaction/request_attributes.rb +47 -11
- data/lib/new_relic/agent/transaction/segment.rb +1 -1
- data/lib/new_relic/agent/transaction/synthetics_sample_buffer.rb +1 -1
- data/lib/new_relic/agent/transaction/trace.rb +1 -1
- data/lib/new_relic/agent/transaction/trace_context.rb +4 -4
- data/lib/new_relic/agent/transaction/trace_node.rb +8 -7
- data/lib/new_relic/agent/transaction/tracing.rb +10 -4
- data/lib/new_relic/agent/transaction/transaction_sample_buffer.rb +1 -1
- data/lib/new_relic/agent/transaction.rb +90 -58
- data/lib/new_relic/agent/transaction_error_primitive.rb +21 -5
- data/lib/new_relic/agent/transaction_event_aggregator.rb +4 -4
- data/lib/new_relic/agent/transaction_event_primitive.rb +22 -3
- data/lib/new_relic/agent/transaction_sampler.rb +3 -3
- data/lib/new_relic/agent/transaction_time_aggregator.rb +7 -3
- data/lib/new_relic/agent/utilization/aws.rb +1 -1
- data/lib/new_relic/agent/utilization/azure.rb +3 -3
- data/lib/new_relic/agent/utilization/gcp.rb +4 -6
- data/lib/new_relic/agent/utilization/pcf.rb +1 -1
- data/lib/new_relic/agent/utilization/vendor.rb +6 -8
- data/lib/new_relic/agent/vm/monotonic_gc_profiler.rb +1 -1
- data/lib/new_relic/agent/vm/mri_vm.rb +9 -8
- data/lib/new_relic/agent/worker_loop.rb +1 -1
- data/lib/new_relic/agent.rb +133 -36
- data/lib/new_relic/cli/command.rb +4 -3
- data/lib/new_relic/cli/commands/deployments.rb +26 -25
- data/lib/new_relic/cli/commands/install.rb +23 -23
- data/lib/new_relic/collection_helper.rb +2 -2
- data/lib/new_relic/constants.rb +10 -8
- data/lib/new_relic/control/class_methods.rb +4 -10
- data/lib/new_relic/control/frameworks/rails.rb +44 -20
- data/lib/new_relic/control/frameworks/roda.rb +20 -0
- data/lib/new_relic/control/instance_methods.rb +6 -6
- data/lib/new_relic/control/instrumentation.rb +1 -15
- data/lib/new_relic/control/private_instance_methods.rb +1 -1
- data/lib/new_relic/dependency_detection.rb +20 -18
- data/lib/new_relic/environment_report.rb +4 -4
- data/lib/new_relic/helper.rb +2 -1
- data/lib/new_relic/language_support.rb +10 -1
- data/lib/new_relic/latest_changes.rb +6 -6
- data/lib/new_relic/local_environment.rb +0 -10
- data/lib/new_relic/noticed_error.rb +25 -20
- data/lib/new_relic/rack/agent_hooks.rb +1 -1
- data/lib/new_relic/rack/agent_middleware.rb +0 -16
- data/lib/new_relic/rack/browser_monitoring.rb +21 -17
- data/lib/new_relic/recipes/capistrano3.rb +1 -1
- data/lib/new_relic/recipes/capistrano_legacy.rb +6 -6
- data/lib/new_relic/recipes/helpers/send_deployment.rb +5 -5
- data/lib/new_relic/supportability_helper.rb +4 -1
- data/lib/new_relic/traced_thread.rb +2 -3
- data/lib/new_relic/version.rb +2 -2
- data/lib/newrelic_rpm.rb +4 -4
- data/lib/sequel/extensions/{newrelic_instrumentation.rb → new_relic_instrumentation.rb} +6 -6
- data/lib/sequel/plugins/{newrelic_instrumentation.rb → new_relic_instrumentation.rb} +4 -4
- data/lib/tasks/bump_version.rake +21 -0
- data/lib/tasks/config.rake +13 -12
- data/lib/tasks/coverage_report.rake +4 -4
- data/lib/tasks/helpers/config.html.erb +93 -0
- data/lib/tasks/helpers/format.rb +19 -15
- data/lib/tasks/helpers/newrelicyml.rb +144 -0
- data/lib/tasks/helpers/version_bump.rb +62 -0
- data/lib/tasks/install.rake +4 -4
- data/lib/tasks/instrumentation_generator/instrumentation.thor +16 -19
- data/lib/tasks/instrumentation_generator/templates/Envfile.tt +1 -1
- data/lib/tasks/instrumentation_generator/templates/chain.tt +1 -1
- data/lib/tasks/instrumentation_generator/templates/dependency_detection.tt +1 -1
- data/lib/tasks/newrelic.rb +1 -0
- data/lib/tasks/newrelicyml.rake +13 -0
- data/lib/tasks/tests.rake +77 -6
- data/newrelic.yml +393 -274
- data/newrelic_rpm.gemspec +41 -30
- data/test/agent_helper.rb +25 -24
- metadata +172 -35
- data/.gitignore +0 -42
- data/.project +0 -23
- data/.rubocop.yml +0 -1946
- data/.rubocop_todo.yml +0 -62
- data/.simplecov +0 -15
- data/.snyk +0 -11
- data/.yardopts +0 -27
- data/Brewfile +0 -12
- data/DOCKER.md +0 -167
- data/Dockerfile +0 -10
- data/Guardfile +0 -26
- data/config/database.yml +0 -5
- data/config.dot +0 -278
- data/docker-compose.yml +0 -107
- data/lefthook.yml +0 -9
- data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +0 -83
- data/lib/new_relic/agent/instrumentation/authlogic.rb +0 -33
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +0 -215
- data/lib/new_relic/agent/instrumentation/rainbows_instrumentation.rb +0 -36
- data/lib/new_relic/agent/instrumentation/sunspot.rb +0 -41
- data/lib/new_relic/agent/range_extensions.rb +0 -27
- data/lib/tasks/helpers/removers.rb +0 -33
- data/lib/tasks/multiverse.rake +0 -6
- data/lib/tasks/multiverse.rb +0 -77
@@ -1,6 +1,7 @@
|
|
1
1
|
# This file is distributed under New Relic's license terms.
|
2
2
|
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
3
|
# frozen_string_literal: true
|
4
|
+
|
4
5
|
require_relative 'sidekiq/client'
|
5
6
|
require_relative 'sidekiq/server'
|
6
7
|
require_relative 'sidekiq/extensions/delayed_class'
|
@@ -32,7 +33,9 @@ DependencyDetection.defer do
|
|
32
33
|
end
|
33
34
|
|
34
35
|
if config.respond_to?(:error_handlers)
|
35
|
-
|
36
|
+
# Sidekiq 3.0.0 - 7.1.4 expect error_handlers to have 2 arguments
|
37
|
+
# Sidekiq 7.1.5+ expect error_handlers to have 3 arguments
|
38
|
+
config.error_handlers << proc do |error, _ctx, *_|
|
36
39
|
NewRelic::Agent.notice_error(error)
|
37
40
|
end
|
38
41
|
end
|
@@ -42,8 +45,8 @@ DependencyDetection.defer do
|
|
42
45
|
executes do
|
43
46
|
next unless Gem::Version.new(Sidekiq::VERSION) < Gem::Version.new('5.0.0')
|
44
47
|
|
45
|
-
deprecation_msg = 'Instrumentation for Sidekiq versions below 5.0.0 is deprecated
|
46
|
-
'
|
48
|
+
deprecation_msg = 'Instrumentation for Sidekiq versions below 5.0.0 is deprecated ' \
|
49
|
+
'and will be dropped entirely in a future major New Relic Ruby agent release.' \
|
47
50
|
'Please upgrade your Sidekiq version to continue receiving full support. '
|
48
51
|
|
49
52
|
NewRelic::Agent.logger.log_once(
|
@@ -33,7 +33,7 @@ module NewRelic::Agent::Instrumentation
|
|
33
33
|
set(:newrelic_ignores, Hash.new([])) if !respond_to?(:newrelic_ignores)
|
34
34
|
|
35
35
|
# If we call an ignore without a route, it applies to the whole app
|
36
|
-
routes = [
|
36
|
+
routes = ['*'] if routes.empty?
|
37
37
|
|
38
38
|
settings.newrelic_ignores[type] += routes.map do |r|
|
39
39
|
# Ugly sending to private Base#compile, but we want to mimic
|
@@ -13,6 +13,8 @@ module NewRelic::Agent::Instrumentation
|
|
13
13
|
module Tracer
|
14
14
|
include ::NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
15
15
|
|
16
|
+
INSTRUMENTATION_NAME = 'Sinatra'
|
17
|
+
|
16
18
|
def self.included(clazz)
|
17
19
|
clazz.extend(self)
|
18
20
|
end
|
@@ -45,7 +47,8 @@ module NewRelic::Agent::Instrumentation
|
|
45
47
|
|
46
48
|
def try_to_use(app, clazz)
|
47
49
|
install_lock.synchronize do
|
48
|
-
|
50
|
+
# The following line needs else branch coverage
|
51
|
+
has_middleware = app.middleware && app.middleware.any? { |info| info && info[0] == clazz } # rubocop:disable Style/SafeNavigation
|
49
52
|
app.use(clazz) unless has_middleware
|
50
53
|
end
|
51
54
|
end
|
@@ -53,9 +56,9 @@ module NewRelic::Agent::Instrumentation
|
|
53
56
|
# Capture last route we've seen. Will set for transaction on route_eval
|
54
57
|
def process_route_with_tracing(*args)
|
55
58
|
begin
|
56
|
-
env[
|
59
|
+
env['newrelic.last_route'] = args[0]
|
57
60
|
rescue => e
|
58
|
-
::NewRelic::Agent.logger.debug(
|
61
|
+
::NewRelic::Agent.logger.debug('Failed determining last route in Sinatra', e)
|
59
62
|
end
|
60
63
|
yield
|
61
64
|
end
|
@@ -74,7 +77,7 @@ module NewRelic::Agent::Instrumentation
|
|
74
77
|
)
|
75
78
|
end
|
76
79
|
rescue => e
|
77
|
-
::NewRelic::Agent.logger.debug(
|
80
|
+
::NewRelic::Agent.logger.debug('Failed during route_eval to set transaction name', e)
|
78
81
|
end
|
79
82
|
yield
|
80
83
|
end
|
@@ -83,12 +86,14 @@ module NewRelic::Agent::Instrumentation
|
|
83
86
|
begin
|
84
87
|
@request.params
|
85
88
|
rescue => e
|
86
|
-
NewRelic::Agent.logger.debug(
|
89
|
+
NewRelic::Agent.logger.debug('Failed to get params from Rack request.', e)
|
87
90
|
nil
|
88
91
|
end
|
89
92
|
end
|
90
93
|
|
91
94
|
def dispatch_with_tracing
|
95
|
+
NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
|
96
|
+
|
92
97
|
request_params = get_request_params
|
93
98
|
filtered_params = ::NewRelic::Agent::ParameterFiltering::apply_filters(request.env, request_params || {})
|
94
99
|
|
@@ -25,14 +25,12 @@ module NewRelic
|
|
25
25
|
transaction_name(::NewRelic::Agent::UNKNOWN_METRIC, request)
|
26
26
|
end
|
27
27
|
|
28
|
-
ROOT = '/'.freeze
|
29
|
-
|
30
28
|
def transaction_name(route_text, request)
|
31
29
|
verb = http_verb(request)
|
32
30
|
|
33
31
|
route_text = route_text.source if route_text.is_a?(Regexp)
|
34
32
|
name = route_text.gsub(%r{^[/^\\A]*(.*?)[/\$\?\\z]*$}, '\1')
|
35
|
-
name = ROOT if name.empty?
|
33
|
+
name = NewRelic::ROOT if name.empty?
|
36
34
|
name = "#{verb} #{name}" unless verb.nil?
|
37
35
|
name
|
38
36
|
rescue => e
|
@@ -47,7 +45,7 @@ module NewRelic
|
|
47
45
|
# For bare Sinatra, our override on process_route captures the last
|
48
46
|
# route into the environment for us to use later on
|
49
47
|
def route_for_sinatra(env)
|
50
|
-
env[
|
48
|
+
env['newrelic.last_route']
|
51
49
|
end
|
52
50
|
|
53
51
|
# For Padrino, the request object has a copy of the matched route
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# This file is distributed under New Relic's license terms.
|
2
|
+
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
require 'new_relic/agent/instrumentation/stripe_subscriber'
|
6
|
+
|
7
|
+
DependencyDetection.defer do
|
8
|
+
named :stripe
|
9
|
+
|
10
|
+
depends_on do
|
11
|
+
NewRelic::Agent.config[:'instrumentation.stripe'] == 'enabled'
|
12
|
+
end
|
13
|
+
|
14
|
+
depends_on do
|
15
|
+
defined?(Stripe) &&
|
16
|
+
Gem::Version.new(Stripe::VERSION) >= Gem::Version.new('5.38.0')
|
17
|
+
end
|
18
|
+
|
19
|
+
executes do
|
20
|
+
NewRelic::Agent.logger.info('Installing Stripe instrumentation')
|
21
|
+
end
|
22
|
+
|
23
|
+
executes do
|
24
|
+
newrelic_subscriber = NewRelic::Agent::Instrumentation::StripeSubscriber.new
|
25
|
+
Stripe::Instrumentation.subscribe(:request_begin) { |event| newrelic_subscriber.start_segment(event) }
|
26
|
+
Stripe::Instrumentation.subscribe(:request_end) { |event| newrelic_subscriber.finish_segment(event) }
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# This file is distributed under New Relic's license terms.
|
2
|
+
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
module NewRelic
|
6
|
+
module Agent
|
7
|
+
module Instrumentation
|
8
|
+
class StripeSubscriber
|
9
|
+
DEFAULT_DESTINATIONS = AttributeFilter::DST_SPAN_EVENTS
|
10
|
+
EVENT_ATTRIBUTES = %i[http_status method num_retries path request_id].freeze
|
11
|
+
ATTRIBUTE_NAMESPACE = 'stripe.user_data'
|
12
|
+
ATTRIBUTE_FILTER_TYPES = %i[include exclude].freeze
|
13
|
+
|
14
|
+
def start_segment(event)
|
15
|
+
return unless is_execution_traced?
|
16
|
+
|
17
|
+
segment = NewRelic::Agent::Tracer.start_segment(name: metric_name(event))
|
18
|
+
event.user_data[:newrelic_segment] = segment
|
19
|
+
rescue => e
|
20
|
+
NewRelic::Agent.logger.error("Error starting New Relic Stripe segment: #{e}")
|
21
|
+
end
|
22
|
+
|
23
|
+
def finish_segment(event)
|
24
|
+
return unless is_execution_traced?
|
25
|
+
|
26
|
+
segment = remove_and_return_nr_segment(event)
|
27
|
+
add_stripe_attributes(segment, event)
|
28
|
+
add_custom_attributes(segment, event)
|
29
|
+
rescue => e
|
30
|
+
NewRelic::Agent.logger.error("Error finishing New Relic Stripe segment: #{e}")
|
31
|
+
ensure
|
32
|
+
segment&.finish
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def is_execution_traced?
|
38
|
+
NewRelic::Agent::Tracer.state.is_execution_traced?
|
39
|
+
end
|
40
|
+
|
41
|
+
def metric_name(event)
|
42
|
+
"Stripe#{event.path}/#{event.method}"
|
43
|
+
end
|
44
|
+
|
45
|
+
def add_stripe_attributes(segment, event)
|
46
|
+
EVENT_ATTRIBUTES.each do |attribute|
|
47
|
+
segment.add_agent_attribute("stripe_#{attribute}", event.send(attribute), DEFAULT_DESTINATIONS)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def add_custom_attributes(segment, event)
|
52
|
+
return if NewRelic::Agent.config[:'stripe.user_data.include'].empty?
|
53
|
+
|
54
|
+
filtered_attributes = NewRelic::Agent::AttributePreFiltering.pre_filter_hash(event.user_data, nr_attribute_options)
|
55
|
+
filtered_attributes.each do |key, value|
|
56
|
+
segment.add_agent_attribute("stripe_user_data_#{key}", value, DEFAULT_DESTINATIONS)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def nr_attribute_options
|
61
|
+
ATTRIBUTE_FILTER_TYPES.each_with_object({}) do |type, opts|
|
62
|
+
pattern =
|
63
|
+
NewRelic::Agent::AttributePreFiltering.formulate_regexp_union(:"#{ATTRIBUTE_NAMESPACE}.#{type}")
|
64
|
+
opts[type] = pattern if pattern
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def remove_and_return_nr_segment(event)
|
69
|
+
segment = event.user_data[:newrelic_segment]
|
70
|
+
event.user_data.delete(:newrelic_segment)
|
71
|
+
|
72
|
+
segment
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -14,7 +14,7 @@ module NewRelic::Agent::Instrumentation
|
|
14
14
|
alias_method(:initialize_without_new_relic, :initialize)
|
15
15
|
|
16
16
|
def initialize(*args, &block)
|
17
|
-
traced_block = add_thread_tracing(
|
17
|
+
traced_block = add_thread_tracing(&block)
|
18
18
|
initialize_with_newrelic_tracing { initialize_without_new_relic(*args, &traced_block) }
|
19
19
|
end
|
20
20
|
end
|
@@ -6,26 +6,21 @@ module NewRelic
|
|
6
6
|
module Agent
|
7
7
|
module Instrumentation
|
8
8
|
module MonitoredThread
|
9
|
-
attr_reader :
|
9
|
+
attr_reader :nr_parent_key
|
10
10
|
|
11
11
|
def initialize_with_newrelic_tracing
|
12
|
-
@
|
12
|
+
@nr_parent_key = NewRelic::Agent::Tracer.current_segment_key
|
13
13
|
yield
|
14
14
|
end
|
15
15
|
|
16
16
|
def add_thread_tracing(*args, &block)
|
17
|
-
return block if
|
17
|
+
return block if !NewRelic::Agent::Tracer.thread_tracing_enabled?
|
18
18
|
|
19
19
|
NewRelic::Agent::Tracer.thread_block_with_current_transaction(
|
20
|
-
*args,
|
21
20
|
segment_name: 'Ruby/Thread',
|
22
21
|
&block
|
23
22
|
)
|
24
23
|
end
|
25
|
-
|
26
|
-
def skip_tracing?
|
27
|
-
!NewRelic::Agent.config[:'instrumentation.thread.tracing']
|
28
|
-
end
|
29
24
|
end
|
30
25
|
end
|
31
26
|
end
|
@@ -12,7 +12,7 @@ module NewRelic
|
|
12
12
|
include NewRelic::Agent::Instrumentation::MonitoredThread
|
13
13
|
|
14
14
|
def initialize(*args, &block)
|
15
|
-
traced_block = add_thread_tracing(
|
15
|
+
traced_block = add_thread_tracing(&block)
|
16
16
|
initialize_with_newrelic_tracing { super(*args, &traced_block) }
|
17
17
|
end
|
18
18
|
end
|
@@ -6,6 +6,8 @@ module NewRelic
|
|
6
6
|
module Agent
|
7
7
|
module Instrumentation
|
8
8
|
module Tilt
|
9
|
+
INSTRUMENTATION_NAME = NewRelic::Agent.base_name(name)
|
10
|
+
|
9
11
|
def metric_name(klass, file)
|
10
12
|
"View/#{klass}/#{file}/Rendering"
|
11
13
|
end
|
@@ -21,6 +23,8 @@ module NewRelic
|
|
21
23
|
end
|
22
24
|
|
23
25
|
def render_with_tracing(*args, &block)
|
26
|
+
NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
|
27
|
+
|
24
28
|
begin
|
25
29
|
finishable = Tracer.start_segment(
|
26
30
|
name: metric_name(self.class, create_filename_for_metric(self.file))
|
@@ -32,7 +36,8 @@ module NewRelic
|
|
32
36
|
raise
|
33
37
|
end
|
34
38
|
ensure
|
35
|
-
|
39
|
+
# The following line needs else branch coverage
|
40
|
+
finishable.finish if finishable # rubocop:disable Style/SafeNavigation
|
36
41
|
end
|
37
42
|
end
|
38
43
|
end
|
@@ -6,10 +6,10 @@ module NewRelic
|
|
6
6
|
module Agent
|
7
7
|
module Instrumentation
|
8
8
|
module Typhoeus
|
9
|
-
HYDRA_SEGMENT_NAME =
|
10
|
-
NOTICEABLE_ERROR_CLASS =
|
11
|
-
|
12
|
-
|
9
|
+
HYDRA_SEGMENT_NAME = 'External/Multiple/Typhoeus::Hydra/run'
|
10
|
+
NOTICEABLE_ERROR_CLASS = 'Typhoeus::Errors::TyphoeusError'
|
11
|
+
EARLIEST_VERSION = Gem::Version.new('0.5.3')
|
12
|
+
INSTRUMENTATION_NAME = NewRelic::Agent.base_name(name)
|
13
13
|
|
14
14
|
def self.is_supported_version?
|
15
15
|
Gem::Version.new(::Typhoeus::VERSION) >= EARLIEST_VERSION
|
@@ -26,11 +26,13 @@ module NewRelic
|
|
26
26
|
response.return_message
|
27
27
|
else
|
28
28
|
# 0.5.4 seems to have lost xxxx_message methods altogether.
|
29
|
-
|
29
|
+
'timeout'
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
def with_tracing
|
34
|
+
NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
|
35
|
+
|
34
36
|
segment = NewRelic::Agent::Tracer.start_segment(name: HYDRA_SEGMENT_NAME)
|
35
37
|
instance_variable_set(:@__newrelic_hydra_segment, segment)
|
36
38
|
begin
|
@@ -41,6 +43,8 @@ module NewRelic
|
|
41
43
|
end
|
42
44
|
|
43
45
|
def self.trace(request)
|
46
|
+
NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
|
47
|
+
|
44
48
|
state = NewRelic::Agent::Tracer.state
|
45
49
|
return unless state.is_execution_traced?
|
46
50
|
|
@@ -72,7 +76,7 @@ module NewRelic
|
|
72
76
|
end
|
73
77
|
request.on_complete.unshift(callback)
|
74
78
|
rescue => e
|
75
|
-
NewRelic::Agent.logger.error(
|
79
|
+
NewRelic::Agent.logger.error('Exception during trace setup for Typhoeus request', e)
|
76
80
|
end
|
77
81
|
end
|
78
82
|
end
|
@@ -23,7 +23,7 @@ module NewRelic
|
|
23
23
|
"JS agent loader version: #{NewRelic::Agent.config[:'browser_monitoring.loader_version']}")
|
24
24
|
|
25
25
|
if !NewRelic::Agent.config[:'rum.enabled']
|
26
|
-
NewRelic::Agent.logger.debug(
|
26
|
+
NewRelic::Agent.logger.debug('Real User Monitoring is disabled for this agent. Edit your configuration to change this.')
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -38,19 +38,19 @@ module NewRelic
|
|
38
38
|
def js_enabled_and_ready?
|
39
39
|
if !enabled?
|
40
40
|
::NewRelic::Agent.logger.log_once(:debug, :js_agent_disabled,
|
41
|
-
|
41
|
+
'JS agent instrumentation is disabled.')
|
42
42
|
false
|
43
43
|
elsif missing_config?(:js_agent_loader)
|
44
44
|
::NewRelic::Agent.logger.log_once(:debug, :missing_js_agent_loader,
|
45
|
-
|
45
|
+
'Missing :js_agent_loader. Skipping browser instrumentation.')
|
46
46
|
false
|
47
47
|
elsif missing_config?(:beacon)
|
48
48
|
::NewRelic::Agent.logger.log_once(:debug, :missing_beacon,
|
49
|
-
|
49
|
+
'Beacon configuration not received (yet?). Skipping browser instrumentation.')
|
50
50
|
false
|
51
51
|
elsif missing_config?(:browser_key)
|
52
52
|
::NewRelic::Agent.logger.log_once(:debug, :missing_browser_key,
|
53
|
-
|
53
|
+
'Browser key is not set. Skipping browser instrumentation.')
|
54
54
|
false
|
55
55
|
else
|
56
56
|
true
|
@@ -62,19 +62,19 @@ module NewRelic
|
|
62
62
|
|
63
63
|
def insert_js?(state)
|
64
64
|
if !state.current_transaction
|
65
|
-
::NewRelic::Agent.logger.debug(
|
65
|
+
::NewRelic::Agent.logger.debug('Not in transaction. Skipping browser instrumentation.')
|
66
66
|
false
|
67
67
|
elsif !state.is_execution_traced?
|
68
|
-
::NewRelic::Agent.logger.debug(
|
68
|
+
::NewRelic::Agent.logger.debug('Execution is not traced. Skipping browser instrumentation.')
|
69
69
|
false
|
70
70
|
elsif state.current_transaction.ignore_enduser?
|
71
|
-
::NewRelic::Agent.logger.debug(
|
71
|
+
::NewRelic::Agent.logger.debug('Ignore end user for this transaction is set. Skipping browser instrumentation.')
|
72
72
|
false
|
73
73
|
else
|
74
74
|
true
|
75
75
|
end
|
76
76
|
rescue => e
|
77
|
-
::NewRelic::Agent.logger.debug(
|
77
|
+
::NewRelic::Agent.logger.debug('Failure during insert_js', e)
|
78
78
|
false
|
79
79
|
end
|
80
80
|
|
@@ -95,7 +95,7 @@ module NewRelic
|
|
95
95
|
|
96
96
|
bt_config + browser_timing_loader(nonce)
|
97
97
|
rescue => e
|
98
|
-
::NewRelic::Agent.logger.debug(
|
98
|
+
::NewRelic::Agent.logger.debug('Failure during RUM browser_timing_header construction', e)
|
99
99
|
''
|
100
100
|
end
|
101
101
|
|
@@ -122,18 +122,18 @@ module NewRelic
|
|
122
122
|
" nonce=\"#{nonce.to_s}\""
|
123
123
|
end
|
124
124
|
|
125
|
-
BEACON_KEY =
|
126
|
-
ERROR_BEACON_KEY =
|
127
|
-
LICENSE_KEY_KEY =
|
128
|
-
APPLICATIONID_KEY =
|
129
|
-
TRANSACTION_NAME_KEY =
|
130
|
-
QUEUE_TIME_KEY =
|
131
|
-
APPLICATION_TIME_KEY =
|
132
|
-
AGENT_KEY =
|
133
|
-
SSL_FOR_HTTP_KEY =
|
134
|
-
ATTS_KEY =
|
135
|
-
ATTS_USER_SUBKEY =
|
136
|
-
ATTS_AGENT_SUBKEY =
|
125
|
+
BEACON_KEY = 'beacon'.freeze
|
126
|
+
ERROR_BEACON_KEY = 'errorBeacon'.freeze
|
127
|
+
LICENSE_KEY_KEY = 'licenseKey'.freeze
|
128
|
+
APPLICATIONID_KEY = 'applicationID'.freeze
|
129
|
+
TRANSACTION_NAME_KEY = 'transactionName'.freeze
|
130
|
+
QUEUE_TIME_KEY = 'queueTime'.freeze
|
131
|
+
APPLICATION_TIME_KEY = 'applicationTime'.freeze
|
132
|
+
AGENT_KEY = 'agent'.freeze
|
133
|
+
SSL_FOR_HTTP_KEY = 'sslForHttp'.freeze
|
134
|
+
ATTS_KEY = 'atts'.freeze
|
135
|
+
ATTS_USER_SUBKEY = 'u'.freeze
|
136
|
+
ATTS_AGENT_SUBKEY = 'a'.freeze
|
137
137
|
|
138
138
|
# NOTE: Internal prototyping may override this, so leave name stable!
|
139
139
|
def data_for_js_agent(transaction)
|
@@ -185,9 +185,14 @@ module NewRelic
|
|
185
185
|
|
186
186
|
def append_custom_attributes!(txn, atts)
|
187
187
|
custom_attributes = txn.attributes.custom_attributes_for(NewRelic::Agent::AttributeFilter::DST_BROWSER_MONITORING)
|
188
|
-
|
189
|
-
|
188
|
+
if custom_attributes.empty?
|
189
|
+
NewRelic::Agent.logger.debug("#{self.class}: No custom attributes found to append.")
|
190
|
+
return
|
190
191
|
end
|
192
|
+
|
193
|
+
NewRelic::Agent.logger.debug("#{self.class}: Appending the following custom attribute keys for browser " \
|
194
|
+
"monitoring: #{custom_attributes.keys}")
|
195
|
+
atts[ATTS_USER_SUBKEY] = custom_attributes
|
191
196
|
end
|
192
197
|
|
193
198
|
def append_agent_attributes!(txn, atts)
|
@@ -11,7 +11,7 @@ module NewRelic
|
|
11
11
|
extend self
|
12
12
|
|
13
13
|
def append_service_linking_metadata(metadata)
|
14
|
-
raise ArgumentError,
|
14
|
+
raise ArgumentError, 'Missing argument `metadata`' if metadata.nil?
|
15
15
|
|
16
16
|
config = ::NewRelic::Agent.config
|
17
17
|
|
@@ -27,7 +27,7 @@ module NewRelic
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def append_trace_linking_metadata(metadata)
|
30
|
-
raise ArgumentError,
|
30
|
+
raise ArgumentError, 'Missing argument `metadata`' if metadata.nil?
|
31
31
|
|
32
32
|
if trace_id = Tracer.current_trace_id
|
33
33
|
metadata[TRACE_ID_KEY] = trace_id
|
@@ -4,25 +4,26 @@
|
|
4
4
|
|
5
5
|
require 'new_relic/agent/event_aggregator'
|
6
6
|
require 'new_relic/agent/log_priority'
|
7
|
+
require 'new_relic/agent/log_event_attributes'
|
7
8
|
|
8
9
|
module NewRelic
|
9
10
|
module Agent
|
10
11
|
class LogEventAggregator < EventAggregator
|
11
12
|
# Per-message keys
|
12
|
-
LEVEL_KEY =
|
13
|
-
MESSAGE_KEY =
|
14
|
-
TIMESTAMP_KEY =
|
15
|
-
PRIORITY_KEY =
|
13
|
+
LEVEL_KEY = 'level'.freeze
|
14
|
+
MESSAGE_KEY = 'message'.freeze
|
15
|
+
TIMESTAMP_KEY = 'timestamp'.freeze
|
16
|
+
PRIORITY_KEY = 'priority'.freeze
|
16
17
|
|
17
18
|
# Metric keys
|
18
|
-
LINES =
|
19
|
-
DROPPED_METRIC =
|
20
|
-
SEEN_METRIC =
|
21
|
-
SENT_METRIC =
|
22
|
-
OVERALL_SUPPORTABILITY_FORMAT =
|
23
|
-
METRICS_SUPPORTABILITY_FORMAT =
|
24
|
-
FORWARDING_SUPPORTABILITY_FORMAT =
|
25
|
-
DECORATING_SUPPORTABILITY_FORMAT =
|
19
|
+
LINES = 'Logging/lines'.freeze
|
20
|
+
DROPPED_METRIC = 'Logging/Forwarding/Dropped'.freeze
|
21
|
+
SEEN_METRIC = 'Supportability/Logging/Forwarding/Seen'.freeze
|
22
|
+
SENT_METRIC = 'Supportability/Logging/Forwarding/Sent'.freeze
|
23
|
+
OVERALL_SUPPORTABILITY_FORMAT = 'Supportability/Logging/Ruby/Logger/%s'.freeze
|
24
|
+
METRICS_SUPPORTABILITY_FORMAT = 'Supportability/Logging/Metrics/Ruby/%s'.freeze
|
25
|
+
FORWARDING_SUPPORTABILITY_FORMAT = 'Supportability/Logging/Forwarding/Ruby/%s'.freeze
|
26
|
+
DECORATING_SUPPORTABILITY_FORMAT = 'Supportability/Logging/LocalDecorating/Ruby/%s'.freeze
|
26
27
|
MAX_BYTES = 32768 # 32 * 1024 bytes (32 kibibytes)
|
27
28
|
|
28
29
|
named :LogEventAggregator
|
@@ -36,6 +37,10 @@ module NewRelic
|
|
36
37
|
METRICS_ENABLED_KEY = :'application_logging.metrics.enabled'
|
37
38
|
FORWARDING_ENABLED_KEY = :'application_logging.forwarding.enabled'
|
38
39
|
DECORATING_ENABLED_KEY = :'application_logging.local_decorating.enabled'
|
40
|
+
LOG_LEVEL_KEY = :'application_logging.forwarding.log_level'
|
41
|
+
CUSTOM_ATTRIBUTES_KEY = :'application_logging.forwarding.custom_attributes'
|
42
|
+
|
43
|
+
attr_reader :attributes
|
39
44
|
|
40
45
|
def initialize(events)
|
41
46
|
super(events)
|
@@ -44,6 +49,7 @@ module NewRelic
|
|
44
49
|
@seen_by_severity = Hash.new(0)
|
45
50
|
@high_security = NewRelic::Agent.config[:high_security]
|
46
51
|
@instrumentation_logger_enabled = NewRelic::Agent::Instrumentation::Logger.enabled?
|
52
|
+
@attributes = NewRelic::Agent::LogEventAttributes.new
|
47
53
|
register_for_done_configuring(events)
|
48
54
|
end
|
49
55
|
|
@@ -54,7 +60,7 @@ module NewRelic
|
|
54
60
|
def record(formatted_message, severity)
|
55
61
|
return unless enabled?
|
56
62
|
|
57
|
-
severity =
|
63
|
+
severity = 'UNKNOWN' if severity.nil? || severity.empty?
|
58
64
|
|
59
65
|
if NewRelic::Agent.config[METRICS_ENABLED_KEY]
|
60
66
|
@counter_lock.synchronize do
|
@@ -63,8 +69,9 @@ module NewRelic
|
|
63
69
|
end
|
64
70
|
end
|
65
71
|
|
72
|
+
return if severity_too_low?(severity)
|
66
73
|
return if formatted_message.nil? || formatted_message.empty?
|
67
|
-
return unless NewRelic::Agent.config[
|
74
|
+
return unless NewRelic::Agent.config[FORWARDING_ENABLED_KEY]
|
68
75
|
return if @high_security
|
69
76
|
|
70
77
|
txn = NewRelic::Agent::Transaction.tl_current
|
@@ -114,6 +121,10 @@ module NewRelic
|
|
114
121
|
]
|
115
122
|
end
|
116
123
|
|
124
|
+
def add_custom_attributes(custom_attributes)
|
125
|
+
attributes.add_custom_attributes(custom_attributes)
|
126
|
+
end
|
127
|
+
|
117
128
|
# Because our transmission format (MELT) is different than historical
|
118
129
|
# agent payloads, extract the munging here to keep the service focused
|
119
130
|
# on the general harvest + transmit instead of the format.
|
@@ -130,6 +141,8 @@ module NewRelic
|
|
130
141
|
# sent by classic logs-in-context
|
131
142
|
common_attributes.delete(ENTITY_TYPE_KEY)
|
132
143
|
|
144
|
+
common_attributes.merge!(NewRelic::Agent.agent.log_event_aggregator.attributes.custom_attributes)
|
145
|
+
|
133
146
|
_, items = data
|
134
147
|
payload = [{
|
135
148
|
common: {attributes: common_attributes},
|
@@ -149,6 +162,7 @@ module NewRelic
|
|
149
162
|
@seen = 0
|
150
163
|
@seen_by_severity.clear
|
151
164
|
end
|
165
|
+
|
152
166
|
super
|
153
167
|
end
|
154
168
|
|
@@ -168,15 +182,17 @@ module NewRelic
|
|
168
182
|
record_configuration_metric(METRICS_SUPPORTABILITY_FORMAT, METRICS_ENABLED_KEY)
|
169
183
|
record_configuration_metric(FORWARDING_SUPPORTABILITY_FORMAT, FORWARDING_ENABLED_KEY)
|
170
184
|
record_configuration_metric(DECORATING_SUPPORTABILITY_FORMAT, DECORATING_ENABLED_KEY)
|
185
|
+
|
186
|
+
add_custom_attributes(NewRelic::Agent.config[CUSTOM_ATTRIBUTES_KEY])
|
171
187
|
end
|
172
188
|
end
|
173
189
|
|
174
190
|
def record_configuration_metric(format, key)
|
175
191
|
state = NewRelic::Agent.config[key]
|
176
192
|
label = if !enabled?
|
177
|
-
|
193
|
+
'disabled'
|
178
194
|
else
|
179
|
-
state ?
|
195
|
+
state ? 'enabled' : 'disabled'
|
180
196
|
end
|
181
197
|
NewRelic::Agent.increment_metric(format % label)
|
182
198
|
end
|
@@ -191,7 +207,7 @@ module NewRelic
|
|
191
207
|
# these until harvest before recording them
|
192
208
|
def record_customer_metrics
|
193
209
|
return unless enabled?
|
194
|
-
return unless NewRelic::Agent.config[
|
210
|
+
return unless NewRelic::Agent.config[METRICS_ENABLED_KEY]
|
195
211
|
|
196
212
|
@counter_lock.synchronize do
|
197
213
|
return unless @seen > 0
|
@@ -230,6 +246,37 @@ module NewRelic
|
|
230
246
|
|
231
247
|
message.byteslice(0...MAX_BYTES)
|
232
248
|
end
|
249
|
+
|
250
|
+
def minimum_log_level
|
251
|
+
if Logger::Severity.constants.include?(configured_log_level_constant)
|
252
|
+
configured_log_level_constant
|
253
|
+
else
|
254
|
+
NewRelic::Agent.logger.log_once(
|
255
|
+
:error,
|
256
|
+
'Invalid application_logging.forwarding.log_level ' \
|
257
|
+
"'#{NewRelic::Agent.config[LOG_LEVEL_KEY]}' specified! " \
|
258
|
+
"Must be one of #{Logger::Severity.constants.join('|')}. " \
|
259
|
+
"Using default level of 'debug'"
|
260
|
+
)
|
261
|
+
:DEBUG
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
265
|
+
def configured_log_level_constant
|
266
|
+
format_log_level_constant(NewRelic::Agent.config[LOG_LEVEL_KEY])
|
267
|
+
end
|
268
|
+
|
269
|
+
def format_log_level_constant(log_level)
|
270
|
+
log_level.upcase.to_sym
|
271
|
+
end
|
272
|
+
|
273
|
+
def severity_too_low?(severity)
|
274
|
+
severity_constant = format_log_level_constant(severity)
|
275
|
+
# always record custom log levels
|
276
|
+
return false unless Logger::Severity.constants.include?(severity_constant)
|
277
|
+
|
278
|
+
Logger::Severity.const_get(severity_constant) < Logger::Severity.const_get(minimum_log_level)
|
279
|
+
end
|
233
280
|
end
|
234
281
|
end
|
235
282
|
end
|