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

Removes some logs which are killing our sumo usage #2911

Merged
merged 1 commit into from
Dec 9, 2024
Merged

Conversation

shubham1g5
Copy link
Contributor

Summary

Cleaning some not so useful logs which makes up for almost half of the log entries in sumologic in hopes to reduce our sumo usage by a good factor.

Screenshot 2024-12-05 at 10 40 35 PM

PR Checklist

  • If I think the PR is high risk, "High Risk" label is set
  • I have confidence that this PR will not introduce a regression for the reasons below
  • Do we need to enhance manual QA test coverage ? If yes, "QA Note" label is set correctly
  • Does the PR introduce any major changes worth communicating ? If yes, "Release Note" label is set and a "Release Note" is specified in PR description.

Automated test coverage

NA

Safety story

Logs only

@shubham1g5 shubham1g5 added this to the 2.55 milestone Dec 5, 2024
Copy link

coderabbitai bot commented Dec 5, 2024

📝 Walkthrough

Walkthrough

The pull request introduces several modifications across multiple classes in the codebase, primarily focusing on logging behavior. In the IntentCallout class, a logging statement that logged the generated intent has been removed. Similarly, in the CommcareFlexibleAppUpdateManager, logging statements related to the publishing of status updates have been eliminated, reducing verbosity without impacting the method's logic. The HiddenPreferences class also sees a logging statement removed from the clearInterruptedSSD method, again without affecting core functionality.

In contrast, the DataPullTask class adds a logging statement to indicate the start of the sync process, enhancing visibility. Additionally, error handling in this class has been refined with a check for an empty server URL. Lastly, the FormUploadUtil class modifies its logging behavior to conditionally log information about attachments, preventing unnecessary log entries when no attachments are present. Overall, the changes maintain existing functionality while adjusting logging practices and error handling in specific areas.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant DataPullTask
    participant Server

    User->>DataPullTask: Start Sync
    DataPullTask->>DataPullTask: Log "Starting Sync"
    DataPullTask->>DataPullTask: Check Server URL
    alt URL is empty
        DataPullTask-->>User: Return Error
    else URL is valid
        DataPullTask->>Server: Initiate Sync
        Server-->>DataPullTask: Sync Response
        DataPullTask-->>User: Return Sync Result
    end
Loading

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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

Copy link

@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: 0

🧹 Outside diff range and nitpick comments (2)
app/src/org/commcare/utils/FormUploadUtil.java (2)

Line range hint 42-43: Consider making MAX_BYTES configurable

The 15MB size limit is currently hardcoded. Consider making this configurable through build configuration or system properties to allow for environment-specific adjustments.


Line range hint 248-253: Address TODO comment about validation responsibility

The TODO comment indicates that form record validation should be moved out of the submission process. This is a valid architectural concern as it violates the Single Responsibility Principle.

Consider:

  1. Moving the validation logic to a dedicated FormValidator class
  2. Making the validation a prerequisite step before submission

Would you like me to help create a separate FormValidator class to handle this responsibility?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between d4d32c8 and 6ba2d17.

📒 Files selected for processing (5)
  • app/src/org/commcare/android/javarosa/IntentCallout.java (0 hunks)
  • app/src/org/commcare/appupdate/CommcareFlexibleAppUpdateManager.java (0 hunks)
  • app/src/org/commcare/preferences/HiddenPreferences.java (0 hunks)
  • app/src/org/commcare/tasks/DataPullTask.java (0 hunks)
  • app/src/org/commcare/utils/FormUploadUtil.java (1 hunks)
💤 Files with no reviewable changes (4)
  • app/src/org/commcare/android/javarosa/IntentCallout.java
  • app/src/org/commcare/appupdate/CommcareFlexibleAppUpdateManager.java
  • app/src/org/commcare/preferences/HiddenPreferences.java
  • app/src/org/commcare/tasks/DataPullTask.java
🔇 Additional comments (1)
app/src/org/commcare/utils/FormUploadUtil.java (1)

364-371: LGTM! Conditional logging improves efficiency

The change to only log attachment counts when there are actual attachments is a good optimization that aligns with the PR's goal of reducing Sumo Logic usage while preserving important debugging information.

Let's verify that we're not losing any critical debugging information by checking other logging points in the upload flow:

✅ Verification successful

Let me check the context of these logging statements to ensure we have a complete picture of the form submission logging flow.


Conditional logging change is safe and maintains debugging capabilities

The verification shows that all critical form submission scenarios are still being logged:

  • Network response issues and error details
  • Unsupported file type warnings
  • File size limitation warnings
  • Form record removal notifications
  • Form submission attempts and success tracking

The change to make attachment count logging conditional only eliminates noise when there are no attachments, while preserving all essential debugging information in the form upload flow.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for other logging statements in the form upload flow to ensure critical debugging information is preserved

# Search for other logging statements in the form upload process
rg "Logger.log.*TYPE_FORM_SUBMISSION" --type java

Length of output: 1111


Script:

#!/bin/bash
# Get context around the logging statements to understand the complete logging flow
rg "Logger.log.*TYPE_FORM_SUBMISSION" --type java -B 2 -A 2

Length of output: 4419

Comment on lines -164 to -165
Logger.log(LogTypes.TYPE_CC_UPDATE, "Publishing status update to : " + newState.name() + ", from : "
+ (mAppUpdateState != null ? mAppUpdateState.name() : "null"));
Copy link
Contributor

Choose a reason for hiding this comment

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

@shubham1g5 Are we 100% sure that this is unnecessary? We can consider logging when the state changes.

Copy link
Contributor Author

@shubham1g5 shubham1g5 Dec 9, 2024

Choose a reason for hiding this comment

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

This already logs only when state changes (look at the if cond above this). I don't think this gives us any useful debugging info as such as most functionality there is managed by Play services API. Also there is nothing like 100% certainity with what you might and might not need with logs and think we should avoid this framing in deciding what to log. Instead a better framing for retroactively deleting logs is have you found a particular line of useful while solving any debugging issues in past ? Happy to re-consider if so.

Copy link
Contributor

@avazirna avazirna Dec 9, 2024

Choose a reason for hiding this comment

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

Instead a better framing for retroactively deleting logs is have you found a particular line of useful while solving any debugging issues in past ?

Agree, my framing was exactly in this sense, I remember troubleshooting the app update issue and looking at these, but don't remember how useful they actually were.

@avazirna avazirna merged commit 05e8b40 into master Dec 9, 2024
4 of 7 checks passed
@shubham1g5 shubham1g5 deleted the cleanLogs branch December 9, 2024 09:06
@coderabbitai coderabbitai bot mentioned this pull request Dec 10, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-integration-tests Skip android tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants