Skip to content

Commit

Permalink
refactor: added check for not initializing DD if not confiuration pro…
Browse files Browse the repository at this point in the history
…vided
  • Loading branch information
abdullahwaheed committed May 24, 2024
1 parent d06b234 commit 76f18ed
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/DatadogLoggingService.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ class DatadogLoggingService extends NewRelicLoggingService {
}

initialize() {
const requiredDatadogConfig = [
process.env.DATADOG_APPLICATION_ID,
process.env.DATADOG_CLIENT_TOKEN,
];
const hasRequiredDatadogConfig = requiredDatadogConfig.every(value => !!value);

// Do not attempt to initialize Datadog if required config settings are not supplied.
if (!hasRequiredDatadogConfig) {
return;
}

const datadogVersion = process.env.DATADOG_VERSION || process.env.APP_VERSION || '1.0.0';
datadogRum.init({
applicationId: process.env.DATADOG_APPLICATION_ID || '',
Expand Down

0 comments on commit 76f18ed

Please sign in to comment.