Skip to content

chore: source category set to event stream as default #4226

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 5 commits into from
Jan 5, 2024

Conversation

gane5hvarma
Copy link
Contributor

@gane5hvarma gane5hvarma commented Dec 11, 2023

Description

We have observed the source category coming to be as empty string in metrics and some customers are using prom exporter where the empty value label gets dropped. Reporting service assumes it as event stream when source cateogry is emtpy.

Linear Ticket

https://linear.app/rudderstack/issue/OBS-264/add-event-stream-in-source-category-as-default-value

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

Summary by CodeRabbit

  • New Features

    • Introduced a new constant to enhance event stream handling.
  • Bug Fixes

    • Improved the Record method to address scenarios with missing source categories in event metrics.
  • Tests

    • Added a new test case to verify the robustness of event metrics recording with detailed assertions.

Copy link
Contributor

coderabbitai bot commented Dec 11, 2023

Important

Auto Review Skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository.

To trigger a single review, invoke the @coderabbitai review command.

Walkthrough

The recent update introduces a new constant EventStream and modifies the EventStatsReporter to handle cases where metrics[index].ConnectionDetails.SourceCategory is empty. Additionally, the test suite has been expanded with a new test case that checks for specific connection, PU details, and status, including an assertion for a newly added metric.

Changes

File(s) Summary
.../reporting/event_stats.go Added EventStream constant and updated Record method to handle empty SourceCategory.
.../reporting/event_stats_test.go Added a new test case with assertions for specific connection details and a new metric.

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's AI:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • 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 tests 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 from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid.
    • @coderabbitai read the files in the src/scheduler package and generate README in the markdown format.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@gane5hvarma gane5hvarma changed the title source category set to event stream as default chore: source category set to event stream as default Dec 11, 2023
@gane5hvarma
Copy link
Contributor Author

@coderabbitai review

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.

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between a7c373a and 78e3489.
Files selected for processing (2)
  • enterprise/reporting/event_stats.go (2 hunks)
  • enterprise/reporting/event_stats_test.go (2 hunks)
Additional comments: 4
enterprise/reporting/event_stats.go (2)
  • 29-38: The logic to default sourceCategory to EventStream when it's empty is implemented correctly. Ensure that this default value is consistent with other parts of the codebase where sourceCategory might be used.

The search for SourceCategory in the enterprise/reporting/ directory shows that the SourceCategory field is used in various places within the codebase. The references in reporting.go and event_stats_test.go suggest that the field is indeed used elsewhere and that the logic for setting a default value might need to be consistent across these files.

However, without more context on how SourceCategory is used in these other files, it's not possible to definitively say whether the defaulting logic in event_stats.go will cause any issues. The test cases in event_stats_test.go do include a case where SourceCategory is set to an empty string, which seems to be handled by the new logic.

Given the information available, it seems that the change in event_stats.go is consistent with the intended behavior, but a full verification would require a deeper understanding of the codebase.

Final review comment:

The update to default sourceCategory to EventStream when empty is consistent with the changes described. However, ensure that this default value aligns with the usage of sourceCategory across the entire codebase, particularly in reporting.go. It may be necessary to review the logic in related files to maintain consistency.

  • 27-41: The changes to the Record method correctly implement the logic to prevent sourceCategory from being empty, aligning with the PR objective.
enterprise/reporting/event_stats_test.go (2)
  • 137-152: The new test case added to simulate the scenario where SourceCategory is empty and should default to "event stream" is correctly implemented.

  • 200-210: The assertion for the new metric with the default EventStream is correctly checking the expected behavior when SourceCategory is empty.

Copy link

codecov bot commented Dec 18, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (1c3fb01) 73.88% compared to head (52b6d67) 73.93%.
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4226      +/-   ##
==========================================
+ Coverage   73.88%   73.93%   +0.04%     
==========================================
  Files         388      388              
  Lines       55098    55106       +8     
==========================================
+ Hits        40709    40741      +32     
+ Misses      12060    12043      -17     
+ Partials     2329     2322       -7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rudderlabs rudderlabs deleted a comment from coderabbitai bot Dec 19, 2023
@gane5hvarma gane5hvarma merged commit af82a6f into master Jan 5, 2024
@gane5hvarma gane5hvarma deleted the chore.addDefaultValueForSourceCategory branch January 5, 2024 11:48
This was referenced Jan 15, 2024
This was referenced Feb 9, 2024
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.

3 participants