Skip to content

updates for prism home api #1275

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

Merged
merged 1 commit into from
Mar 28, 2025

Conversation

parmesant
Copy link
Contributor

@parmesant parmesant commented Mar 27, 2025

Fixes #XXXX.

Description


This PR has:

  • been tested to ensure log ingestion and log query works.
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added documentation for new or modified features or behaviors.

Summary by CodeRabbit

  • Refactor

    • Improved internal data handling to ensure consistent and efficient concurrent operations.
    • Optimized asynchronous processes to reduce wait times during data aggregation.
  • New Features

    • Enhanced the home view to concurrently load multiple display elements, resulting in a faster and smoother user experience.
    • Upgraded logstream information retrieval for quicker response times during data display.

Copy link
Contributor

coderabbitai bot commented Mar 27, 2025

Walkthrough

The pull request refines asynchronous operations and locking mechanisms across three modules. In the correlation module, a write lock is now acquired via a guard variable to manage insertions safely. In the home module, multiple asynchronous fetch operations and metadata collection tasks are now executed concurrently using tokio::join!, with new helper functions and a type alias added. In the logstream module, concurrent fetching of stream information, schema, and statistics replaces sequential calls, improving overall efficiency.

Changes

File(s) Change Summary
src/correlation.rs Introduced a guard variable to acquire a write lock (self.write().await) and perform insertions through it, ensuring the lock is held during the entire insertion operation.
src/prism/home/mod.rs
src/prism/logstream/mod.rs
Refactored asynchronous operations to run concurrently using tokio::join!. In the home module, helper functions (e.g., for fetching various titles and stream metadata) and a type alias were added, and concurrent processing for stream metadata and date-based statistics was introduced. In the logstream module, sequential async calls were replaced with concurrent calls for retrieving stream info, schema, and statistics.

Sequence Diagram(s)

sequenceDiagram
    participant GH as generate_home_response
    participant TS as get_stream_titles
    participant AS as get_alert_titles
    participant CS as get_correlation_titles
    participant DS as get_dashboard_titles
    participant FS as get_filter_titles
    participant MD as get_stream_metadata
    participant SD as stats_for_date

    GH->>+TS: Fetch stream titles
    GH->>+AS: Fetch alert titles
    GH->>+CS: Fetch correlation titles
    GH->>+DS: Fetch dashboard titles
    GH->>+FS: Fetch filter titles
    Note right of GH: Initiates concurrent calls using tokio::join!
    TS-->>-GH: Return list of streams
    AS-->>-GH: Return list of alerts
    CS-->>-GH: Return correlation titles
    DS-->>-GH: Return dashboard titles
    FS-->>-GH: Return filter titles

    alt Process each stream concurrently
      GH->>+MD: Request stream metadata (for each stream)
      MD-->>-GH: Return metadata tuple
    end

    alt Concurrent date statistics
      GH->>+SD: Fetch stats for a date (for each stream)
      SD-->>-GH: Return statistics
    end
Loading
sequenceDiagram
    participant PL as get_prism_logstream_info
    participant SI as get_stream_info
    participant SC as get_schema
    participant ST as get_stats

    PL->>+SI: Fetch stream info concurrently
    PL->>+SC: Fetch stream schema concurrently
    PL->>+ST: Fetch stream stats concurrently
    Note right of PL: Using tokio::join! for parallel execution
    SI-->>-PL: Return stream info
    SC-->>-PL: Return stream schema
    ST-->>-PL: Return stats
    PL->>PL: Construct PrismLogstreamInfo object
Loading

Suggested labels

for next release

Suggested reviewers

  • nikhilsinhaparseable

Poem

Oh, I’m a rabbit, hopping with glee,
Async flows and locks now set free.
With tokio::join! I leap so high,
Carrots of code dancing in the sky.
Happy bytes and bouncy streams, oh my!
Cheers from the burrow, coding is spry!
(_/)(•‿•) Hop on to the new supply!

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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: 0

🧹 Nitpick comments (2)
src/prism/logstream/mod.rs (1)

63-71: Efficient concurrent fetching with tokio::join!.
Replacing sequential async calls with tokio::join! improves throughput for these I/O-bound tasks. If an early failure should abort remaining calls, consider try_join! instead. Otherwise, this approach is valid.

src/prism/home/mod.rs (1)

242-259: Handling null dashboard IDs.
Dashboard IDs are unwrapped with ok_or_else(...), which will fail if an ID is missing. This is valid if the system must strictly enforce ID presence. If partial loading is expected, consider skipping incomplete dashboard entries.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9cd3809 and fab7ab1.

📒 Files selected for processing (3)
  • src/correlation.rs (2 hunks)
  • src/prism/home/mod.rs (7 hunks)
  • src/prism/logstream/mod.rs (1 hunks)
🧰 Additional context used
🧬 Code Definitions (2)
src/prism/logstream/mod.rs (1)
src/logstream/mod.rs (2)
  • get_stream_info_helper (47-90)
  • get_stream_schema_helper (28-45)
src/prism/home/mod.rs (2)
src/alerts/mod.rs (1)
  • get_alerts_info (893-930)
src/handlers/http/logstream.rs (1)
  • get_stats_date (201-223)
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: coverage
  • GitHub Check: Quest Smoke and Load Tests for Distributed deployments
  • GitHub Check: Quest Smoke and Load Tests for Standalone deployments
  • GitHub Check: Build Default x86_64-pc-windows-msvc
  • GitHub Check: Build Default x86_64-apple-darwin
  • GitHub Check: Build Kafka x86_64-unknown-linux-gnu
  • GitHub Check: Build Default aarch64-apple-darwin
  • GitHub Check: Build Default x86_64-unknown-linux-gnu
  • GitHub Check: Build Default aarch64-unknown-linux-gnu
  • GitHub Check: Build Kafka aarch64-apple-darwin
🔇 Additional comments (11)
src/correlation.rs (2)

59-60: Consider scoping or early release of write lock.
Acquiring the write lock and storing it in guard is appropriate for ensuring safe concurrent writes. If additional operations beyond insertion are needed, consider using a narrower scope or carefully releasing the lock after insertion to reduce the chance of blocking other writers.


71-71: Correct usage of guarded insertion.
Using guard.insert(...) while holding the write lock ensures atomic insertion. This looks good for preventing data races.

src/prism/home/mod.rs (9)

44-45: Clearer type alias.
Defining StreamMetadataResponse as a type alias for an Result<..., ...> simplifies readability and emphasizes the context of the returned data.


93-192: Parallel fetch for home response.
Using tokio::join! to concurrently retrieve stream titles, alert titles, correlation titles, dashboards, filter titles, and alerts info is a strong step for efficiency. The code bails out early if any of these fail, which may be desirable. If you wish to collect partial results on error, consider manual error handling or a different concurrency strategy.


196-213: Stream listing with RBAC filtering.
Filtering the listed streams by RBAC checks ensures proper authorization. If the number of streams grows large, consider streaming them or adding pagination.


214-226: Retrieving alert titles.
Mapping alerts to TitleAndId for display is straightforward. The approach looks good for authorized user access of alerts.


228-240: Fetching correlation titles by user.
Listing correlations with matching user permissions appears correct. The code is consistent with how other titles are fetched; no issues found.


261-278: Filter titles retrieval.
Similar to dashboards, this function unwraps the filter_id. The partial approach is consistent. No immediate concerns.


280-325: Aggregating stream metadata.
Reading multiple .json objects from storage, logging parse errors, and continuing allows partial success. This is good for resiliency. If desired, consider collecting parse errors in a single report for troubleshooting.


327-361: Generating date-based stats.
Stats are fetched concurrently for each stream on each date. Any failures are logged and skipped. This non-blocking approach helps ensure partial success even if some streams fail.


362-375: Consolidating querier and ingestor stats.
Combining stats from get_stats_date and fetch_daily_stats_from_ingestors is coherent for building a comprehensive view. Implementation looks solid.

Copy link
Contributor

@nikhilsinhaparseable nikhilsinhaparseable left a comment

Choose a reason for hiding this comment

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

good to merge

@nikhilsinhaparseable nikhilsinhaparseable merged commit 26e700d into parseablehq:main Mar 28, 2025
14 checks passed
@coderabbitai coderabbitai bot mentioned this pull request May 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants