Skip to content

Commit

Permalink
refactor(publish-metrics): warning instead of throwing when no api set
Browse files Browse the repository at this point in the history
  • Loading branch information
InesNi committed Feb 20, 2024
1 parent 5e119dd commit 08672ad
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ function getADOTEnvVars(adotRelevantconfigs, dotenv) {
Object.assign(envVars, vendorVars);
});
} catch (err) {
throw new Error(err);
// We warn here instead of throwing because in the future we will support providing these variables through secrets
console.warn(err.message);
}
return envVars;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,16 @@ test('when getADOTEnvVars is called with a list of adotRelevantconfigs and a dot
});

// Maybe remove throwing an error in the function itself as it propagates to the resolveADOTConfigSettings and then we can handle it there
test('when getADOTEnvVars is called with an unsupported vendor, it throws an error', async (t) => {
test('if an error happens in getADOTEnvVars it logs the error message and returns the current state of envVars variable ', async (t) => {
const adotRelevantconfigs = [
{
type: 'unsupportedVendor',
type: 'datadog',
tracing: {}
}
];
const dotenv = {
DD_API_KEY: '123'
};
t.throws(() => getADOTEnvVars(adotRelevantconfigs, dotenv));
const dotenv = {};
const result = getADOTEnvVars(adotRelevantconfigs, dotenv);
t.same(result, {});
});

test('when getADOTEnvVars is called with an empty list of adotRelevantconfigs and an empty dotenv object it returns an empty object', async (t) => {
Expand Down

0 comments on commit 08672ad

Please sign in to comment.