Skip to content

chore: added new relic telemetry for spans#34240

Merged
NilanshBansal merged 2 commits intoreleasefrom
fix/issue-34072/tenant-caching-telemetry
Jun 14, 2024
Merged

chore: added new relic telemetry for spans#34240
NilanshBansal merged 2 commits intoreleasefrom
fix/issue-34072/tenant-caching-telemetry

Conversation

@NilanshBansal
Copy link
Contributor

@NilanshBansal NilanshBansal commented Jun 14, 2024

Description

This PR adds telemetry and logs for different spans where tenant info is fetched.

Fixes #34072

Automation

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

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/9511509976
Commit: d4dc99e
Cypress dashboard url: Click here!

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Enhanced tenant fetching with improved logging and metrics using Micrometer.
  • Improvements

    • Added monitoring capabilities to various tenant-related services for better observability and debugging.

@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Jun 14, 2024
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 14, 2024

Walkthrough

This update focuses on integrating performance metrics and logging to debug tenant fetching operations in the Appsmith application. By incorporating Micrometer's ObservationRegistry and adding specific constants for tenant-related spans, the changes aim to enhance observability and diagnose why the tenant caching implementation hasn't yielded significant performance improvements.

Changes

Files/Packages Change Summaries
TenantSpan.java in appsmith-interfaces Added constants for tenant fetching spans, enhancing observability with a base span prefix.
CacheableRepositoryHelperCEImpl.java, CacheableRepositoryHelperCECompatibleImpl.java, TenantServiceImpl.java, TenantServiceCEImpl.java Introduced ObservationRegistry for monitoring and metrics, updated constructors, and enhanced tenant-fetching logic with observable spans.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant TenantService
    participant ObservationRegistry
    participant CacheableRepositoryHelper
    participant Database

    Client->>+TenantService: getDefaultTenant()
    TenantService->>+ObservationRegistry: Observe Start
    TenantService->>+CacheableRepositoryHelper: fetchDefaultTenant()
    CacheableRepositoryHelper->>ObservationRegistry: Log Start
    CacheableRepositoryHelper->>Database: Fetch Data
    Database-->>CacheableRepositoryHelper: Return Data
    CacheableRepositoryHelper->>ObservationRegistry: Log End
    CacheableRepositoryHelper-->>TenantService: Return Data
    TenantService->>ObservationRegistry: Observe End
    TenantService-->>Client: Return Tenant
Loading

Assessment against linked issues

Objective Addressed Explanation
Debug why tenant caching has not improved performance (#34072)
Integrate logging and metrics into tenant fetching methods (#34072)
Add observability constants for tenant fetching spans (#34072)

Poem

Out in the meadow where code rabbits play,
Metrics and spans guide the way.
Fetching tenants with keen oversight,
Performance woes will take flight.
Logs and metrics now intertwined,
In Appsmith’s world, clarity we'll find. 🐇✨


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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.

@github-actions github-actions bot added Integrations Product Issues related to a specific integration Integrations Pod General Issues related to the Integrations Pod that don't fit into other tags. Task A simple Todo labels Jun 14, 2024
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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between dae657e and d303b74.

Files selected for processing (6)
  • app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/TenantSpan.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/CacheableRepositoryHelperImpl.java (2 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CacheableRepositoryHelperCEImpl.java (3 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce_compatible/CacheableRepositoryHelperCECompatibleImpl.java (2 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/services/TenantServiceImpl.java (3 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/TenantServiceCEImpl.java (5 hunks)
Files skipped from review due to trivial changes (1)
  • app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/TenantSpan.java
Additional context used
Learnings (1)
app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CacheableRepositoryHelperCEImpl.java (1)
User: NilanshBansal
PR: appsmithorg/appsmith#33641
File: app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CacheableRepositoryHelperCE.java:23-25
Timestamp: 2024-05-26T02:49:06.780Z
Learning: The new methods `fetchDefaultTenant` and `evictCachedTenant` in the `CacheableRepositoryHelperCE` interface are covered by existing and new tests, as confirmed by NilanshBansal.
Additional comments not posted (6)
app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/CacheableRepositoryHelperImpl.java (1)

5-5: The integration of ObservationRegistry in the constructor is well-implemented for enhanced monitoring.

Also applies to: 15-17

Verification successful

The integration of ObservationRegistry in the constructor of CacheableRepositoryHelperImpl and its superclass CacheableRepositoryHelperCECompatibleImpl is correctly implemented. The superclass is properly utilizing the passed ObservationRegistry.

  • Confirmed locations:
    • app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/CacheableRepositoryHelperImpl.java
    • app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce_compatible/CacheableRepositoryHelperCECompatibleImpl.java
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the superclass correctly utilizes the passed `ObservationRegistry`.

# Test: Search for the superclass usage of `ObservationRegistry`. Expect: Proper usage in superclass.
rg --type java $'super.*observationRegistry' -C 3 src/main/java/com/appsmith/server/repositories/ce_compatible/CacheableRepositoryHelperCECompatibleImpl.java

Length of output: 306



Script:

#!/bin/bash
# Locate all Java files that might contain the superclass definition.
fd -e java

# Search for the usage of `ObservationRegistry` across the located Java files.
rg --type java 'super.*observationRegistry' -C 3

Length of output: 190495

app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CacheableRepositoryHelperCEImpl.java (1)

17-17: The introduction of ObservationRegistry in CacheableRepositoryHelperCEImpl enhances monitoring capabilities. Ensure that the ObservationRegistry is used effectively in the methods where needed.

Also applies to: 23-23, 41-49, 191-201

Verification successful

The ObservationRegistry is properly integrated and utilized within the CacheableRepositoryHelperCEImpl class, specifically in the tap method with Micrometer.observation.

  • app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CacheableRepositoryHelperCEImpl.java
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `ObservationRegistry` is utilized effectively within `CacheableRepositoryHelperCEImpl`.

# Test: Search for usage of `ObservationRegistry` within `CacheableRepositoryHelperCEImpl`. Expect: Effective usage.
rg --type java $'observationRegistry' -C 3 src/main/java/com/appsmith/server/repositories/ce/CacheableRepositoryHelperCEImpl.java

Length of output: 255



Script:

#!/bin/bash
# Locate the correct path of CacheableRepositoryHelperCEImpl.java
fd CacheableRepositoryHelperCEImpl.java

# Assuming the correct path is found, verify the usage of `ObservationRegistry` within the file.
# Replace <correct_path> with the actual path found.
rg --type java $'observationRegistry' -C 3 <correct_path>

Length of output: 356



Script:

#!/bin/bash
# Verify the usage of `ObservationRegistry` within `CacheableRepositoryHelperCEImpl.java`.
rg --type java $'observationRegistry' -C 3 app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CacheableRepositoryHelperCEImpl.java

Length of output: 1199

app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/TenantServiceCEImpl.java (4)

22-22: Great job on integrating ObservationRegistry and Micrometer for enhanced observability.

Also applies to: 27-27


32-33: Usage of constants from TenantSpan for naming conventions in observability is a good practice as it maintains consistency and improves maintainability.


51-51: The injection of ObservationRegistry through the constructor ensures that the dependency is managed correctly. This is crucial for the observability of the tenant service operations.

Also applies to: 62-62, 69-69


185-186: The application of observability to the getDefaultTenant method using name() and tap() from Micrometer is well-implemented. However, ensure that the observability is effectively capturing all necessary metrics and logs, particularly in error scenarios.

Also applies to: 203-204

Verification successful

The onErrorResume block in the getDefaultTenant method includes logging for error scenarios, which is a good observability practice. The logs capture both the error and the subsequent action taken (evicting the cache and fetching from the database).

  • Error logging: log.error("Error fetching default tenant from redis!", e);
  • Action logging: log.info("Evicting the default tenant from cache and fetching from the database!");

These logs ensure that necessary metrics and logs are captured during error scenarios.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Check if all necessary metrics and logs are captured in error scenarios.

# Test: Search for error handling observability in the getDefaultTenant method.
rg --type java 'onErrorResume' 'app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/TenantServiceCEImpl.java'

Length of output: 166



Script:

#!/bin/bash
# Extract the onErrorResume block from getDefaultTenant method to inspect for observability measures.
rg -A 10 'onErrorResume' app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/TenantServiceCEImpl.java

Length of output: 1009

@NilanshBansal NilanshBansal self-assigned this Jun 14, 2024
@NilanshBansal NilanshBansal added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Jun 14, 2024
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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d303b74 and d4dc99e.

Files selected for processing (3)
  • app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/TenantSpan.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CacheableRepositoryHelperCEImpl.java (3 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/TenantServiceCEImpl.java (5 hunks)
Files skipped from review as they are similar to previous changes (3)
  • app/server/appsmith-interfaces/src/main/java/com/appsmith/external/constants/spans/TenantSpan.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ce/CacheableRepositoryHelperCEImpl.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/TenantServiceCEImpl.java

@NilanshBansal NilanshBansal merged commit b4ca723 into release Jun 14, 2024
@NilanshBansal NilanshBansal deleted the fix/issue-34072/tenant-caching-telemetry branch June 14, 2024 09:11
@coderabbitai coderabbitai bot mentioned this pull request Dec 5, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Integrations Pod General Issues related to the Integrations Pod that don't fit into other tags. Integrations Product Issues related to a specific integration ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog Task A simple Todo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Task]: Debug why even after tenant caching implementation there is not much performance boost

2 participants