Skip to content

Commit

Permalink
chore: Added table of contents to help community navigate the examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
bizob2828 committed Jul 15, 2024
1 parent 542f377 commit 779bd0e
Show file tree
Hide file tree
Showing 133 changed files with 104 additions and 8 deletions.
23 changes: 20 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,24 @@

# New Relic Node.js Examples

This repository will contain examples of agent features. Browse the folders for different self-contained, working examples.
This repository contains example application and scripts that demonstrate functionality of the [New Relic Node.js Agent](https://github.com/newrelic/node-newrelic).

* [AI Monitoring](./ai-monitoring) - examples using supported 3rd party libraries to produce AI Monitoring(AIM) telemetry
* [Logs in Context](./application-logging) - examples using logging libraries to demonstrate agent log decoration and forwarding of logs to New Relic
* [Code Level Metrics](./code-level-metrics) - example demonstrating span attributes that help drive the [CodeStream](https://newrelic.com/codestream) integration
* [Custom Instrumentation](./custom-instrumentation) - examples demonstrating the use of the [Node.js agent API](https://newrelic.github.io/node-newrelic/API.html)
* [Elasticsearch](./elasticsearch) - example demonstrating elasticsearch with Node.js agent
* [Error Fingerprinting](./error-fingerprinting) - example using [setErrorCallback](https://newrelic.github.io/node-newrelic/API.html#setErrorGroupCallback) and [noticeError](https://newrelic.github.io/node-newrelic/API.html#noticeError) to [group errors](https://docs.newrelic.com/docs/errors-inbox/errors-inbox/#error-groups) produced in Node.js application
* [ESM](./esm-app) - example demonstrating how to load agent in an [ESM](https://nodejs.org/api/esm.html) application. It also demonstrates how to register custom instrumentation for a ESM package.
* [GraphQL Dataloader](./graphql-koa-dataloader) - example using Apollo Server, koa and GraphQL dataloader
* [Kafkajs](./kafkajs) - example demonstrating [kafkajs](https://kafka.js.org/) with Node.js agent
* [Mock Infinite Tracing Server](./mock-infinite-tracing-server) - mock gRPC server to use to locally test [infinite tracing](https://docs.newrelic.com/docs/distributed-tracing/infinite-tracing/introduction-infinite-tracing/) with a Node.js applciation
* [Nest](./nestjs) - examples demonstrating Nestjs with Node.js agent
* [Next.js](./nextjs) - examples demonstrating Next.js with Node.js agent
* [Prisma](./prisma-app) - example demonstrating Prisma with Node.js agent
* [Sequelize](./sequelize-app) - example demonstrating sequelize with Node.js agent
* [Express](./simple-express-app) - example demonstrating express with Node.js agent
* [Source Maps](./source-maps) - typescript example using [--enable-source-maps](https://nodejs.org/dist/latest-v22.x/docs/api/cli.html#--enable-source-maps) to demonstrate proper stack traces the Node.js agent produces

## Contribute

Expand All @@ -14,11 +31,11 @@ If you have any questions, or to execute our corporate CLA (which is required if

As noted in our [security policy](../../security/policy), New Relic is committed to the privacy and security of our customers and their data. We believe that providing coordinated disclosure by security researchers and engaging with the security community are important means to achieve our security goals.

If you believe you have found a security vulnerability in this project or any of New Relic's products or websites, we welcome and greatly appreciate you reporting it to New Relic through [HackerOne](https://hackerone.com/newrelic).
If you believe you have found a security vulnerability in this project or any of New Relic's products or websites, we welcome and greatly appreciate you reporting it to New Relic through [our bug bounty program](https://docs.newrelic.com/docs/security/security-privacy/information-security/report-security-vulnerabilities/).

If you would like to contribute to this project, review [these guidelines](./CONTRIBUTING.md).

To all contributors, we thank you! Without your contribution, this project would not be what it is today.
To [all contributors](https://github.com/newrelic/newrelic-node-examples/graphs/contributors), we thank you!

## License
New Relic Node.js Examples is licensed under the [Apache 2.0](http://apache.org/licenses/LICENSE-2.0.txt) License.
7 changes: 7 additions & 0 deletions ai-monitoring/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## AI Monitoring

This folder contains example applications interacting with various LLM libraries that produce [AI monitoring telemetry](https://docs.newrelic.com/docs/ai-monitoring/intro-to-ai-monitoring/)

* [AWS Bedrock](./aws-bedrock-app) - AWS Bedrock example that can make requests to all [supported LLM models](https://aws.amazon.com/ai/generative-ai/).
* [Langchain](./langchain) - [Langchain.js](https://js.langchain.com/v0.2/docs/introduction/) example that interacts with chains, vector stores, and tools.
* [OpenAI](./openai) - [OpenAI](https://github.com/openai/openai-node) example that can make requests to create chat completions and embeddings.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions application-logging/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Application Logging

This folder contains example applications interacting with various logging libraries that provide [logs in context](https://docs.newrelic.com/docs/logs/logs-context/configure-logs-context-nodejs/)

* [ESM logs in context](./esm-logs-in-context) - An [ESM](https://nodejs.org/api/esm.html) application that uses winston to create logs.
* [Log generator](./log-generator) - An application used to produce logs with either winston or pino.
* [Log enrichers](./legacy-logs-in-context) - **deprecated** - An application that uses deprecated log enrichers for pino and winston.
3 changes: 3 additions & 0 deletions custom-instrumentation/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
## Custom instrumentation
This folder contains example applications using the [Agent API](https://newrelic.github.io/node-newrelic/API.html) to do custom instrumentation.

* [instrumentMessages](./instrument-messages) - example application that uses the [newrelic.instrumentMessages](https://newrelic.github.io/node-newrelic/API.html#instrumentMessages) and associated [messaging shim API](https://newrelic.github.io/node-newrelic/MessageShim.html) to instrument a toy messaging library called Nifty Messages
* [instrumentWebframework](./instrument-webframework ) - example application that uses the [newrelic.instrumentWebframework](https://newrelic.github.io/node-newrelic/API.html#instrumentWebframework) and associated [WebFramework shim API](https://newrelic.github.io/node-newrelic/WebFrameworkShim.html) to instrument a hypothetical web framework
31 changes: 31 additions & 0 deletions mock-infinite-tracing-server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Mock Infinite Tracing gRPC Server

This is a gRPC server used to test our [infinite tracing](https://docs.newrelic.com/docs/distributed-tracing/infinite-tracing/introduction-infinite-tracing/) with the Node.js agent.


## Setup

To setup gRPC run

```sh
npm install
node index.js
```

## Test

Once the gPRC server is started, you can use it in an example application and set the following in `newrelic.js`


```js
exports.config = {
license_key: <your-license-key>,
infinite_tracing: {
trace_observer: {
host: 'localhost:50051
}
}
}
```
As you use the application the mock gPRC server will log to console the number of spans seen.
9 changes: 4 additions & 5 deletions nestjs/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
This is an example of an instrumented Nest.js app, using Prisma and Winston.
# Nestjs examples

Get it running:
This folder contains 2 different [Nestjs](https://github.com/nestjs/nest) examples that demonstrate producing telemetry with the Node.js agent.

1. Copy sample.env to .env
2. Edit .env to add your New Relic ingest key, and any other desired changes.
3. Start with `docker-compose up --build`.
* [basic Nestjs example](./nestjs-example) - full Nestjs example to demonstrate the telemetry the agent provides
* [Nestjs example with agent config as typescript](./nestjs-config-file) - Nestjs example application that relies on agent configuration as `newrelic.ts`
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions nestjs/nestjs-example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
This is an example of an instrumented Nest.js app, using Prisma and Winston.

Get it running:

1. Copy sample.env to .env
2. Edit .env to add your New Relic ingest key, and any other desired changes.
3. Start with `docker-compose up --build`.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions nextjs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Next.js examples

This folder contains Next.js example applications that leverage its different routers and demonstrate the telemetry the Node.js agent provides.

* [App Router](./nextjs-app-router) - Example using [App Router](https://nextjs.org/docs/app)
* [Pages Router](./nextjs-legacy) - Example using [Pages Router](https://nextjs.org/docs/pages)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions simple-express-app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Express example

This example application uses [express](https://github.com/expressjs/express) and has 2 endpoints to demonstrate telemetry produced by Node.js agent with express and AWS SNS.

## Setup

1. Run `npm install`
1. Start application with `NEW_RELIC_LICENSE_KEY=<your-key> node index.js`


## Test

Once the application is started you can make requests to the 2 endpoints to see the telemetry it generates.


```sh
curl http://localhost:3000/named-route
curl http://localhost:3000/sns
```

0 comments on commit 779bd0e

Please sign in to comment.