You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+36-31
Original file line number
Diff line number
Diff line change
@@ -31,7 +31,7 @@ To use New Relic's Node.js agent entails these three steps, which are described
31
31
32
32
3. Now, add your New Relic license key and application/service name to that file:
33
33
34
-
```js
34
+
```js
35
35
/* File: newrelic.js */
36
36
'use strict'
37
37
/**
@@ -45,30 +45,29 @@ To use New Relic's Node.js agent entails these three steps, which are described
45
45
license_key: 'your new relic license key',
46
46
/* ... rest of configuration .. */
47
47
}
48
-
```
48
+
```
49
49
50
50
4. Finally, run your program with the `newrelic` module loaded first by using node's `-r/--require` flag.
51
51
52
-
```
53
-
$ node -r newrelic your-program.js
54
-
```
52
+
```sh
53
+
$ node -r newrelic your-program.js
54
+
```
55
55
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.
57
57
58
-
```js
58
+
```js
59
59
const newrelic = require('newrelic')
60
60
61
61
/* ... the rest of your program ... */
62
-
```
62
+
```
63
63
64
64
## Next.js instrumentation
65
65
**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).
66
66
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 forNext.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 orin 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).
68
68
69
69
Here are documents for more in-depth explanations about [transaction naming](./documentation/nextjs/transactions.md), and [segments/spans](./documentation/nextjs/segments-and-spans.md).
70
70
71
-
72
71
### Setup
73
72
Typically you are running a Next.js app with the `next` cli and you must load the agent via `NODE_OPTIONS`:
74
73
@@ -102,15 +101,15 @@ The New Relic Node.js agent includes ***_experimental_*** support for ES Modules
102
101
103
102
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.
104
103
105
-
```sh
106
-
$ mv newrelic.js newrelic.cjs
107
-
```
104
+
```sh
105
+
$ mv newrelic.js newrelic.cjs
106
+
```
108
107
109
108
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:
shim.wrap(parseJson.default, function wrapParseJson(shim, orig) {
125
-
returnfunctionwrappedParseJson() {
126
-
constresult=orig.apply(this, arguments)
127
-
result.instrumented=true
128
-
returntrue
129
-
}
124
+
return function wrappedParseJson() {
125
+
const result = orig.apply(this, arguments)
126
+
result.instrumented = true
127
+
return true
128
+
}
130
129
})
131
130
})
132
131
```
@@ -151,11 +150,11 @@ For more information on getting started, [check the Node.js docs](https://docs.n
151
150
152
151
There are modules that can be installed and configured to accompany the Node.js agent:
153
152
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.
155
154
156
155
There are modules included within the Node.js agent to add more instrumentation for 3rd party modules:
157
156
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.
159
158
160
159
## Usage
161
160
@@ -164,10 +163,10 @@ There are modules included within the Node.js agent to add more instrumentation
164
163
The `newrelic` module returns an object with the Node.js agent's API methods attached.
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:
182
181
183
182
1. [Fork](https://github.com/newrelic/node-newrelic/fork) and clone this GitHub repository:
0 commit comments