newrelic_rpm 9.2.2 → 9.5.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 +168 -0
- data/README.md +8 -4
- data/lib/new_relic/agent/attribute_pre_filtering.rb +109 -0
- data/lib/new_relic/agent/configuration/default_source.rb +176 -32
- data/lib/new_relic/agent/configuration/environment_source.rb +1 -1
- data/lib/new_relic/agent/configuration/manager.rb +3 -2
- data/lib/new_relic/agent/configuration/yaml_source.rb +13 -0
- data/lib/new_relic/agent/distributed_tracing.rb +1 -1
- data/lib/new_relic/agent/instrumentation/action_controller_other_subscriber.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_record.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_record_notifications.rb +2 -1
- data/lib/new_relic/agent/instrumentation/active_support_logger/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +9 -0
- 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 +1 -2
- data/lib/new_relic/agent/instrumentation/curb/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/delayed_job/instrumentation.rb +3 -0
- data/lib/new_relic/agent/instrumentation/elasticsearch/instrumentation.rb +4 -1
- data/lib/new_relic/agent/instrumentation/excon/middleware.rb +3 -0
- data/lib/new_relic/agent/instrumentation/fiber/chain.rb +10 -3
- data/lib/new_relic/agent/instrumentation/fiber/instrumentation.rb +1 -2
- data/lib/new_relic/agent/instrumentation/fiber/prepend.rb +10 -3
- data/lib/new_relic/agent/instrumentation/grape/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/grpc/client/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/grpc/server/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/grpc_client.rb +1 -1
- data/lib/new_relic/agent/instrumentation/grpc_server.rb +1 -1
- 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/logger/instrumentation.rb +3 -0
- data/lib/new_relic/agent/instrumentation/memcache/instrumentation.rb +12 -3
- data/lib/new_relic/agent/instrumentation/memcache.rb +2 -2
- data/lib/new_relic/agent/instrumentation/net_http/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/notifications_subscriber.rb +4 -0
- data/lib/new_relic/agent/instrumentation/padrino/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/queue_time.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rack/instrumentation.rb +6 -0
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +4 -0
- data/lib/new_relic/agent/instrumentation/rails_notifications/action_cable.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rake/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/redis/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/resque/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/roda/chain.rb +43 -0
- data/lib/new_relic/agent/instrumentation/roda/instrumentation.rb +56 -0
- data/lib/new_relic/agent/instrumentation/roda/prepend.rb +24 -0
- data/lib/new_relic/agent/instrumentation/roda/roda_transaction_namer.rb +30 -0
- data/lib/new_relic/agent/instrumentation/roda.rb +34 -0
- data/lib/new_relic/agent/instrumentation/sequel.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sidekiq/client.rb +4 -0
- data/lib/new_relic/agent/instrumentation/sidekiq/server.rb +26 -3
- data/lib/new_relic/agent/instrumentation/sidekiq.rb +2 -2
- data/lib/new_relic/agent/instrumentation/sinatra/instrumentation.rb +4 -0
- 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 +0 -1
- data/lib/new_relic/agent/instrumentation/thread/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/tilt/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/typhoeus/instrumentation.rb +5 -1
- data/lib/new_relic/agent/log_event_aggregator.rb +49 -2
- data/lib/new_relic/agent/log_event_attributes.rb +115 -0
- data/lib/new_relic/agent/logging.rb +4 -4
- data/lib/new_relic/agent/method_tracer_helpers.rb +26 -5
- data/lib/new_relic/agent/new_relic_service.rb +33 -17
- data/lib/new_relic/agent/pipe_service.rb +1 -1
- data/lib/new_relic/agent/tracer.rb +6 -5
- data/lib/new_relic/agent/transaction/abstract_segment.rb +52 -0
- data/lib/new_relic/agent/transaction/request_attributes.rb +45 -7
- data/lib/new_relic/agent/transaction.rb +5 -4
- data/lib/new_relic/agent/utilization/vendor.rb +5 -7
- data/lib/new_relic/agent.rb +50 -1
- data/lib/new_relic/cli/command.rb +1 -0
- data/lib/new_relic/control/class_methods.rb +1 -7
- data/lib/new_relic/control/frameworks/roda.rb +20 -0
- data/lib/new_relic/dependency_detection.rb +6 -0
- data/lib/new_relic/language_support.rb +5 -0
- data/lib/new_relic/latest_changes.rb +1 -1
- data/lib/new_relic/noticed_error.rb +5 -2
- 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 +1 -1
- data/lib/new_relic/supportability_helper.rb +2 -0
- data/lib/new_relic/traced_thread.rb +2 -3
- data/lib/new_relic/version.rb +2 -2
- data/lib/sequel/extensions/new_relic_instrumentation.rb +1 -1
- data/lib/tasks/bump_version.rake +21 -0
- data/lib/tasks/config.rake +3 -2
- data/lib/tasks/helpers/config.html.erb +93 -0
- data/lib/tasks/helpers/format.rb +11 -7
- data/lib/tasks/helpers/newrelicyml.rb +144 -0
- data/lib/tasks/helpers/version_bump.rb +62 -0
- data/lib/tasks/newrelicyml.rake +13 -0
- data/newrelic.yml +362 -265
- data/newrelic_rpm.gemspec +11 -7
- metadata +36 -25
- data/.gitignore +0 -43
- data/.project +0 -23
- data/.rubocop.yml +0 -1845
- data/.rubocop_todo.yml +0 -61
- data/.simplecov +0 -16
- data/.snyk +0 -11
- data/.yardopts +0 -27
- data/Brewfile +0 -13
- data/DOCKER.md +0 -167
- data/Dockerfile +0 -10
- data/Guardfile +0 -27
- data/config/database.yml +0 -5
- data/config.dot +0 -278
- data/docker-compose.yml +0 -107
- data/lefthook.yml +0 -9
- data/lib/tasks/helpers/removers.rb +0 -33
- data/lib/tasks/multiverse.rake +0 -6
- data/lib/tasks/multiverse.rb +0 -84
@@ -27,7 +27,7 @@ module Sequel
|
|
27
27
|
# If you don't want your models or database connections to be instrumented,
|
28
28
|
# you can disable them by setting `disable_database_instrumentation` in
|
29
29
|
# your `newrelic.yml` to `true`. It will also honor the
|
30
|
-
# `
|
30
|
+
# `disable_active_record_instrumentation` setting.
|
31
31
|
#
|
32
32
|
module NewRelicInstrumentation
|
33
33
|
module Naming
|
@@ -0,0 +1,21 @@
|
|
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_relative 'helpers/version_bump'
|
6
|
+
|
7
|
+
namespace :newrelic do
|
8
|
+
namespace :version do
|
9
|
+
desc 'Returns the current version'
|
10
|
+
task :current do
|
11
|
+
puts "#{NewRelic::VERSION::STRING}"
|
12
|
+
end
|
13
|
+
|
14
|
+
desc 'Update version file and changelog to next version'
|
15
|
+
task :bump, [:format] => [] do |t, args|
|
16
|
+
new_version = VersionBump.update_version
|
17
|
+
VersionBump.update_changelog(new_version)
|
18
|
+
puts "New version: #{new_version}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/tasks/config.rake
CHANGED
@@ -21,12 +21,13 @@ namespace :newrelic do
|
|
21
21
|
'transaction_tracer' => 'The [transaction traces](/docs/apm/traces/transaction-traces/transaction-traces) feature collects detailed information from a selection of transactions, including a summary of the calling sequence, a breakdown of time spent, and a list of SQL queries and their query plans (on mysql and postgresql). Available features depend on your New Relic subscription level.',
|
22
22
|
'error_collector' => "The agent collects and reports all uncaught exceptions by default. These configuration options allow you to customize the error collection.\n\nFor information on ignored and expected errors, [see this page on Error Analytics in APM](/docs/agents/manage-apm-agents/agent-data/manage-errors-apm-collect-ignore-or-mark-expected/). To set expected errors via the `NewRelic::Agent.notice_error` Ruby method, [consult the Ruby Agent API](/docs/agents/ruby-agent/api-guides/sending-handled-errors-new-relic/).",
|
23
23
|
'browser_monitoring' => "The browser monitoring [page load timing](/docs/browser/new-relic-browser/page-load-timing/page-load-timing-process) feature (sometimes referred to as real user monitoring or RUM) gives you insight into the performance real users are experiencing with your website. This is accomplished by measuring the time it takes for your users' browsers to download and render your web pages by injecting a small amount of JavaScript code into the header and footer of each page.",
|
24
|
+
'application_logging' => "The Ruby agent supports [APM logs in context](/docs/apm/new-relic-apm/getting-started/get-started-logs-context). For some tips on configuring logs for the Ruby agent, see [Configure Ruby logs in context](/docs/logs/logs-context/configure-logs-context-ruby).\n\nAvailable logging-related config options include:",
|
24
25
|
'analytics_events' => '[New Relic dashboards](/docs/query-your-data/explore-query-data/dashboards/introduction-new-relic-one-dashboards) is a resource to gather and visualize data about your software and what it says about your business. With it you can quickly and easily create real-time dashboards to get immediate answers about end-user experiences, clickstreams, mobile activities, and server transactions.'
|
25
26
|
}
|
26
27
|
|
27
28
|
NAME_OVERRIDES = {
|
28
|
-
'slow_sql' => 'Slow SQL',
|
29
|
-
'custom_insights_events' => 'Custom Events'
|
29
|
+
'slow_sql' => 'Slow SQL [#slow-sql]',
|
30
|
+
'custom_insights_events' => 'Custom Events [#custom-events]'
|
30
31
|
}
|
31
32
|
|
32
33
|
desc 'Describe available New Relic configuration settings'
|
@@ -1,3 +1,96 @@
|
|
1
|
+
---
|
2
|
+
title: Ruby agent configuration
|
3
|
+
tags:
|
4
|
+
- Agents
|
5
|
+
- Ruby agent
|
6
|
+
- Configuration
|
7
|
+
metaDescription: 'APM for Ruby: how to configure the Ruby agent, including editing the config file and setting environment variables.'
|
8
|
+
redirects:
|
9
|
+
- /docs/agents/ruby-agent/configuration/ruby-agent-configuration
|
10
|
+
- /docs/ruby/ruby-agent-configuration
|
11
|
+
- /docs/agents/ruby-agent/installation-and-configuration/ruby-agent-configuration
|
12
|
+
- /docs/agents/ruby-agent/installation-configuration/ruby-agent-configuration
|
13
|
+
---
|
14
|
+
|
15
|
+
<CONTRIBUTOR_NOTE>
|
16
|
+
This file is automatically generated from values defined in `lib/new_relic/agent/configuration/default_source.rb`.
|
17
|
+
All changes should be made directly to `default_source.rb.`
|
18
|
+
Submit PRs or raise issues at: https://github.com/newrelic/newrelic-ruby-agent
|
19
|
+
</CONTRIBUTOR_NOTE>
|
20
|
+
|
21
|
+
You can configure the New Relic Ruby agent with settings in a configuration file, environment variables, or programmatically with server-side configuration. This document summarizes the configuration options available for the Ruby agent.
|
22
|
+
|
23
|
+
If the default value for a configuration option is `(Dynamic)`, this means the Ruby agent calculates the default at runtime. The value for the config setting defaults to the value of another setting as appropriate.
|
24
|
+
|
25
|
+
## Configuration methods and precedence [#Options]
|
26
|
+
|
27
|
+
The primary (default) method to configure the Ruby agent is via the configuration file (`newrelic.yml`) in the `config` subdirectory. To set configuration values using environment variables:
|
28
|
+
|
29
|
+
1. Add the prefix `NEW_RELIC_` to the setting's name.
|
30
|
+
2. Replace any periods `.` with underscores `_`.
|
31
|
+
|
32
|
+
You can also configure a few values in the UI via [server-side configuration](/docs/agents/manage-apm-agents/configuration/server-side-agent-configuration).
|
33
|
+
|
34
|
+
The Ruby agent follows this order of precedence for configuration:
|
35
|
+
|
36
|
+
1. Environment variables
|
37
|
+
2. Server-side configuration
|
38
|
+
3. Configuration file (`newrelic.yml`)
|
39
|
+
4. Default configuration settings
|
40
|
+
|
41
|
+
In other words, environment variables override all other configuration settings and info, server-side configuration overrides the configuration file and default config settings, and so on.
|
42
|
+
|
43
|
+
## View and edit config file options [#Edit]
|
44
|
+
|
45
|
+
The Ruby agent's `newrelic.yml` is a standard YAML configuration file. It typically includes a `Defaults` section at the top, plus sections below for each application environment; for example, `Development`, `Testing`, and `Production`.
|
46
|
+
|
47
|
+
The Ruby agent determines which section of the `newrelic.yml` config file to read from by looking at certain environment variables to derive the application's environment. This can be useful, for example, when you want to use `info` for the `log_level` config setting in your production environment, and you want more verbose `log_level` config settings (such as `debug` in your development environment.
|
48
|
+
|
49
|
+
Here is an example `newrelic.yml` config file:
|
50
|
+
|
51
|
+
```yaml
|
52
|
+
common: &default_settings
|
53
|
+
license_key: 'YOUR_LICENSE_KEY'
|
54
|
+
app_name: 'My Application Name'
|
55
|
+
production:
|
56
|
+
<<: *default_settings
|
57
|
+
log_level: info
|
58
|
+
development:
|
59
|
+
<<: *default_settings
|
60
|
+
log_level: debug
|
61
|
+
```
|
62
|
+
|
63
|
+
For non-Rails apps, the Ruby agent looks for the following environment variables, in this order, to determine the application environment:
|
64
|
+
|
65
|
+
1. `NEW_RELIC_ENV`
|
66
|
+
2. `RUBY_ENV`
|
67
|
+
3. `RAILS_ENV`
|
68
|
+
4. `APP_ENV`
|
69
|
+
5. `RACK_ENV`
|
70
|
+
|
71
|
+
If the Ruby agent does not detect values for any of those environment variables, it will default the application environment to `development` and read from the `development` section of the `newrelic.yml` config file.
|
72
|
+
|
73
|
+
When running the Ruby agent in a Rails app, the agent first looks for the `NEW_RELIC_ENV` environment variable to determine the application environment and which section of the `newrelic.yml` to use. If `NEW_RELIC_ENV` is not present, the agent uses the Rails environment (`RAILS_ENV` or `RAILS.env`, depending on the version of Rails) .
|
74
|
+
|
75
|
+
When you edit the config file, be sure to:
|
76
|
+
|
77
|
+
* Indent only with two spaces.
|
78
|
+
* Indent only where relevant, in stanzas such as **`error_collector`**.
|
79
|
+
|
80
|
+
If you do not indent correctly, the agent may throw an `Unable to parse configuration file` error on startup.
|
81
|
+
|
82
|
+
To view the most current list of available Ruby agent configuration options, use the `rake newrelic:config:docs` command. This document describes the most common options.
|
83
|
+
|
84
|
+
## Update the config file [#Updates]
|
85
|
+
|
86
|
+
This documentation applies to the Ruby agent's latest release. For details on earlier versions, refer to the comments in `newrelic.yml` itself.
|
87
|
+
|
88
|
+
To update `newrelic.yml` file after a new release, use the template in the base directory of the agent gem. When you update to new gem versions, examine or diff `config/newrelic.yml` and `newrelic.yml` in the [installation directory](/docs/agents/manage-apm-agents/troubleshooting/find-agent-root-directory#ruby-agent) to take advantage of new configuration options.
|
89
|
+
|
90
|
+
<Callout variant="important">
|
91
|
+
Updating the gem does not automatically update `config/newrelic.yml`.
|
92
|
+
</Callout>
|
93
|
+
|
1
94
|
<% sections.each do |(section_key, section_name, section_description, configs)| %>
|
2
95
|
## <%=section_name%>
|
3
96
|
|
data/lib/tasks/helpers/format.rb
CHANGED
@@ -3,16 +3,19 @@
|
|
3
3
|
# frozen_string_literal: true
|
4
4
|
|
5
5
|
module Format
|
6
|
-
|
7
|
-
config_hash = build_config_hash
|
8
|
-
sections = flatten_config_hash(config_hash)
|
6
|
+
DEFAULT_CONFIG_PATH = 'ruby-agent-configuration.mdx'
|
9
7
|
|
10
|
-
|
11
|
-
|
8
|
+
def output(format)
|
9
|
+
result = build_erb(format).result(binding).split("\n").map(&:rstrip).join("\n").gsub('. ', '. ')
|
10
|
+
File.write(DEFAULT_CONFIG_PATH, result)
|
12
11
|
end
|
13
12
|
|
14
13
|
private
|
15
14
|
|
15
|
+
def sections
|
16
|
+
@sections ||= flatten_config_hash(build_config_hash)
|
17
|
+
end
|
18
|
+
|
16
19
|
def add_data_to_sections(sections)
|
17
20
|
sections.each do |section|
|
18
21
|
section_key = section[0]
|
@@ -66,7 +69,7 @@ module Format
|
|
66
69
|
|
67
70
|
def format_description(value)
|
68
71
|
description = ''
|
69
|
-
description += '
|
72
|
+
description += '**DEPRECATED** ' if value[:deprecated]
|
70
73
|
description += value[:description]
|
71
74
|
description
|
72
75
|
end
|
@@ -81,9 +84,10 @@ module Format
|
|
81
84
|
name = NAME_OVERRIDES[key]
|
82
85
|
return name if name
|
83
86
|
|
84
|
-
key.split('_')
|
87
|
+
title = key.split('_')
|
85
88
|
.each { |fragment| fragment[0] = fragment[0].upcase }
|
86
89
|
.join(' ')
|
90
|
+
"#{title} [##{key.tr('_', '-')}]"
|
87
91
|
end
|
88
92
|
|
89
93
|
def format_sections(key, value)
|
@@ -0,0 +1,144 @@
|
|
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_relative '../../new_relic/agent/configuration/default_source'
|
6
|
+
|
7
|
+
module NewRelicYML
|
8
|
+
CRITICAL = [:'agent_enabled', :'app_name', :'license_key', :'log_level']
|
9
|
+
DEFAULTS = NewRelic::Agent::Configuration::DEFAULTS
|
10
|
+
# Skip because not configurable via yml
|
11
|
+
SKIP = [:'defer_rails_initialization']
|
12
|
+
# Don't evaluate Procs, instead use set values
|
13
|
+
PROCS = {:'config_path' => 'newrelic.yml',
|
14
|
+
:'process_host.display_name' => 'default hostname',
|
15
|
+
:'transaction_tracer.transaction_threshold' => 1.0}
|
16
|
+
|
17
|
+
HEADER = <<~HEADER
|
18
|
+
#
|
19
|
+
# This file configures the New Relic Agent. New Relic monitors Ruby, Java,
|
20
|
+
# .NET, PHP, Python, Node, and Go applications with deep visibility and low
|
21
|
+
# overhead. For more information, visit www.newrelic.com.
|
22
|
+
|
23
|
+
# Generated <%= Time.now.strftime('%B %d, %Y') %><%= ", for version \#{@agent_version}" if @agent_version %>
|
24
|
+
#<%= "\\n# \#{generated_for_user}\\n#" if generated_for_user %>
|
25
|
+
# For full documentation of agent configuration options, please refer to
|
26
|
+
# https://docs.newrelic.com/docs/agents/ruby-agent/installation-configuration/ruby-agent-configuration
|
27
|
+
|
28
|
+
common: &default_settings
|
29
|
+
# Required license key associated with your New Relic account.
|
30
|
+
license_key: <%= license_key %>
|
31
|
+
|
32
|
+
# Your application name. Renaming here affects where data displays in New
|
33
|
+
# Relic. For more details, see https://docs.newrelic.com/docs/apm/new-relic-apm/maintenance/renaming-applications
|
34
|
+
app_name: <%= app_name %>
|
35
|
+
|
36
|
+
# To disable the agent regardless of other settings, uncomment the following:
|
37
|
+
# agent_enabled: false
|
38
|
+
|
39
|
+
# Logging level for log/newrelic_agent.log; options are error, warn, info, or
|
40
|
+
# debug.
|
41
|
+
log_level: info
|
42
|
+
|
43
|
+
# All of the following configuration options are optional. Review them, and
|
44
|
+
# uncomment or edit them if they appear relevant to your application needs.
|
45
|
+
|
46
|
+
HEADER
|
47
|
+
|
48
|
+
FOOTER = <<~FOOTER
|
49
|
+
# Environment-specific settings are in this section.
|
50
|
+
# RAILS_ENV or RACK_ENV (as appropriate) is used to determine the environment.
|
51
|
+
# If your application has other named environments, configure them here.
|
52
|
+
development:
|
53
|
+
<<: *default_settings
|
54
|
+
app_name: <%= app_name %> (Development)
|
55
|
+
|
56
|
+
test:
|
57
|
+
<<: *default_settings
|
58
|
+
# It doesn't make sense to report to New Relic from automated test runs.
|
59
|
+
monitor_mode: false
|
60
|
+
|
61
|
+
staging:
|
62
|
+
<<: *default_settings
|
63
|
+
app_name: <%= app_name %> (Staging)
|
64
|
+
|
65
|
+
production:
|
66
|
+
<<: *default_settings
|
67
|
+
FOOTER
|
68
|
+
|
69
|
+
def self.get_configs(defaults)
|
70
|
+
defaults.sort.each_with_object({}) do |(key, value), final_configs|
|
71
|
+
next if CRITICAL.include?(key) || SKIP.include?(key)
|
72
|
+
|
73
|
+
next unless public_config?(value) && !deprecated?(value)
|
74
|
+
|
75
|
+
sanitized_description = sanitize_description(value[:description])
|
76
|
+
description = format_description(sanitized_description)
|
77
|
+
default = default_value(key, value)
|
78
|
+
final_configs[key] = {description: description, default: default}
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def self.public_config?(value)
|
83
|
+
value[:public] == true
|
84
|
+
end
|
85
|
+
|
86
|
+
def self.deprecated?(value)
|
87
|
+
value[:deprecated] == true
|
88
|
+
end
|
89
|
+
|
90
|
+
def self.sanitize_description(description)
|
91
|
+
# remove callouts
|
92
|
+
description = description.split("\n").reject { |line| line.match?('</?Callout') }.join("\n")
|
93
|
+
# remove InlinePopover, keep the text inside type
|
94
|
+
description.gsub!(/<InlinePopover type="(.*)" \/>/, '\1')
|
95
|
+
# remove hyperlinks
|
96
|
+
description.gsub!(/\[([^\]]+)\]\([^\)]+\)/, '\1')
|
97
|
+
# remove single pairs of backticks
|
98
|
+
description.gsub!(/`([^`]+)`/, '\1')
|
99
|
+
# removed href links
|
100
|
+
description.gsub!(/<a href="(.*)">(.*)<\/a>/, '\2')
|
101
|
+
|
102
|
+
description
|
103
|
+
end
|
104
|
+
|
105
|
+
def self.format_description(description)
|
106
|
+
# remove leading and trailing whitespace
|
107
|
+
description.strip!
|
108
|
+
# wrap text after 80 characters
|
109
|
+
description.gsub!(/(.{1,80})(\s+|\Z)/, "\\1\n")
|
110
|
+
# add hashtags to lines
|
111
|
+
description = description.split("\n").map { |line| " # #{line}" }.join("\n")
|
112
|
+
|
113
|
+
description
|
114
|
+
end
|
115
|
+
|
116
|
+
def self.default_value(key, config_hash)
|
117
|
+
if PROCS.include?(key)
|
118
|
+
PROCS[key]
|
119
|
+
else
|
120
|
+
default = config_hash[:documentation_default].nil? ? config_hash[:default] : config_hash[:documentation_default]
|
121
|
+
default = 'nil' if default.nil?
|
122
|
+
default = '""' if default == ''
|
123
|
+
|
124
|
+
default
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def self.build_string(defaults)
|
129
|
+
configs = get_configs(defaults)
|
130
|
+
yml_string = ''
|
131
|
+
|
132
|
+
configs.each do |key, value|
|
133
|
+
yml_string += "#{value[:description]}\n # #{key}: #{value[:default]}\n\n"
|
134
|
+
end
|
135
|
+
|
136
|
+
yml_string
|
137
|
+
end
|
138
|
+
|
139
|
+
# :nocov:
|
140
|
+
def self.write_file(defaults = DEFAULTS)
|
141
|
+
File.write('newrelic.yml', HEADER + build_string(defaults) + FOOTER)
|
142
|
+
end
|
143
|
+
# :nocov:
|
144
|
+
end
|
@@ -0,0 +1,62 @@
|
|
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 VersionBump
|
6
|
+
MAJOR = 0
|
7
|
+
MINOR = 1
|
8
|
+
TINY = 2
|
9
|
+
VERSION = {major: MAJOR, minor: MINOR, tiny: TINY}
|
10
|
+
|
11
|
+
# Updates version.rb with new version number
|
12
|
+
def self.update_version
|
13
|
+
bump_type = determine_bump_type
|
14
|
+
file = read_file('lib/new_relic/version.rb')
|
15
|
+
new_version = {}
|
16
|
+
|
17
|
+
VERSION.each do |key, current|
|
18
|
+
file.gsub!(/(#{key.to_s.upcase} = )(\d+)/) do
|
19
|
+
match = Regexp.last_match
|
20
|
+
|
21
|
+
new_version[key] = if bump_type == current # bump type, increase by 1
|
22
|
+
match[2].to_i + 1
|
23
|
+
elsif bump_type < current # right of bump type, goes to 0
|
24
|
+
0
|
25
|
+
else # left of bump type, stays the same
|
26
|
+
match[2].to_i
|
27
|
+
end
|
28
|
+
|
29
|
+
match[1] + new_version[key].to_s
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
write_file('lib/new_relic/version.rb', file)
|
34
|
+
new_version.values.join('.')
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.read_file(path)
|
38
|
+
File.read(File.expand_path(path))
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.write_file(path, file)
|
42
|
+
File.write(File.expand_path(path), file)
|
43
|
+
end
|
44
|
+
|
45
|
+
# Determined version based on if changelog has a feature or not for version
|
46
|
+
def self.determine_bump_type
|
47
|
+
file = read_file('CHANGELOG.md')
|
48
|
+
lines = file.split('## ')[1].split('- **')
|
49
|
+
return MAJOR if lines.first.include?('Major version')
|
50
|
+
return MINOR if lines.any? { |line| line.include?('Feature:') }
|
51
|
+
|
52
|
+
TINY
|
53
|
+
end
|
54
|
+
|
55
|
+
# Replace dev with version number in changelog
|
56
|
+
def self.update_changelog(version)
|
57
|
+
file = read_file('CHANGELOG.md')
|
58
|
+
file.gsub!('## dev', "## v#{version}")
|
59
|
+
file.gsub!('Version <dev>', "Version #{version}")
|
60
|
+
write_file('CHANGELOG.md', file)
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,13 @@
|
|
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_relative 'helpers/newrelicyml'
|
6
|
+
|
7
|
+
namespace :newrelic do
|
8
|
+
desc 'Update newrelic.yml with latest config options from default_source.rb'
|
9
|
+
task :update_newrelicyml do
|
10
|
+
NewRelicYML.write_file
|
11
|
+
puts 'newrelic.yml updated'
|
12
|
+
end
|
13
|
+
end
|