Skip to content

Commit 15cb454

Browse files
authored
chore: Clarified supported next.js middleware versions in docs (#2984)
1 parent c641645 commit 15cb454

File tree

1 file changed

+36
-31
lines changed

1 file changed

+36
-31
lines changed

README.md

+36-31
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ To use New Relic's Node.js agent entails these three steps, which are described
3131
3232
3. Now, add your New Relic license key and application/service name to that file:
3333
34-
```js
34+
```js
3535
/* File: newrelic.js */
3636
'use strict'
3737
/**
@@ -45,30 +45,29 @@ To use New Relic's Node.js agent entails these three steps, which are described
4545
license_key: 'your new relic license key',
4646
/* ... rest of configuration .. */
4747
}
48-
```
48+
```
4949
5050
4. Finally, run your program with the `newrelic` module loaded first by using node's `-r/--require` flag.
5151

52-
```
53-
$ node -r newrelic your-program.js
54-
```
52+
```sh
53+
$ node -r newrelic your-program.js
54+
```
5555

56-
If you cannot control how your program is run, you can load the `newrelic` module _before any other module_ in your program.
56+
If you cannot control how your program is run, you can load the `newrelic` module _before any other module_ in your program.
5757

58-
```js
58+
```js
5959
const newrelic = require('newrelic')
6060
6161
/* ... the rest of your program ... */
62-
```
62+
```
6363

6464
## Next.js instrumentation
6565
**Note**: The minimum supported Next.js version is [12.0.9](https://github.com/vercel/next.js/releases/tag/v12.0.9). If you are using Next.js middleware the minimum supported version is [12.2.0](https://github.com/vercel/next.js/releases/tag/v12.2.0).
6666

67-
The New Relic Node.js agent provides instrumentation for Next.js The instrumentation provides telemetry for server-side rendering via [getServerSideProps](https://nextjs.org/docs/basic-features/data-fetching/get-server-side-props), [middleware](https://nextjs.org/docs/middleware), and New Relic transaction naming for both page and server requests. It does not provide any instrumentation for actions occurring during build or in client-side code. If you want telemetry data on actions occurring on the client (browser), you can [inject the browser agent](./documentation/nextjs/faqs/browser-agent.md).
67+
The New Relic Node.js agent provides instrumentation for Next.js The instrumentation provides telemetry for server-side rendering via [`getServerSideProps`](https://nextjs.org/docs/basic-features/data-fetching/get-server-side-props), [middleware](https://nextjs.org/docs/middleware) (limited to Next.js versions [12.2.0](https://github.com/vercel/next.js/releases/tag/v12.2.0) - [13.4.12](https://github.com/vercel/next.js/releases/tag/v13.4.12)), and New Relic transaction naming for both page and server requests. It does not provide any instrumentation for actions occurring during build or in client-side code. If you want telemetry data on actions occurring on the client (browser), you can [inject the browser agent](./documentation/nextjs/faqs/browser-agent.md).
6868

6969
Here are documents for more in-depth explanations about [transaction naming](./documentation/nextjs/transactions.md), and [segments/spans](./documentation/nextjs/segments-and-spans.md).
7070

71-
7271
### Setup
7372
Typically you are running a Next.js app with the `next` cli and you must load the agent via `NODE_OPTIONS`:
7473

@@ -102,15 +101,15 @@ The New Relic Node.js agent includes ***_experimental_*** support for ES Modules
102101
103102
1. If you rely on a configuration file to run the agent, you must rename the file from `newrelic.js` to `newrelic.cjs` so it can be properly loaded. All the contents of the configuration file will behave the same once you rename. See [CommonJS modules in ESM](https://nodejs.org/api/modules.html#enabling) for more details.
104103
105-
```sh
106-
$ mv newrelic.js newrelic.cjs
107-
```
104+
```sh
105+
$ mv newrelic.js newrelic.cjs
106+
```
108107
109108
2. To use the newrelic ESM loader, start your program with node and use the `--experimental-loader` flag and a path to the loader file, like this:
110109
111-
```sh
112-
$ node --experimental-loader newrelic/esm-loader.mjs -r newrelic your-program.js
113-
```
110+
```sh
111+
$ node --experimental-loader newrelic/esm-loader.mjs -r newrelic your-program.js
112+
```
114113
115114
**Note**: Unlike the CommonJS methods listed above, there are no alternatives to running the agent without the `--experimental-loader` flag.
116115
@@ -122,11 +121,11 @@ The agent supports adding your own custom instrumentation to ES module applicati
122121
import newrelic from 'newrelic'
123122
newrelic.instrument({ moduleName: 'parse-json', isEsm: true }, function wrap(shim, parseJson, moduleName) {
124123
shim.wrap(parseJson.default, function wrapParseJson(shim, orig) {
125-
return function wrappedParseJson() {
126-
const result = orig.apply(this, arguments)
127-
result.instrumented = true
128-
return true
129-
}
124+
return function wrappedParseJson() {
125+
const result = orig.apply(this, arguments)
126+
result.instrumented = true
127+
return true
128+
}
130129
})
131130
})
132131
```
@@ -151,11 +150,11 @@ For more information on getting started, [check the Node.js docs](https://docs.n
151150
152151
There are modules that can be installed and configured to accompany the Node.js agent:
153152
154-
* [@newrelic/apollo-server-plugin](https://github.com/newrelic/newrelic-node-apollo-server-plugin): New Relic's official Apollo Server plugin for use with the Node.js agent.
153+
* [`@newrelic/apollo-server-plugin`](https://github.com/newrelic/newrelic-node-apollo-server-plugin): New Relic's official Apollo Server plugin for use with the Node.js agent.
155154

156155
There are modules included within the Node.js agent to add more instrumentation for 3rd party modules:
157156

158-
* [@newrelic/native-metrics](https://github.com/newrelic/node-native-metrics): Provides hooks into the native v8 layer of Node.js to provide metrics to the Node.js agent.
157+
* [`@newrelic/native-metrics`](https://github.com/newrelic/node-native-metrics): Provides hooks into the native v8 layer of Node.js to provide metrics to the Node.js agent.
159158

160159
## Usage
161160

@@ -164,10 +163,10 @@ There are modules included within the Node.js agent to add more instrumentation
164163
The `newrelic` module returns an object with the Node.js agent's API methods attached.
165164
166165
```js
167-
const newrelic = require('newrelic')
166+
const newrelic = require('newrelic')
168167
169-
/* ... */
170-
newrelic.addCustomAttribute('some-attribute', 'some-value')
168+
/* ... */
169+
newrelic.addCustomAttribute('some-attribute', 'some-value')
171170
```
172171
173172
You can read more about using the API over on the [New Relic documentation](https://docs.newrelic.com/docs/agents/nodejs-agent/api-guides/guide-using-nodejs-agent-api) site.
@@ -182,12 +181,16 @@ These are the steps to work on core agent features, with more detail below:
182181
183182
1. [Fork](https://github.com/newrelic/node-newrelic/fork) and clone this GitHub repository:
184183
184+
```sh
185185
$ git clone [email protected]:your-user-name/node-newrelic.git
186186
$ cd node-newrelic
187+
```
187188
188189
2. Install the project's dependencies:
189190

191+
```sh
190192
$ npm install
193+
```
191194

192195
Then you're all set to start programming.
193196
@@ -199,11 +202,13 @@ Then you're all set to start programming.
199202
200203
Available test suites include:
201204
202-
$ npm run unit
203-
$ npm run integration
204-
$ npm run versioned
205-
$ npm run lint
206-
$ npm run smoke
205+
```sh
206+
$ npm run unit
207+
$ npm run integration
208+
$ npm run versioned
209+
$ npm run lint
210+
$ npm run smoke
211+
```
207212
208213
## Further Reading
209214

0 commit comments

Comments
 (0)