• /
  • Log in
  • Free account

Code references

We use a variety of formatting to highlight code or other technical language.

When to use code formatting

The following table provides some examples of our use of code format.

For this...

Why use code?


File paths and file names

Using code helps paths and file names stand out, and ensures clarity about the exact file name.

The agent looks for newrelic.config in the %ALLUSERSPROFILE%\New Relic\.NET Agent directory.

NRDB event names and attributes

Many attribute names (such as duration) look like ordinary English words. Formatting them as code helps clarify that we're talking about a specific data point.

To analyze APM errors, use the TransactionError event.

Method names

Using code formatting for method names is standard practice.

To initialize the APM agent, use startAgent().

URLs you don't intend to be clicked

Using code formatting hints to the user that they may need to customize or tweak the URL to ensure it works for them.

In your web browser, navigate to the minion Overview page at http://MINION_IP_ADDRESS.

Command line utility names

If you think a reader or translator might confuse a command with a general English word, use code.

  • curl: Sends http requests via a terminal session–not to be confused with the curls you do with weights at the gym.
  • cat: Lists the first ten lines of a file–not a feline pet who ignores you.
  • date: Displays the day, year, and time–not an outing that couples take.
  • tail: Displays the last ten lines of a file–not the appendage on various mammals.
  • which: Show the location of a program executable–not the pronoun.

To install the utility, use apt.

Inline code formatting

To format inline code (like maxSampleTimes or TransactionError), surround the text with backtick ` characters.

Multi-line code blocks

To format one or more lines of code, insert three backticks ( ``` ) above and below your code. This essentially acts like the HTML <pre> tag.

Highlight user input with <var>

The <var> tag is used to highlight areas the user needs to customize the value in a code snippet.

Follow these guidelines when you use <var> tags:

  • Address the reader directly (YOUR_CONFIG_FILE not CONFIG_FILE).
  • Use all caps and underscores _ to separate words (also known as SCREAMING_SNAKE_CASE).
  • Don't combine them with other punctuation to indicate variables (such as wrapping the text in angle brackets or curly braces).
  • Don't overuse them. For example, if you're showing a complete config file where the user is expected to customize many values, a <var> tag on each configurable value is overkill.

Annotate code with <mark>

Use the <mark> tag to highlight areas of a code block that are particularly important. Most commonly, <mark> is used to highlight New Relic API methods in sample code that contains a lot of "other logic." They're also handy when you want to indicate a bit of code that will be referenced later in a procedure or doc.

When you use <mark>, you should usually follow the code block with a list of bullets that explain what each API call is doing and link to method syntax.

Create issueEdit page
Copyright © 2021 New Relic Inc.