Skip to content

Commit

Permalink
Node Env Logging for Sentry Testing (#790)
Browse files Browse the repository at this point in the history
Co-authored-by: Armando Belardo <[email protected]>
  • Loading branch information
dcb6 and armandobelardo authored May 4, 2024
1 parent d672f78 commit 38b43e0
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy-fdr-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jobs:
ALGOLIA_ADMIN_API_KEY: ${{ secrets.ALGOLIA_ADMIN_API_KEY }}
ALGOLIA_SEARCH_INDEX: ${{ secrets.ALGOLIA_SEARCH_INDEX }}
ALGOLIA_SEARCH_API_KEY: ${{ secrets.ALGOLIA_SEARCH_API_KEY }}
APPLICATION_ENVIRONMENT: dev
steps:
- uses: actions/checkout@v4
- name: 📥 Install
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy-fdr-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
ALGOLIA_ADMIN_API_KEY: ${{ secrets.ALGOLIA_ADMIN_API_KEY }}
ALGOLIA_SEARCH_INDEX: ${{ secrets.ALGOLIA_SEARCH_INDEX }}
ALGOLIA_SEARCH_API_KEY: ${{ secrets.ALGOLIA_SEARCH_API_KEY }}
APPLICATION_ENVIRONMENT: prod
steps:
- uses: actions/checkout@v4
- name: 📥 Install
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/diff-fdr-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jobs:
ALGOLIA_ADMIN_API_KEY: ${{ secrets.ALGOLIA_ADMIN_API_KEY }}
ALGOLIA_SEARCH_INDEX: ${{ secrets.ALGOLIA_SEARCH_INDEX }}
ALGOLIA_SEARCH_API_KEY: ${{ secrets.ALGOLIA_SEARCH_API_KEY }}
APPLICATION_ENVIRONMENT: dev
steps:
- uses: actions/checkout@v4
- name: 📥 Install
Expand Down
1 change: 1 addition & 0 deletions servers/fdr-deploy/scripts/fdr-deploy-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export class FdrDeployStack extends Stack {
LOG_LEVEL: getLogLevel(environmentType),
DOCS_CACHE_ENDPOINT: fernDocsCacheEndpoint,
ENABLE_CUSTOMER_NOTIFICATIONS: (environmentType === "PROD").toString(),
APPLICATION_ENVIRONMENT: getEnvironmentVariableOrThrow("APPLICATION_ENVIRONMENT"),
},
containerName: CONTAINER_NAME,
containerPort: 8080,
Expand Down
1 change: 1 addition & 0 deletions servers/fdr/docker-compose.ete.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ services:
ALGOLIA_SEARCH_API_KEY: dummy
SLACK_TOKEN: dummy
ENABLE_CUSTOMER_NOTIFICATIONS: "false"
APPLICATION_ENVIRONMENT: ete
postgres:
image: postgres:10.3
restart: always
Expand Down
1 change: 1 addition & 0 deletions servers/fdr/src/__test__/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export function createMockFdrConfig(): FdrConfig {
slackToken: "",
logLevel: "debug",
enableCustomerNotifications: false,
applicationEnvironment: "mock",
};
}

Expand Down
3 changes: 3 additions & 0 deletions servers/fdr/src/app/FdrConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const ALGOLIA_SEARCH_API_KEY_ENV_VAR = "ALGOLIA_SEARCH_API_KEY";
const SLACK_TOKEN_ENV_VAR = "SLACK_TOKEN";
const LOG_LEVEL_ENV_VAR = "LOG_LEVEL";
const ENABLE_CUSTOMER_NOTIFICATIONS_ENV_VAR = "ENABLE_CUSTOMER_NOTIFICATIONS";
const APPLICATION_ENVIRONMENT_ENV_VAR = "APPLICATION_ENVIRONMENT";

export interface FdrConfig {
venusUrl: string;
Expand All @@ -28,6 +29,7 @@ export interface FdrConfig {
slackToken: string;
logLevel: string;
enableCustomerNotifications: boolean;
applicationEnvironment: string;
}

export function getConfig(): FdrConfig {
Expand All @@ -46,6 +48,7 @@ export function getConfig(): FdrConfig {
slackToken: getEnvironmentVariableOrThrow(SLACK_TOKEN_ENV_VAR),
logLevel: process.env[LOG_LEVEL_ENV_VAR] ?? "info",
enableCustomerNotifications: getEnvironmentVariableOrThrow(ENABLE_CUSTOMER_NOTIFICATIONS_ENV_VAR) === "true",
applicationEnvironment: getEnvironmentVariableOrThrow(APPLICATION_ENVIRONMENT_ENV_VAR),
};
}

Expand Down
4 changes: 2 additions & 2 deletions servers/fdr/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ Sentry.init({
tracesSampleRate: 1.0, // Capture 100% of the transactions
// Set sampling rate for profiling - this is relative to tracesSampleRate
profilesSampleRate: 1.0,
environment: process?.env.NEXT_PUBLIC_APPLICATION_ENVIRONMENT ?? "dev",
environment: config.applicationEnvironment,
maxValueLength: 1000,
// enabled: process.env.NODE_ENV === "production", // Do not enable sentry when running local
enabled: config.applicationEnvironment === "dev" || config.applicationEnvironment == "prod",
});

// The request handler must be the first middleware on the app
Expand Down

0 comments on commit 38b43e0

Please sign in to comment.