Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CLI command to set log-forwarding config #225

Open
wants to merge 8 commits into
base: epic/log-forwarding
Choose a base branch
from

Conversation

AjazSumaiya
Copy link
Contributor

@AjazSumaiya AjazSumaiya commented Mar 19, 2025

This PR closes https://jira.corp.adobe.com/browse/CEXT-4231

Description

Related Issue

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@@ -0,0 +1,250 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class should be changed to set-log-forwarding-newrelic-.test.js as it is testing newrelic

});

// For MVP, only New Relic is supported
const destinations = ['newrelic'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use an enum for the destination and make it so that we can extend this functionality for other destinations like splunk

// For MVP, only New Relic is supported
const destinations = ['newrelic'];

let meshId = null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to set meshid to null and as a variable as you are getting the meshid in line 52. Changing it to a const is better practice

if (shouldContinue) {
try {
await setLogForwarding(imsOrgCode, projectId, workspaceId, {
destination: 'newrelic',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the enum instead


if (shouldContinue) {
try {
await setLogForwarding(imsOrgCode, projectId, workspaceId, {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should make this code extensible so that we can support other destinations besides newrelic.


return {
success: true,
destination: 'newrelic',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the enum

this.log('Log forwarding details set successfully.');

return {
success: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this success variable used?

} catch (error) {
this.log(error.message);
this.error(
`Failed to set log forwarding details. Please try again. RequestId: ${global.requestId}`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if this fails, we should provide a descriptive message of why it failed or else the user may find it confusing why it failed


if (licenseKey.length !== 40) {
this.error(
`License key has wrong format. Expected: 40 characters (received: ${licenseKey.length})`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`License key has wrong format. Expected: 40 characters (received: ${licenseKey.length})`,
`The license key is in the wrong format. Expected: 40 characters (received: ${licenseKey.length})`,

},
});

this.log('Log forwarding details set successfully.');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
this.log('Log forwarding details set successfully.');
this.log('Log forwarding successful.');

} catch (error) {
this.log(error.message);
this.error(
`Failed to set log forwarding details. Please try again. RequestId: ${global.requestId}`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`Failed to set log forwarding details. Please try again. RequestId: ${global.requestId}`,
`Failed to set log forwarding details. Try again. RequestId: ${global.requestId}`,

Comment on lines 137 to 140
SetLogForwardingCommand.description = `Set log forwarding destination for API mesh.
- Select a log forwarding destination: Choose from available options ( example : newrelic).
- Enter the base URI: Provide the URI for the log forwarding service. Ensure it includes the protocol ( example : \`https://\`).
- Enter the license key: Provide the license key for authentication with the log forwarding service. The key must be 40 characters long.`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SetLogForwardingCommand.description = `Set log forwarding destination for API mesh.
- Select a log forwarding destination: Choose from available options ( example : newrelic).
- Enter the base URI: Provide the URI for the log forwarding service. Ensure it includes the protocol ( example : \`https://\`).
- Enter the license key: Provide the license key for authentication with the log forwarding service. The key must be 40 characters long.`;
SetLogForwardingCommand.description = `Sets the log forwarding destination for API mesh.
- Select a log forwarding destination: Choose from available options ( example : newrelic).
- Enter the base URI: Provide the URI for the log forwarding service. Ensure it includes the protocol ( example : \`https://www.adobe.com\`).
- Enter the license key: Provide the license key for authentication with the log forwarding service. The key must be 40 characters long.`;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants