Skip to content

Commit

Permalink
new relic instrumentation
Browse files Browse the repository at this point in the history
  • Loading branch information
jackiequach committed Oct 6, 2022
1 parent 8e7970d commit 3a9b7d4
Show file tree
Hide file tree
Showing 9 changed files with 843 additions and 74 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build-production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ jobs:
ECR_REPOSITORY: sfr-front-end
IMAGE_TAG: ${{ github.sha }}
AIRTABLE_KEY: ${{ secrets.AIRTABLE_API_KEY }}
NEW_RELIC_LICENSE_KEY: ${{ secrets.NEW_RELIC_LICENSE_KEY }}
run: |
docker build --build-arg airtable_api_key=$AIRTABLE_KEY -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker build --build-arg airtable_api_key=$AIRTABLE_KEY -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG --build-arg NEW_RELIC_APP_NAME="Digital Research Books (PROD)" --build-arg NEW_RELIC_LICENSE_KEY=$NEW_RELIC_LICENSE_KEY .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:latest
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/build-qa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ jobs:
ECR_REPOSITORY: sfr-front-end
IMAGE_TAG: ${{ github.sha }}
AIRTABLE_KEY: ${{ secrets.AIRTABLE_API_KEY }}
NEW_RELIC_LICENSE_KEY: ${{ secrets.NEW_RELIC_LICENSE_KEY }}
run: |
docker build --build-arg airtable_api_key=$AIRTABLE_KEY -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker build --build-arg airtable_api_key=$AIRTABLE_KEY -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG --build-arg NEW_RELIC_APP_NAME="Digital Research Books (QA)" --build-arg NEW_RELIC_LICENSE_KEY=$NEW_RELIC_LICENSE_KEY .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:latest
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ build

# troubleshooting files
vega.feature
vega.spec.ts
vega.spec.ts

# New Relic
newrelic_agent.log
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ WORKDIR /

ARG airtable_api_key

# Newrelic settings
ARG NEW_RELIC_LICENSE_KEY
ARG NEW_RELIC_APP_NAME

# Set environment variables. NODE_ENV is set early because we
# want to use it when running `npm install` and `npm run build`.
ENV PATH /app/node_modules/.bin:$PATH
Expand All @@ -17,6 +21,8 @@ ENV PORT=3000 \
ENV NEXT_PUBLIC_AIRTABLE_API_KEY $airtable_api_key
# Sets READER_VERSION at build time. To revert, remove this variable entirely.
ENV NEXT_PUBLIC_READER_VERSION=v2
ENV NEW_RELIC_LICENSE_KEY $NEW_RELIC_LICENSE_KEY
ENV NEW_RELIC_APP_NAME $NEW_RELIC_APP_NAME

# Install dependencies.
COPY package.json package-lock.json ./
Expand Down
63 changes: 63 additions & 0 deletions newrelic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
"use strict";

require("dotenv").config();
/**
* New Relic agent configuration.
*
* See lib/config/default.js in the agent distribution for a more complete
* description of configuration variables and their potential values.
*/
exports.config = {
/**
* Array of application names.
*/
app_name: process.env.NEW_RELIC_APP_NAME,
/**
* Your New Relic license key.
*/
license_key: process.env.NEW_RELIC_LICENSE_KEY,
logging: {
/**
* Level at which to log. 'trace' is most useful to New Relic when diagnosing
* issues with the agent, 'info' and higher will impose the least overhead on
* production applications.
*/
level: "info",
},
/**
* When true, all request headers except for those listed in attributes.exclude
* will be captured for all traces, unless otherwise specified in a destination's
* attributes include/exclude lists.
*/
allow_all_headers: true,
application_logging: {
forwarding: {
/**
* Toggles whether the agent gathers log records for sending to New Relic.
*/
enabled: true,
},
},
attributes: {
/**
* Prefix of attributes to exclude from all destinations. Allows * as wildcard
* at end.
*
* NOTE: If excluding headers, they must be in camelCase form to be filtered.
*
* @env NEW_RELIC_ATTRIBUTES_EXCLUDE
*/
exclude: [
"request.headers.cookie",
"request.headers.authorization",
"request.headers.proxyAuthorization",
"request.headers.setCookie*",
"request.headers.x*",
"response.headers.cookie",
"response.headers.authorization",
"response.headers.proxyAuthorization",
"response.headers.setCookie*",
"response.headers.x*",
],
},
};
Loading

0 comments on commit 3a9b7d4

Please sign in to comment.