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

chore: span push and sentry logs #36682

Merged
merged 5 commits into from
Oct 7, 2024
Merged

Conversation

ApekshaBhosale
Copy link
Contributor

@ApekshaBhosale ApekshaBhosale commented Oct 3, 2024

Description

Tip

Add a TL;DR when the description is longer than 500 words or extremely technical (helps the content, marketing, and DevRel team).

Please also include relevant motivation and context. List any dependencies that are required for this change. Add links to Notion, Figma or any other documents that might be relevant to the PR.

Fixes #Issue Number
or
Fixes Issue URL

Warning

If no issue exists, please create an issue first, and check with the maintainers if the issue is valid.

Automation

/ok-to-test tags="@tag.All"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/11182676913
Commit: c93c9dc
Cypress dashboard.
Tags: @tag.All
Spec:


Fri, 04 Oct 2024 16:45:18 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Enhanced error tracking for user creation, login, and sign-up processes with Sentry integration.
    • Added new constants for authentication and authorization processes to improve logging and tracing.
  • Bug Fixes

    • Improved error handling for user sign-up failures.
  • Documentation

    • Updated tracing configuration to include additional criteria for Appsmith-specific spans, enhancing logging for login and signup activities.

Copy link
Contributor

coderabbitai bot commented Oct 3, 2024

Walkthrough

The pull request introduces several modifications across four files. In userSagas.tsx, Sentry is integrated for enhanced error tracking during user creation. The Login.tsx and SignUp.tsx components are similarly updated to improve error handling with Sentry. Additionally, new constants AUTHENTICATE and AUTHORIZE are added to the BaseSpan class, which likely pertain to authentication processes. The TracingConfig class is updated to include logging capabilities and broaden the criteria for filtering Appsmith-specific spans, now encompassing authentication-related spans.

Changes

File Change Summary
app/client/src/ce/sagas/userSagas.tsx Added imports for Sentry and its Severity. Enhanced error handling in createUserSaga using Sentry.captureException.
app/client/src/pages/UserAuth/Login.tsx Added imports for Sentry and its Severity. Enhanced error handling in the Login function using Sentry.captureException.
app/client/src/pages/UserAuth/SignUp.tsx Added imports for Sentry and its Severity. Enhanced error handling in handleSubmit using Sentry.captureException.
app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/BaseSpan.java Added new constants AUTHENTICATE = "authenticate"; and AUTHORIZE = "authorize"; to BaseSpan class.
app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/TracingConfig.java Added @Slf4j annotation for logging. Imported AUTHENTICATE and AUTHORIZE constants and expanded logic in onlyAppsmithSpans method.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UserSagas
    participant Login
    participant SignUp
    participant Sentry

    User->>UserSagas: Create User
    UserSagas->>UserSagas: Attempt to create user
    alt Error occurs
        UserSagas->>Sentry: captureException(error)
    end

    User->>Login: Attempt to log in
    alt Error occurs
        Login->>Sentry: captureException(error)
    end

    User->>SignUp: Attempt to sign up
    alt Error occurs
        SignUp->>Sentry: captureException(error)
    end
Loading

Possibly related PRs

Suggested labels

Task

Suggested reviewers

  • sharat87
  • AnaghHegde
  • pratapaprasanna

Poem

In the code where errors lay,
Sentry now lights the way.
With constants new and logging bright,
Authentication takes its flight!
A saga's tale, a tracing quest,
In code we trust, we do our best! 🎉


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 042a2ea and c93c9dc.

📒 Files selected for processing (1)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/TracingConfig.java (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/TracingConfig.java

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ApekshaBhosale
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

github-actions bot commented Oct 3, 2024

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/11164876382.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 36682.
recreate: .

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (3)
app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/TracingConfig.java (2)

14-14: Excellent addition to our imports, students!

I see you've imported the AUTHENTICATE constant. This is a good step towards making our code more readable and maintainable. However, let's take this opportunity for a quick lesson:

When we're importing constants, it's often beneficial to import the entire class statically, rather than individual constants. This can make our code more flexible if we need to use other constants from the same class in the future.

Consider changing the import to:

import static com.appsmith.external.constants.spans.BaseSpan.*;

This way, we'll have access to all constants in the BaseSpan class without needing to modify our imports again.


51-54: Well done on expanding our span inclusion criteria!

I'm impressed with how you've broadened our span filtering to include authentication-related spans. This is a significant improvement that will enhance our tracing capabilities. Let's break it down:

  1. We're still including server-side spans and those with the APPSMITH_SPAN_PREFIX.
  2. We've added conditions for spans starting with AUTHENTICATE or "authorize".

This is good work, but let's make it even better with a small suggestion:

Consider extracting the "authorize" string as a constant, similar to AUTHENTICATE. This will improve consistency and make future modifications easier. For example:

private static final String AUTHORIZE_PREFIX = "authorize";

// Then in the method:
|| finishedSpan.getName().startsWith(AUTHENTICATE)
|| finishedSpan.getName().startsWith(AUTHORIZE_PREFIX)

Remember, constants make our code more maintainable and less prone to typos. Keep up the excellent work, class!

app/client/src/ce/sagas/userSagas.tsx (1)

133-138: Excellent error handling, A+ work!

You've shown great initiative in capturing exceptions with Sentry. This will help us keep a close eye on any sign-up troubles. Remember, class, always be kind to your users and help them when they stumble!

However, let's make sure we're using our vocabulary correctly. Instead of "Sign up failed", let's be more specific:

Consider changing the error message to be more descriptive:

-    Sentry.captureException("Sign up failed", {
+    Sentry.captureException("User creation failed", {
       level: Severity.Error,
       extra: {
         error: error,
       },
     });

This way, we're being precise about what exactly failed. Precision is key in programming, just like in spelling tests!

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 9e2fb95 and 7d7d260.

📒 Files selected for processing (3)
  • app/client/src/ce/sagas/userSagas.tsx (2 hunks)
  • app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/BaseSpan.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/TracingConfig.java (2 hunks)
🔇 Additional comments (3)
app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/TracingConfig.java (1)

8-8: Very good, class! Let's add some logging capabilities.

I'm pleased to see you've imported the Slf4j logger. This will allow us to add informative log messages to our code, which is always a smart practice. Keep up the good work!

app/client/src/ce/sagas/userSagas.tsx (2)

91-92: Good job on importing Sentry, class!

I see you've added Sentry to our toolkit. That's a gold star for improved error tracking! Remember, children, always keep an eye on those pesky errors.


Line range hint 1-1006: Overall assessment: Great progress, keep up the good work!

Class, today we've learned an important lesson about error handling. These changes will help us better understand when our users have trouble signing up. Remember, in the world of programming, being able to see and understand our mistakes is just as important as getting things right the first time. Keep up the excellent work, and don't forget to always be learning!

Copy link

github-actions bot commented Oct 3, 2024

Deploy-Preview-URL: https://ce-36682.dp.appsmith.com

@ApekshaBhosale
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

github-actions bot commented Oct 3, 2024

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/11166073058.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 36682.
recreate: .

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (2)
app/client/src/pages/UserAuth/SignUp.tsx (2)

138-143: Excellent work on error handling, but let's make it even better!

You've done a splendid job integrating Sentry for error tracking. It's like giving our code a fancy new pair of glasses to spot troubles! However, we can make this even more helpful for our users.

Here's a little homework for you:

  1. Consider adding a user-friendly error message to display on the UI.
  2. Think about categorizing errors to provide more specific feedback.
  3. Maybe we could add some logging to help us troubleshoot locally too!

Remember, clear communication is key, both in the classroom and in our code!


Line range hint 1-324: A gold star for your efforts in improving our SignUp process!

Class, let's take a moment to appreciate the fine work done here. Our SignUp component has gotten a nice upgrade, like getting a new backpack for the school year!

Here's what I like:

  1. You've added error tracking without disrupting the main flow. Well done!
  2. The code is still neat and tidy, just like your desks should be.

For your next assignment, consider these areas for improvement:

  1. Could we add some comments to explain the Sentry integration for future students?
  2. Is there a way to make our error messages more friendly, like how we greet each other in the morning?
  3. Think about how we might test these new changes to make sure they're working perfectly.

Remember, continuous improvement is the key to success, both in coding and in life!

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 7d7d260 and 2523206.

📒 Files selected for processing (2)
  • app/client/src/pages/UserAuth/Login.tsx (2 hunks)
  • app/client/src/pages/UserAuth/SignUp.tsx (2 hunks)
🔇 Additional comments (1)
app/client/src/pages/UserAuth/SignUp.tsx (1)

60-61: Very good, class! Let's welcome our new friends from Sentry.

I'm pleased to see you've added these imports for Sentry. This will help us keep a watchful eye on any mischief happening in our application. Remember, children, monitoring errors is like having a hall monitor for your code!

Comment on lines 117 to 122
Sentry.captureException("Sign up failed", {
level: Severity.Error,
extra: {
error: new Error(errorMessage),
},
});
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Correct Usage of Sentry.captureException

Let's focus on the error handling block in lines 117-122. Currently, "Sign up failed" is passed as a string to Sentry.captureException, but this function expects an Error object. Additionally, setting the level directly in captureException isn't the recommended approach.

Here's how we can refactor the code to use Sentry.withScope for better context and proper severity level:

     if (queryParams.get("error")) {
       errorMessage = queryParams.get("message") || queryParams.get("error") || "";
       showError = true;
-      Sentry.captureException("Sign up failed", {
-        level: Severity.Error,
-        extra: {
-          error: new Error(errorMessage),
-        },
-      });
+      Sentry.withScope(function(scope) {
+        scope.setLevel('error');
+        scope.setExtra('errorMessage', errorMessage);
+        Sentry.captureException(new Error('Sign up failed'));
+      });
     }

This adjustment ensures we're capturing the exception with the appropriate error object and severity level.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Sentry.captureException("Sign up failed", {
level: Severity.Error,
extra: {
error: new Error(errorMessage),
},
});
Sentry.withScope(function(scope) {
scope.setLevel('error');
scope.setExtra('errorMessage', errorMessage);
Sentry.captureException(new Error('Sign up failed'));
});

Copy link

github-actions bot commented Oct 3, 2024

Deploy-Preview-URL: https://ce-36682.dp.appsmith.com

@ApekshaBhosale
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

github-actions bot commented Oct 4, 2024

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/11177807884.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 36682.
recreate: .

Copy link

github-actions bot commented Oct 4, 2024

Deploy-Preview-URL: https://ce-36682.dp.appsmith.com

@ApekshaBhosale ApekshaBhosale added the ok-to-test Required label for CI label Oct 4, 2024
@ApekshaBhosale ApekshaBhosale changed the title WIP: span push and sentry logs task: span push and sentry logs Oct 4, 2024
@ApekshaBhosale ApekshaBhosale changed the title task: span push and sentry logs chore: span push and sentry logs Oct 4, 2024
@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Oct 4, 2024
@@ -9,4 +9,8 @@ public class BaseSpan {
public static final String GIT_SPAN_PREFIX = "git.";

public static final String APPLICATION_SPAN_PREFIX = "application.";

public static final String AUTHENTICATE = "authenticate";
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use more specific strings here? Just to make sure we know exactly what we're tracking?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i have added general because i want to collect all authenticate related spans. tell me if all authenticate spans will be authenticate usernamepassword. this one we get with form login @nidhi-nair

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, may be we'll know more as we gather data. Let's go ahead with this for now.

@ApekshaBhosale ApekshaBhosale merged commit 28e54fe into release Oct 7, 2024
84 checks passed
@ApekshaBhosale ApekshaBhosale deleted the add-logs-traces-SLOs branch October 7, 2024 05:51
@coderabbitai coderabbitai bot mentioned this pull request Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants