Skip to content

Commit cf910aa

Browse files
Merge pull request #3102 from newrelic/update_newrelicyml_code_fences
Adapt newrelic.yml generator to code fences
2 parents 252592a + dfa1ed1 commit cf910aa

File tree

3 files changed

+126
-105
lines changed

3 files changed

+126
-105
lines changed

lib/new_relic/agent/configuration/default_source.rb

Lines changed: 60 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,9 @@ def self.enforce_fallback(allowed_values: nil, fallback: nil)
387387
:allowed_from_server => false,
388388
:description => <<~DESCRIPTION
389389
An array of ActiveSupport custom event names to subscribe to and instrument. For example,
390-
- one.custom.event
391-
- another.event
392-
- a.third.event
390+
- one.custom.event
391+
- another.event
392+
- a.third.event
393393
DESCRIPTION
394394
},
395395
:'ai_monitoring.enabled' => {
@@ -407,11 +407,11 @@ def self.enforce_fallback(allowed_values: nil, fallback: nil)
407407
:description => <<~DESCRIPTION
408408
If `false`, LLM instrumentation (OpenAI only for now) will not capture input and output content on specific LLM events.
409409
410-
The excluded attributes include:
411-
* `content` from LlmChatCompletionMessage events
412-
* `input` from LlmEmbedding events
410+
The excluded attributes include:
411+
- `content` from LlmChatCompletionMessage events
412+
- `input` from LlmEmbedding events
413413
414-
This is an optional security setting to prevent recording sensitive data sent to and received from your LLMs.
414+
This is an optional security setting to prevent recording sensitive data sent to and received from your LLMs.
415415
DESCRIPTION
416416
},
417417
# this is only set via server side config
@@ -460,9 +460,9 @@ def self.enforce_fallback(allowed_values: nil, fallback: nil)
460460
:description => <<~DESCRIPTION
461461
When `true`, the agent captures HTTP request parameters and attaches them to transaction traces, traced errors, and [`TransactionError` events](/attribute-dictionary?attribute_name=&events_tids%5B%5D=8241).
462462
463-
<Callout variant="caution">
464-
When using the `capture_params` setting, the Ruby agent will not attempt to filter secret information. `Recommendation:` To filter secret information from request parameters, use the [`attributes.include` setting](/docs/agents/ruby-agent/attributes/enable-disable-attributes-ruby) instead. For more information, see the <a href="/docs/agents/ruby-agent/attributes/ruby-attribute-examples#ex_req_params">Ruby attribute examples</a>.
465-
</Callout>
463+
<Callout variant="caution">
464+
When using the `capture_params` setting, the Ruby agent will not attempt to filter secret information. `Recommendation:` To filter secret information from request parameters, use the [`attributes.include` setting](/docs/agents/ruby-agent/attributes/enable-disable-attributes-ruby) instead. For more information, see the <a href="/docs/agents/ruby-agent/attributes/ruby-attribute-examples#ex_req_params">Ruby attribute examples</a>.
465+
</Callout>
466466
DESCRIPTION
467467
},
468468
:'clear_transaction_state_after_fork' => {
@@ -487,10 +487,10 @@ def self.enforce_fallback(allowed_values: nil, fallback: nil)
487487
:allowed_from_server => false,
488488
:description => <<~DESC
489489
Path to `newrelic.yml`. If undefined, the agent checks the following directories (in order):
490-
* `config/newrelic.yml`
491-
* `newrelic.yml`
492-
* `$HOME/.newrelic/newrelic.yml`
493-
* `$HOME/newrelic.yml`
490+
- `config/newrelic.yml`
491+
- `newrelic.yml`
492+
- `$HOME/.newrelic/newrelic.yml`
493+
- `$HOME/newrelic.yml`
494494
DESC
495495
},
496496
:'exclude_newrelic_header' => {
@@ -674,13 +674,13 @@ def self.enforce_fallback(allowed_values: nil, fallback: nil)
674674
:public => true,
675675
:type => String,
676676
:allowed_from_server => true,
677-
:description => 'Obfuscation level for SQL queries reported in transaction trace nodes.
678-
679-
By default, this is set to `obfuscated`, which strips out the numeric and string literals.
680-
681-
- If you do not want the agent to capture query information, set this to `none`.
682-
- If you want the agent to capture all query information in its original form, set this to `raw`.
683-
- When you enable [high security mode](/docs/agents/manage-apm-agents/configuration/high-security-mode), this is automatically set to `obfuscated`.'
677+
:description => <<~DESC
678+
Obfuscation level for SQL queries reported in transaction trace nodes.
679+
By default, this is set to `obfuscated`, which strips out the numeric and string literals.
680+
- If you do not want the agent to capture query information, set this to `none`.
681+
- If you want the agent to capture all query information in its original form, set this to `raw`.
682+
- When you enable [high security mode](/docs/agents/manage-apm-agents/configuration/high-security-mode), this is automatically set to `obfuscated`.
683+
DESC
684684
},
685685

686686
:'transaction_tracer.stack_trace_threshold' => {
@@ -722,10 +722,9 @@ def self.enforce_fallback(allowed_values: nil, fallback: nil)
722722
:dynamic_name => true,
723723
:description => <<~DESCRIPTION
724724
A list of error classes that the agent should treat as expected.
725-
726-
<Callout variant="caution">
727-
This option can't be set via environment variable.
728-
</Callout>
725+
<Callout variant="caution">
726+
This option can't be set via environment variable.
727+
</Callout>
729728
DESCRIPTION
730729
},
731730
:'error_collector.expected_messages' => {
@@ -736,10 +735,9 @@ def self.enforce_fallback(allowed_values: nil, fallback: nil)
736735
:dynamic_name => true,
737736
:description => <<~DESCRIPTION
738737
A map of error classes to a list of messages. When an error of one of the classes specified here occurs, if its error message contains one of the strings corresponding to it here, that error will be treated as expected.
739-
740-
<Callout variant="caution">
741-
This option can't be set via environment variable.
742-
</Callout>
738+
<Callout variant="caution">
739+
This option can't be set via environment variable.
740+
</Callout>
743741
DESCRIPTION
744742
},
745743
:'error_collector.expected_status_codes' => {
@@ -758,10 +756,9 @@ def self.enforce_fallback(allowed_values: nil, fallback: nil)
758756
:dynamic_name => true,
759757
:description => <<~DESCRIPTION
760758
A list of error classes that the agent should ignore.
761-
762-
<Callout variant="caution">
763-
This option can't be set via environment variable.
764-
</Callout>
759+
<Callout variant="caution">
760+
This option can't be set via environment variable.
761+
</Callout>
765762
DESCRIPTION
766763
},
767764
:'error_collector.ignore_messages' => {
@@ -772,10 +769,9 @@ def self.enforce_fallback(allowed_values: nil, fallback: nil)
772769
:dynamic_name => true,
773770
:description => <<~DESCRIPTION
774771
A map of error classes to a list of messages. When an error of one of the classes specified here occurs, if its error message contains one of the strings corresponding to it here, that error will be ignored.
775-
776-
<Callout variant="caution">
777-
This option can't be set via environment variable.
778-
</Callout>
772+
<Callout variant="caution">
773+
This option can't be set via environment variable.
774+
</Callout>
779775
DESCRIPTION
780776
},
781777
:'error_collector.ignore_status_codes' => {
@@ -864,12 +860,12 @@ def self.enforce_fallback(allowed_values: nil, fallback: nil)
864860
For example, setting this value to "debug" will forward all log events to New Relic. Setting this value to "error" will only forward log events with the levels "error", "fatal", and "unknown".
865861
866862
Valid values (ordered lowest to highest):
867-
* "debug"
868-
* "info"
869-
* "warn"
870-
* "error"
871-
* "fatal"
872-
* "unknown"
863+
- "debug"
864+
- "info"
865+
- "warn"
866+
- "error"
867+
- "fatal"
868+
- "unknown"
873869
DESCRIPTION
874870
},
875871
:'application_logging.forwarding.custom_attributes' => {
@@ -1241,8 +1237,8 @@ def self.notify
12411237
:dynamic_name => true,
12421238
# Keep the extra two-space indent before the second bullet to appease translation tool
12431239
:description => <<~DESC
1244-
* Specify a maximum number of custom events to buffer in memory at a time.
1245-
* When configuring the agent for [AI monitoring](/docs/ai-monitoring/intro-to-ai-monitoring), \
1240+
- Specify a maximum number of custom events to buffer in memory at a time.
1241+
- When configuring the agent for [AI monitoring](/docs/ai-monitoring/intro-to-ai-monitoring), \
12461242
set to max value `100000`. This ensures the agent captures the maximum amount of LLM events.
12471243
DESC
12481244
},
@@ -1384,9 +1380,9 @@ def self.notify
13841380
:description => <<~DESCRIPTION
13851381
If `true`, the agent won't wrap third-party middlewares in instrumentation (regardless of whether they are installed via `Rack::Builder` or Rails).
13861382
1387-
<Callout variant="important">
1388-
When middleware instrumentation is disabled, if an application is using middleware that could alter the response code, the HTTP status code reported on the transaction may not reflect the altered value.
1389-
</Callout>
1383+
<Callout variant="important">
1384+
When middleware instrumentation is disabled, if an application is using middleware that could alter the response code, the HTTP status code reported on the transaction may not reflect the altered value.
1385+
</Callout>
13901386
DESCRIPTION
13911387
},
13921388
:disable_samplers => {
@@ -1425,20 +1421,18 @@ def self.notify
14251421
:description => <<~DESCRIPTION
14261422
If `true`, disables agent middleware for Sinatra. This middleware is responsible for advanced feature support such as [cross application tracing](/docs/apm/transactions/cross-application-traces/cross-application-tracing), [page load timing](/docs/browser/new-relic-browser/getting-started/new-relic-browser), and [error collection](/docs/apm/applications-menu/events/view-apm-error-analytics).
14271423
1428-
<Callout variant="important">
1429-
Cross application tracing is deprecated in favor of [distributed tracing](/docs/apm/distributed-tracing/getting-started/introduction-distributed-tracing). Distributed tracing is on by default for Ruby agent versions 8.0.0 and above. Middlewares are not required to support distributed tracing.
1424+
<Callout variant="important">
1425+
Cross application tracing is deprecated in favor of [distributed tracing](/docs/apm/distributed-tracing/getting-started/introduction-distributed-tracing). Distributed tracing is on by default for Ruby agent versions 8.0.0 and above. Middlewares are not required to support distributed tracing.
14301426
1431-
To continue using cross application tracing, update the following options in your `newrelic.yml` configuration file:
1427+
To continue using cross application tracing, update the following options in your `newrelic.yml` configuration file:
14321428
1433-
```yaml
1434-
# newrelic.yml
1435-
1436-
cross_application_tracer:
1437-
enabled: true
1438-
distributed_tracing:
1439-
enabled: false
1440-
```
1441-
</Callout>
1429+
```yaml
1430+
cross_application_tracer:
1431+
enabled: true
1432+
distributed_tracing:
1433+
enabled: false
1434+
```
1435+
</Callout>
14421436
DESCRIPTION
14431437
},
14441438
:disable_view_instrumentation => {
@@ -2052,7 +2046,7 @@ def self.notify
20522046
If `true`, when the agent is in an application using Ruby on Rails, it will start after `config/initializers` run.
20532047
20542048
<Callout variant="caution">
2055-
This option may only be set by environment variable.
2049+
This option may only be set by environment variable.
20562050
</Callout>
20572051
DESCRIPTION
20582052
},
@@ -2190,8 +2184,8 @@ def self.notify
21902184
:allowed_from_server => true,
21912185
# Keep the extra two-space indent before the second bullet to appease translation tool
21922186
:description => <<~DESC
2193-
* Defines the maximum number of span events reported from a single harvest. Any Integer between `1` and `10000` is valid.'
2194-
* When configuring the agent for [AI monitoring](/docs/ai-monitoring/intro-to-ai-monitoring), set to max value `10000`.\
2187+
- Defines the maximum number of span events reported from a single harvest. Any Integer between `1` and `10000` is valid.'
2188+
- When configuring the agent for [AI monitoring](/docs/ai-monitoring/intro-to-ai-monitoring), set to max value `10000`.\
21952189
This ensures the agent captures the maximum amount of distributed traces.
21962190
DESC
21972191
},
@@ -2534,11 +2528,9 @@ def self.notify
25342528
:allowlist => %i[none low medium high],
25352529
:external => :infinite_tracing,
25362530
:description => <<~DESC
2537-
Configure the compression level for data sent to the trace observer.
2538-
2539-
May be one of: `:none`, `:low`, `:medium`, `:high`.
2540-
2541-
Set the level to `:none` to disable compression.
2531+
Configure the compression level for data sent to the trace observer. \
2532+
May be one of: `:none`, `:low`, `:medium`, `:high`. \
2533+
Set the level to `:none` to disable compression.
25422534
DESC
25432535
},
25442536
:js_agent_file => {

lib/tasks/helpers/newrelicyml.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ def self.sanitize_description(description)
141141
description.gsub!(/<InlinePopover type="(.*)" \/>/, '\1')
142142
# remove hyperlinks
143143
description.gsub!(/\[([^\]]+)\]\([^\)]+\)/, '\1')
144+
# delete lines with code fences including the language
145+
description.gsub!(/```[a-zA-Z0-9_]*\n(.*?)```/m, '\1')
144146
# remove single pairs of backticks
145147
description.gsub!(/`([^`]+)`/, '\1')
146148
# removed href links
@@ -153,8 +155,8 @@ def self.format_description(description)
153155
# remove leading and trailing whitespace
154156
description.strip!
155157
# wrap text after 80 characters, assuming we're at one tabstop's (two
156-
# spaces') level of indentation already
157-
description.gsub!(/(.{1,78})(\s+|\Z)/, "\\1\n")
158+
# spaces') level of indentation already, keep leading whitespace
159+
description.gsub!(/(.{1,78})(\s|\Z)/, "\\1\n")
158160
# add hashtags to lines
159161
description = description.split("\n").map { |line| " # #{line}" }.join("\n")
160162

0 commit comments

Comments
 (0)