Skip to content

BugFix - Telemetry Bug Fixes#3931

Merged
IamHarsimranjeet merged 3 commits into
Releases/Official-Releasefrom
BugFix/TelemetryBugFixes
Sep 26, 2024
Merged

BugFix - Telemetry Bug Fixes#3931
IamHarsimranjeet merged 3 commits into
Releases/Official-Releasefrom
BugFix/TelemetryBugFixes

Conversation

@IamHarsimranjeet

@IamHarsimranjeet IamHarsimranjeet commented Sep 25, 2024

Copy link
Copy Markdown
Contributor

Thank you for your contribution.
Before submitting this PR, please make sure:

  • PR description and commit message should describe the changes done in this PR
  • Verify the PR is pointing to correct branch i.e. Release or Beta branch if the code fix is for specific release , else point it to master
  • Latest Code from master or specific release branch is merged to your branch
  • No unwanted\commented\junk code is included
  • No new warning upon build solution
  • Code Summary\Comments are added to my code which explains what my code is doing
  • Existing unit test cases are passed
  • New Unit tests are added for your development
  • Sanity Tests are successfully executed for New and Existing Functionality
  • Verify that changes are compatible with all relevant browsers and platforms.
  • After creating pull request there should not be any conflicts
  • Resolve all Codacy comments
  • Builds and checks are passed before PR is sent for review
  • Resolve code review comments
  • Update the Help Library document to match any feature changes

Summary by CodeRabbit

  • New Features

    • Introduced telemetry functionality for tracking item uploads in the repository.
    • Added feature tracking for activity execution, enhancing logging and user feedback.
  • Bug Fixes

    • Improved handling of action execution and error logging for better clarity and maintainability.
  • Refactor

    • Streamlined the serialization and deserialization of DateTime objects for better performance and simplicity.

@coderabbitai

coderabbitai Bot commented Sep 25, 2024

Copy link
Copy Markdown
Contributor

Walkthrough

The changes introduce telemetry functionality across multiple components, enhancing the tracking of feature usage and activity execution. The UploadItemToRepository method in SharedRepositoryOperations.cs now categorizes uploaded items and logs their usage. Modifications to the RunActivity method in GingerExecutionEngine.cs improve the execution flow and logging of activities. Additionally, the serialization and deserialization of DateTime objects in TelemetryLiteDB.cs have been streamlined for efficiency.

Changes

File Path Change Summary
Ginger/GingerCoreNET/Repository/SharedRepositoryOperations.cs Added telemetry functionality to UploadItemToRepository, including item categorization and feature usage tracking.
Ginger/GingerCoreNET/Run/GingerExecutionEngine.cs Modified RunActivity to improve execution flow, logging, and handling of activity actions.
Ginger/GingerCoreNET/Telemetry/TelemetryLiteDB.cs Simplified serialization and deserialization of DateTime objects in the NewBsonMapper method.

Possibly related PRs

  • BugFix - Null Account Details Issue Fix #3910: Enhances telemetry functionality by improving error handling during log and feature record creation, related to the telemetry functionality added in the UploadItemToRepository method.

Suggested reviewers

  • Maheshkale447

Poem

In the code where rabbits hop,
New features bloom, they never stop.
With telemetry bright and clear,
We track our paths, we hold them dear.
So let us cheer for changes made,
In the world of code, our joy displayed! 🐰✨


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 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 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 or @coderabbitai title 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.

@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: 4

🧹 Outside diff range and nitpick comments (5)
Ginger/GingerCoreNET/Repository/SharedRepositoryOperations.cs (1)

63-87: LGTM: Telemetry functionality added correctly. Consider using a switch statement for better readability.

The new telemetry functionality has been implemented correctly. It determines the item type, creates metadata, and reports feature usage. However, the series of if-else statements for determining the item type could be replaced with a switch statement or pattern matching (if using C# 8.0 or later) for improved readability and maintainability.

Consider refactoring the item type determination as follows:

string itemType = item switch
{
    Act => "Action",
    VariableBase => "Variable",
    Activity => "Activity",
    ActivitiesGroup => "ActivitiesGroup",
    _ => string.Empty
};

if (!string.IsNullOrEmpty(itemType))
{
    TelemetryMetadata metadata = new();
    metadata.Add("Type", itemType);
    Reporter.AddFeatureUsage(FeatureId.AddItemToSharedRepository, metadata);
}

This approach is more concise and easier to extend if new item types are added in the future.

Ginger/GingerCoreNET/Run/GingerExecutionEngine.cs (4)

3865-3865: Correct the typo in method name CheckIfVaribalesDependenciesAllowsToRun

The method name CheckIfVaribalesDependenciesAllowsToRun is misspelled. It should be CheckIfVariablesDependenciesAllowsToRun. This will improve code readability and maintain consistency.


3865-3865: Simplify boolean condition

The condition act.CheckIfVariablesDependenciesAllowsToRun(activity, true) == true can be simplified by removing the == true comparison. The revised condition is more concise and readable:

-if (act.Active && act.CheckIfVariablesDependenciesAllowsToRun(activity, true) == true && CheckRunInVisualTestingMode(act) && CheckRunInNetworkLog(act))
+if (act.Active && act.CheckIfVariablesDependenciesAllowsToRun(activity, true) && CheckRunInVisualTestingMode(act) && CheckRunInNetworkLog(act))

3829-3830: Simplify condition checking RunInSimulationMode

The condition mGingerRunner.RunInSimulationMode == true can be simplified to mGingerRunner.RunInSimulationMode for clarity and brevity. The updated code is:

-if (!mGingerRunner.RunInSimulationMode ||
-    (mGingerRunner.RunInSimulationMode == true && driverActs.Any(x => x.SupportSimulation == false)))
+if (!mGingerRunner.RunInSimulationMode ||
+    (mGingerRunner.RunInSimulationMode && driverActs.Any(x => !x.SupportSimulation)))

This removes unnecessary comparisons and simplifies the lambda expression.


Line range hint 396-398: Clarify exception handling in the catch block

The TODO comment suggests reconsidering the exception handling strategy. Currently, the exception is logged but also rethrown. Decide whether to handle the exception internally or propagate it, and remove the TODO comment after making the necessary changes.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ed13792 and a251e9c.

📒 Files selected for processing (3)
  • Ginger/GingerCoreNET/Repository/SharedRepositoryOperations.cs (2 hunks)
  • Ginger/GingerCoreNET/Run/GingerExecutionEngine.cs (1 hunks)
  • Ginger/GingerCoreNET/Telemetry/TelemetryLiteDB.cs (2 hunks)
🔇 Additional comments not posted (7)
Ginger/GingerCoreNET/Telemetry/TelemetryLiteDB.cs (3)

24-24: LGTM: Added necessary using statement

The addition of using System.Globalization; is appropriate and necessary for the changes made in the NewBsonMapper method, specifically for using DateTimeStyles.RoundtripKind.


Line range hint 1-324: Overall assessment: Changes look good

The modifications in this file are focused and align well with the PR objectives of fixing telemetry-related bugs. The changes to DateTime handling in the NewBsonMapper method should improve the robustness of telemetry data serialization and deserialization.

As a final note, ensure that all tests related to telemetry data handling pass successfully, particularly those involving DateTime serialization and deserialization.


52-52: Approve change with verification request

The simplification of DateTime deserialization using DateTime.Parse with DateTimeStyles.RoundtripKind is a good improvement. It leverages built-in parsing capabilities and automatically handles the DateTime kind based on the string format.

However, please verify that this change maintains backwards compatibility with existing stored data. Ensure that previously serialized DateTime values can still be correctly deserialized with this new implementation.

To verify backwards compatibility, please run the following script:

If the script returns any results, please review those occurrences to ensure they are not negatively impacted by this change.

✅ Verification successful

Change Verified Successfully

The update to use DateTime.Parse with DateTimeStyles.RoundtripKind in TelemetryLiteDB.cs is appropriate and does not adversely affect other parts of the codebase. This change enhances the clarity of DateTime parsing in this specific context and maintains backward compatibility with existing data.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any existing DateTime deserialization in the codebase that might be affected by this change.

# Test: Search for DateTime deserialization patterns
rg --type csharp -e 'DateTime\.Parse' -e 'DateTime\.ParseExact' -e 'Convert\.ToDateTime'

Length of output: 14341

Ginger/GingerCoreNET/Repository/SharedRepositoryOperations.cs (2)

22-22: LGTM: Telemetry import added correctly.

The new import statement for Amdocs.Ginger.Common.Telemetry is correctly placed and necessary for the added telemetry functionality.


63-87: Overall impact: Telemetry functionality added without breaking changes.

The new telemetry functionality has been successfully integrated into the UploadItemToRepository method without introducing any breaking changes. This addition aligns with the PR objectives of addressing telemetry-related bugs. The changes are well-contained and don't affect other parts of the file.

Ginger/GingerCoreNET/Run/GingerExecutionEngine.cs (2)

3825-3825: Use Any with a predicate to improve performance

Instead of using driverActs.Any() followed by another Any in the nested condition, combine the conditions using a predicate to minimize enumeration:

-var driverActs = activity.Acts.Where(x => !(x is ActWithoutDriver && x.GetType() != typeof(ActAgentManipulation)) && x.Active);
-if (driverActs.Any() && 
-    (!mGingerRunner.RunInSimulationMode || 
-     (mGingerRunner.RunInSimulationMode && driverActs.Any(x => !x.SupportSimulation))))
+if (activity.Acts.Any(x => !(x is ActWithoutDriver && x.GetType() != typeof(ActAgentManipulation)) && x.Active) && 
+    (!mGingerRunner.RunInSimulationMode || 
+     (mGingerRunner.RunInSimulationMode && activity.Acts.Any(x => !x.SupportSimulation))))
{
    SetCurrentActivityAgent();
}

This reduces the number of iterations over activity.Acts.

[performance]


3945-3945: Ensure correct loop termination condition

The condition if (act.Status != Amdocs.Ginger.CoreNET.Execution.eRunStatus.Pending && activity.Acts.IsLastItem()) may lead to the loop exiting prematurely if the last action is not in Pending status. Verify that this logic aligns with the intended behavior, and adjust the condition if necessary.

Comment thread Ginger/GingerCoreNET/Run/GingerExecutionEngine.cs
Comment thread Ginger/GingerCoreNET/Run/GingerExecutionEngine.cs
Comment thread Ginger/GingerCoreNET/Run/GingerExecutionEngine.cs
Comment thread Ginger/GingerCoreNET/Run/GingerExecutionEngine.cs
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.

2 participants