@@ -10,6 +10,7 @@ Zuplo supports logging to the following sources:
1010
1111- DataDog (Beta)
1212- Dynatrace (Beta)
13+ - New Relic (Beta)
1314
1415If you would like to log to a different source, reach out to
[email protected] 1516and we'd be happy to work with you to add a new logging plugin.
@@ -201,3 +202,68 @@ export default async function (request: ZuploRequest, context: ZuploContext) {
201202 return " What zup?" ;
202203}
203204```
205+
206+ ### New Relic (Beta)
207+
208+ By default, we send all metrics to New Relic. However, you have the option below
209+ to configure which metrics you want to send.
210+
211+ New Relic's Metric API provides a powerful way to monitor your API's performance. The metrics are sent to New Relic's Metric API endpoint (https://metric-api.newrelic.com/metric/v1 ) by default, but you can customize this if needed.
212+
213+ ``` ts
214+ import {
215+ RuntimeExtensions ,
216+ NewRelicMetricsPlugin ,
217+ environment ,
218+ } from " @zuplo/runtime" ;
219+
220+ export function runtimeInit(runtime : RuntimeExtensions ) {
221+ runtime .addPlugin (
222+ new NewRelicMetricsPlugin ({
223+ apiKey: environment .NEW_RELIC_API_KEY ,
224+ // Optional: customize the URL if needed
225+ // url: "https://metric-api.newrelic.com/metric/v1",
226+ // You can add custom attributes to all metrics
227+ attributes: {
228+ service: " my-service-name" ,
229+ environment: environment .ENVIRONMENT ?? " DEVELOPMENT" ,
230+ },
231+ metrics: {
232+ latency: true ,
233+ requestContentLength: true ,
234+ responseContentLength: true ,
235+ },
236+ // You can also choose to add additional attributes to include in the metrics
237+ include: {
238+ country: false ,
239+ httpMethod: false ,
240+ statusCode: false ,
241+ path: false ,
242+ },
243+ }),
244+ );
245+ }
246+ ```
247+
248+ The above configuration applies globally for all metrics sent to New Relic. If you
249+ wish to dynamically configure information for a particular ZuploContext, you can
250+ use the ` NewRelicMetricsPlugin ` in your code. Currently, the only configuration
251+ you can set is the attributes. The values you set here will be appended to those set
252+ globally in the ` zuplo.runtime.ts ` file.
253+
254+ ``` ts
255+ import {
256+ ZuploContext ,
257+ ZuploRequest ,
258+ NewRelicMetricsPlugin ,
259+ } from " @zuplo/runtime" ;
260+
261+ export default async function (request : ZuploRequest , context : ZuploContext ) {
262+ const someValue = " hello" ;
263+ NewRelicMetricsPlugin .setContext (context , {
264+ attributes: { " my-custom-attribute" : someValue },
265+ });
266+
267+ return " What zup?" ;
268+ }
269+ ```
0 commit comments