Skip to content

Commit

Permalink
feat: adds ddog tracer (#4498)
Browse files Browse the repository at this point in the history
* feat: adds ddog tracer

* style: adds new line to env template

* feat: adds ddog-trace to public and partners sites

* feat: adds ddog settings to env templates
  • Loading branch information
seanmalbert authored Dec 4, 2024
1 parent 0e3d9c8 commit e836da8
Show file tree
Hide file tree
Showing 10 changed files with 652 additions and 42 deletions.
10 changes: 10 additions & 0 deletions api/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,13 @@ ENABLE_RECAPTCHA=TRUE
DUPLICATES_PROCESSING_CRON_STRING=15 * * * *
# Date the different AFS cron jobs should use to determine which cron job is applicable for the listing
DUPLICATES_CLOSE_DATE="2024-07-28 00:00 -08:00"
# DataDog environment name
DD_ENV=
# DataDog logs injection
DD_LOGS_INJECTION=false
# DataDog API Key
DD_API_KEY=
# DataDog Site
DD_SITE=
# DataDog Agent Version
DD_AGENT_MAJOR_VERSION=
1 change: 1 addition & 0 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"cookie-parser": "~1.4.6",
"cron": "^3.1.7",
"dayjs": "~1.11.9",
"dd-trace": "^5.28.0",
"dotenv": "^16.4.5",
"exceljs": "^4.4.0",
"express": "^4.21.1",
Expand Down
1 change: 1 addition & 0 deletions api/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import './tracer';
import { NestFactory, HttpAdapterHost } from '@nestjs/core';
import { Logger } from '@nestjs/common';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
Expand Down
15 changes: 15 additions & 0 deletions api/src/tracer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import tracer from 'dd-trace';

if (process.env.DD_API_KEY) {
// see settings @ https://datadoghq.dev/dd-trace-js/#tracer-settings
tracer.init({
profiling: true,
runtimeMetrics: true,
env: process.env.NODE_ENV,
});

// eslint-disable-next-line no-console
console.log('Datadog set up:\nenv', process.env.NODE_ENV);
}

export default tracer;
295 changes: 259 additions & 36 deletions api/yarn.lock

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions sites/partners/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,14 @@ SHOW_LOTTERY=FALSE
APPLICATION_EXPORT_AS_SPREADSHEET=FALSE
# controls use of edit, republish, and reopen functionality when listing is closed
LIMIT_CLOSED_LISTING_ACTIONS=FALSE

# DataDog environment name
DD_ENV=
# DataDog logs injection
DD_LOGS_INJECTION=false
# DataDog API Key
DD_API_KEY=
# DataDog Site
DD_SITE=
# DataDog Agent Version
DD_AGENT_MAJOR_VERSION=
3 changes: 2 additions & 1 deletion sites/partners/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"test:headless": "concurrently \"yarn dev\" \"cypress run\"",
"test:coverage": "yarn nyc report --reporter=text-summary --check-coverage",
"export": "next export",
"start": "next start -p ${NEXTJS_PORT:-3001}",
"start": "NODE_OPTIONS='--require dd-trace/init' next start -p ${NEXTJS_PORT:-3001}",
"dev:new-backend": "cd ../../api && yarn dev",
"dev:server-wait": "wait-on \"http-get://localhost:${PORT:-3100}/\" && yarn dev",
"dev:server-wait-new": "wait-on \"http-get://localhost:3100/\"",
Expand All @@ -39,6 +39,7 @@
"axios-cookiejar-support": "4.0.6",
"clone-deep": "^4.0.1",
"dayjs": "^1.10.7",
"dd-trace": "^5.28.0",
"dotenv": "^8.2.0",
"markdown-to-jsx": "^6.11.4",
"nanoid": "^3.1.12",
Expand Down
13 changes: 12 additions & 1 deletion sites/public/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,15 @@ RECAPTCHA_KEY=
API_PASS_KEY="some-key-here"

# the max number of closed listings to be displayed in the closed listing list
MAX_CLOSED_LISTINGS="20"
MAX_CLOSED_LISTINGS="20"

# DataDog environment name
DD_ENV=
# DataDog logs injection
DD_LOGS_INJECTION=false
# DataDog API Key
DD_API_KEY=
# DataDog Site
DD_SITE=
# DataDog Agent Version
DD_AGENT_MAJOR_VERSION=
3 changes: 2 additions & 1 deletion sites/public/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"test:coverage": "yarn nyc report --reporter=text-summary --check-coverage",
"test:unit": "jest -w 1",
"test:unit:coverage": "jest -w 1 --coverage --watchAll=false",
"start": "next start -p ${NEXTJS_PORT:-3000}",
"start": "NODE_OPTIONS='--require dd-trace/init' next start -p ${NEXTJS_PORT:-3000}",
"test:backend:core:dbsetup": "cd ../../ && yarn test:backend:core:dbsetup",
"dev:new-backend": "cd ../../api && yarn dev",
"dev:server-wait": "wait-on \"http-get://localhost:${PORT:-3100}/\" --httpTimeout 60000 --tcpTimeout 1500 -v --interval 15000 && yarn dev",
Expand All @@ -40,6 +40,7 @@
"axios-cookiejar-support": "4.0.6",
"clone-deep": "^4.0.1",
"dayjs": "^1.10.7",
"dd-trace": "^5.28.0",
"dotenv": "^8.2.0",
"markdown-to-jsx": "^6.11.4",
"next": "^13.2.4",
Expand Down
Loading

0 comments on commit e836da8

Please sign in to comment.