Skip to content

change cloud env to also use cloudwatch - #536

Closed
tonychang04 wants to merge 0 commit into
mainfrom
fix/logSource
Closed

tonychang04 wants to merge 0 commit into
mainfrom
fix/logSource

Conversation

@tonychang04

@tonychang04 tonychang04 commented Oct 29, 2025 •

Copy link
Copy Markdown
Member

Summary

in 1.1.2 we don't see any logs... but when looking at network request it seems to be referencing the local endpints.
Screenshot 2025-10-29 at 00 11 59

How did you test this change?

get a new image, and then it fetches from cloudwatch

Screenshot 2025-10-29 at 00 38 40

Summary by CodeRabbit

  • Bug Fixes
    • Improved logging infrastructure by refining provider selection logic to account for cloud environment configuration, ensuring more reliable log capture across different deployment scenarios.

@coderabbitai

coderabbitai Bot commented Oct 29, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

Modifies log provider selection logic in LogService to consider cloud environment context in addition to AWS credentials. When initializing, the service now routes to CloudWatch provider if either cloud environment flag or AWS credentials are present; otherwise defaults to LocalFileProvider.

Changes

Cohort / File(s) Summary
Log Provider Selection Logic
backend/src/core/logs/logs.ts
Imports isCloudEnvironment() utility and updates LogService initialization to evaluate both cloud environment context and AWS credentials when determining log provider (CloudWatch vs LocalFileProvider).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Verify that isCloudEnvironment() is correctly imported and utilized
  • Confirm the conditional logic accurately reflects intended behavior (cloud environment OR AWS credentials → CloudWatch)
  • Check that fallback to LocalFileProvider works correctly when neither condition is met

Possibly related PRs

Suggested reviewers

  • Fermionic-Lyu

Poem

🐰 A log that knows the cloud so well,
Hops between providers under its spell,
CloudWatch or files, the choice is clear—
Environment whispers what logs should hear! ☁️

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title "change cloud env to also use cloudwatch" directly and accurately describes the main change in this pull request. The changeset modifies the LogService.initialize method to consider cloud environment status (via isCloudEnvironment()) in addition to AWS credentials when selecting the log provider. The word "also" in the title correctly conveys that this is an expansion of existing logic, not a replacement. The title is specific and clear enough that someone scanning commit history would understand the primary change involves enabling CloudWatch based on cloud environment context, addressing the issue where logs weren't visible in version 1.1.2.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/logSource

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@tonychang04
tonychang04 marked this pull request as ready for review October 29, 2025 07:35

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
backend/src/core/logs/logs.ts (1)

22-25: Logic correctly implements cloud environment detection.

The updated logic properly addresses the PR objective by enabling CloudWatch when running in cloud environments with instance profiles. The conditional now covers both explicit AWS credentials and cloud environment scenarios.

Consider renaming hasAwsCredentials to shouldUseCloudWatch or useCloudWatchProvider for clarity, since the variable now returns true even without explicit credentials. While the comment clarifies the intent, a more descriptive name would improve code readability.

Apply this diff to improve variable naming:

-    const hasAwsCredentials =
+    const shouldUseCloudWatch =
       (process.env.AWS_ACCESS_KEY_ID && process.env.AWS_SECRET_ACCESS_KEY) || isCloudEnvironment();
 
-    if (hasAwsCredentials) {
+    if (shouldUseCloudWatch) {
       logger.info('Using log provider: CloudWatch');
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1447690 and 744d607.

📒 Files selected for processing (1)
  • backend/src/core/logs/logs.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{ts,tsx}: Use TypeScript for all code files
Use ES modules (import/export syntax)
Prefer descriptive, unabbreviated variable and function names
Implement proper error handling with try-catch blocks and logging where appropriate
Use single quotes for strings
Include semicolons at the end of statements
Use arrow functions for callbacks and inline functions
Prefer const over let; avoid var
Use template literals for string interpolation
Maintain 2-space indentation
Format code with the repository Prettier configuration
Variables, parameters, properties, and functions must use camelCase
Constants and enum members must use UPPER_CASE
Include JSDoc comments for complex functions

Files:

  • backend/src/core/logs/logs.ts
backend/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

backend/src/**/*.{ts,tsx}: Use async/await for asynchronous operations in the backend
Use Zod schemas for request/response validation
Return consistent API responses using utility functions
Validate all user inputs
Sanitize data before database operations
Use prepared statements for SQL queries
Implement proper caching strategies (server-side)

Files:

  • backend/src/core/logs/logs.ts
backend/src/{controllers,core}/**/*.ts

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Implement proper database transaction handling

Files:

  • backend/src/core/logs/logs.ts
**/*.{tsx,ts}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

React components and TypeScript types/interfaces must use PascalCase

Files:

  • backend/src/core/logs/logs.ts
**/[a-z][a-z0-9-]*.ts

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Utility files should use kebab-case or camelCase (kebab-case validated here)

Files:

  • backend/src/core/logs/logs.ts
🧬 Code graph analysis (1)
backend/src/core/logs/logs.ts (1)
backend/src/utils/environment.ts (1)
  • isCloudEnvironment (9-11)
🔇 Additional comments (1)
backend/src/core/logs/logs.ts (1)

6-6: LGTM! Import supports cloud environment detection.

The import is correctly formatted and necessary for the new cloud environment detection logic.

This branch was successfully deployed

1 active deployment
staging - docs — 14476907 Deployed Oct 29, 2025 by mintlify[bot]
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.

1 participant