We use a variety of formatting to highlight code or other technical language. You can use the <code>
, <pre>
, and <var>
tags to indicate "raw" technical content such as excerpts from a config file, an API method name, or a file path.
To surround small blocks of code or data (single words or lines), mark as code:
- Source: Use
<code>
tags. - Markdown: Surround the text with backtick
`
characters.
To surround longer blocks of data that run multiple lines, mark as preformatted text:
- Source: Use
<pre>
tags. - Markdown: Do not use Markdown-style indented code formatting, as this can cause unexpected formatting problems.
Use the <var>
tag to highlight areas of a code block where a user is expected to supply their own value. For more context on when to use <var>
tags, see <var> formatting guidelines.
Follow these guidelines when you use <var>
tags:
Address the reader directly
Use all caps and underscores
_
to separate words (also known as SCREAMING_SNAKE_CASE).Don't use other punctuation (such as wrapping the text in angle brackets). Exception: REST API examples use a
${VARNAME}
syntax inspired by Bash conventions.Standard examples:
echo "license_key: YOUR_LICENSE_KEY" | sudo tee -a /etc/newrelic-infra.yml
msiexec.exe /qn /i PATH\TO\newrelic-infra.msi
https://rpm.newrelic.com/accounts/ACCOUNT_ID/applications/APP_ID
REST API v2 example:
curl -X GET "https://api.newrelic.com/v2/applications/${APPID}/metrics/data.xml" \ -H "X-Api-Key:${APIKEY}" -i \ -d 'names[]=HttpDispatcher&values[]=average_call_time&values[]=call_count&from=2014-03-01T20:59:00+00:00&to=2014-03-01T21:59:00+00:00&summarize=true'
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." 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. For more context on when to use <mark>
tags, see <mark> formatting guidelines.
Examples:
Example of using the <mark>
tag
private void storeItem(long id) {
Segment segment = NewRelic.getAgent().getTransaction().startSegment("storeItem");
segment.reportAsExternal(DatastoreParameters
.product("H2")
.collection(null)
.operation("insert")
.instance("localhost", 8080)
.databaseName("test")
.build());
// fire and forget
DB_POOL.submit(() -> {
segment.end();
insertData(id);
});
}
The agent API calls in this sample are:
startSegment(...)
: Begins the segment that will time the code. For method syntax, see the Javadoc.reportAsExternal(DatastoreParameters())
: Associates the time with a datastore external call This will show up in APM with datastore data. For more information, see reportAsExternal API. For method syntax, see the Javadoc.segment.end()
: Stops timing this segment. For method syntax, see the Javadoc.
To add syntax highlighting to a code block, add class="highlight"
to the <pre>
tag. The syntax highlighter tries to auto-detect the language. If it's not working as expected, ensure the language is supported and specify the language by adding the a lang-LANG-NAME
class (for example: lang-html)
.
View a full list of supported languages for syntax highlighting. Element colors and themes are fully customizable.
You can add <a href>
tags inside a <pre>
blocks, just as you would any other content. However, make sure to use them judiciously since they can be easy to miss. A good example is the Infrastructure config file template, where each config element links to the relevant section of the main config doc.
その他のヘルプ
さらに支援が必要な場合は、これらのサポートと学習リソースを確認してください:
- Explorers Hubでは、コミュニティからのサポートを受けたり、ディスカッションに参加したりすることができます。
- 当社サイトで答えを見つけて、サポートポータルの使用方法を確認してください。
- Linux、Windows、およびmacOS向けトラブルシューティングツールであるNew Relic Diagnosticsを実行してください。
- New Relicの とandドキュメント をご確認ください。