Skip to content

Conversation

@nikhilsaikethe
Copy link
Contributor

@nikhilsaikethe nikhilsaikethe commented Sep 17, 2024

This PR fixes the issues in #4565

  1. Removed _o2_id from the schema list.
  2. Added ErrorDetail in the logs page when error occurs details errors can be shown.
  3. Histogram rendering blank bars at the starting , this PR fixes that rendering blank bars at the starting.

Summary by CodeRabbit

  • New Features

    • Enhanced error reporting with detailed error messages and additional context.
    • Improved histogram data accuracy through refined timestamp handling.
  • Bug Fixes

    • Streamlined error message rendering across various components for better user experience.
  • Refactor

    • Simplified logic for filtering schema fields in the stream data.

These updates collectively enhance the reliability and clarity of logging and error handling within the application.

@github-actions github-actions bot added the ☢️ Bug Something isn't working label Sep 17, 2024
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 17, 2024

Walkthrough

The pull request introduces enhancements primarily focused on error handling and data processing across several components. Key changes include the addition of errorDetail and histogramInterval to the defaultObject in useLogs.ts, improved error reporting mechanisms, and a refactor of histogram data generation logic. Additionally, modifications in multiple Index.vue files enhance the presentation of error messages by incorporating detailed error information, thereby improving user feedback during error scenarios.

Changes

File Change Summary
web/src/composables/useLogs.ts Enhanced error handling and data processing; added errorDetail and histogramInterval to defaultObject; improved granularity of error reporting; refactored histogram data generation logic.
web/src/composables/useStreams.ts Simplified the removeSchemaFields function by directly applying filtering to the schema array, removing _original and _o2_id items in a single operation.
web/src/plugins/logs/Index.vue Updated error message rendering to include errorDetail alongside errorMsg, enhancing the clarity and structure of error information displayed to users.
web/src/plugins/metrics/Index.vue Similar to logs/Index.vue, modified error message rendering to concatenate errorMsg with errorDetail, improving the presentation of error information.
web/src/plugins/traces/Index.vue Changed error message rendering to combine errorMsg and errorDetail, formatted with HTML for better visibility and structure in error communication.

Possibly related PRs


Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5237be5 and e1fc230.

Files selected for processing (5)
  • web/src/composables/useLogs.ts (13 hunks)
  • web/src/composables/useStreams.ts (1 hunks)
  • web/src/plugins/logs/Index.vue (1 hunks)
  • web/src/plugins/metrics/Index.vue (1 hunks)
  • web/src/plugins/traces/Index.vue (1 hunks)
Files skipped from review as they are similar to previous changes (4)
  • web/src/composables/useStreams.ts
  • web/src/plugins/logs/Index.vue
  • web/src/plugins/metrics/Index.vue
  • web/src/plugins/traces/Index.vue
Additional context used
Biome
web/src/composables/useLogs.ts

[error] 1256-1256: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)

Additional comments not posted (7)
web/src/composables/useLogs.ts (7)

39-39: LGTM!

Importing a date conversion utility is a good practice to handle dates consistently across the codebase.


139-139: Looks good!

The additions of errorDetail and histogramInterval to defaultObject enhance error handling and histogram configuration without introducing breaking changes.

Also applies to: 170-170


1256-1258: Good catch!

Capturing the error_detail from the API response aligns with the errorDetail addition to defaultObject. This provides more context about errors for debugging or surfacing to the user.

Also applies to: 1274-1274

Tools
Biome

[error] 1256-1256: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


1820-1820: Please clarify the commented out histogram generation logic.

The for loop that generates histogram entries is commented out. Is this intentional? How does removing this logic impact the histogram functionality?

Also, histogramInterval is now assigned to searchObj.data. Is this related to the histogram refactoring? Please provide more context.

Also applies to: 1848-1858


2380-2431: Histogram generation logic refactored.

The new histogram generation logic based on calculated timestamps seems to be the refactored version of the previously commented out loop.

It enhances the accuracy of the histogram by aligning the entries with the actual time intervals using the histogramInterval from searchObj.data.

This change looks good and addresses the question raised in the previous comment.


2276-2278: Duplicate of the previous error handling update.

This change is similar to the previous observation in the same function. It captures the error_detail from the API response for better error context.

Also applies to: 2301-2301


1256-1256: Skipping static analysis hint.

The suggestion to use Object.hasOwn() instead of Object.hasOwnProperty() doesn't seem to be applicable here, as the code is not accessing hasOwnProperty from a prototype.

The static analysis hint appears to be a false positive in this specific case.

Tools
Biome

[error] 1256-1256: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


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 generate interesting stats about this repository and render them as a table.
    -- @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
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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between dd26311 and 5237be5.

Files selected for processing (5)
  • web/src/composables/useLogs.ts (13 hunks)
  • web/src/composables/useStreams.ts (1 hunks)
  • web/src/plugins/logs/Index.vue (1 hunks)
  • web/src/plugins/metrics/Index.vue (1 hunks)
  • web/src/plugins/traces/Index.vue (1 hunks)
Additional context used
Biome
web/src/composables/useLogs.ts

[error] 1256-1256: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)

Additional comments not posted (12)
web/src/composables/useStreams.ts (1)

281-284: LGTM!

The updated implementation of the removeSchemaFields function simplifies the logic by directly filtering out items with names _original and _o2_id from the schema array. The change streamlines the function without altering its core functionality.

web/src/plugins/traces/Index.vue (1)

92-92: Verify that error details are properly sanitized to prevent XSS.

It's great to see more context being added to the error messages by including errorDetail. However, please ensure that the SanitizedHtmlRenderer component is properly sanitizing the HTML content to prevent XSS vulnerabilities, especially if the errorDetail can contain user-generated content.

Additionally, consider using a templating library or framework mechanism for safely generating the HTML, instead of relying on string concatenation which can be error-prone.

web/src/plugins/logs/Index.vue (1)

236-237: Enhance error message presentation. LGTM!

The change improves the user experience by presenting the error details in a visually distinct manner. The line break and heading tag provide clearer separation and emphasis.

web/src/composables/useLogs.ts (9)

39-39: LGTM!

The convertDateToTimestamp import is a valid addition for date conversion utility.


139-139: Looks good!

The additions of errorDetail and histogramInterval to defaultObject are valid as per the intended enhancements mentioned in the summary.

Also applies to: 170-170


1256-1258: Good catch!

Extracting error_detail from the API response and storing it improves error reporting granularity.

Tools
Biome

[error] 1256-1256: Do not access Object.prototype method 'hasOwnProperty' from target object.

It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.

(lint/suspicious/noPrototypeBuiltins)


2276-2278: Looks good!

Storing error_detail from the API response is consistent with the enhanced error reporting mechanism.


2301-2301: Looks good!

Storing error_detail from the API response aligns with the enhanced error reporting mechanism.


2380-2431: Nicely refactored!

The new histogram data generation logic looks good:

  • It replaces the commented out loop with a cleaner approach.
  • Using convertDateToTimestamp to derive the start timestamp is a nice touch.
  • Iterating forward and backward from the start timestamp to populate results is intuitive.

This refactor aligns well with the intended enhancements to histogram data generation mentioned in the summary.


1848-1858: Good cleanup!

Removing the commented out loop eliminates dead code and improves code hygiene.


2574-2574: Looks good!

Storing error_detail from the API response is consistent with the enhanced error reporting mechanism.


3549-3549: Looks good!

Storing error_detail from the API response aligns with the enhanced error reporting mechanism.

Comment on lines +181 to +182
:htmlContent="searchObj.data.errorMsg + '<br><h6>' + searchObj.data.errorDetail + '</h6>'"
/>
Copy link
Contributor

Choose a reason for hiding this comment

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

Improved error reporting but watch out for potential XSS vulnerability.

Displaying the errorDetail provides additional context for troubleshooting. However, if searchObj.data.errorDetail contains user-generated content, it could be a security risk to render it without sanitization. I recommend validating and sanitizing the errorDetail before rendering it to prevent potential XSS attacks.

Also, consider using a template literal for better readability:

- :htmlContent="searchObj.data.errorMsg + '<br><h6>' + searchObj.data.errorDetail + '</h6>'"
+ :htmlContent="`${searchObj.data.errorMsg}<br><h6>${sanitize(searchObj.data.errorDetail)}</h6>`"

Ensure you have a robust sanitization function in place.

Committable suggestion was skipped due to low confidence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

☢️ Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants