Skip to content
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

Feature - Ginger Telemetry #3897

Merged
merged 54 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
90e0729
created telemetry pipeline steps
IamRanjeetSingh Aug 22, 2024
8e972a9
added litedb implementation
IamRanjeetSingh Aug 26, 2024
bd97b73
feature record impl
IamRanjeetSingh Aug 26, 2024
87ddb49
implemented telemetry monitor
IamRanjeetSingh Aug 27, 2024
8904059
changed feature tracking structure
IamRanjeetSingh Aug 27, 2024
9d15e0b
updated TelemetryMonitor
IamRanjeetSingh Aug 27, 2024
10d68ab
ignored non-error logs from telemetry
IamRanjeetSingh Aug 27, 2024
0975cb4
added TelemetryMonitor initialization
IamRanjeetSingh Aug 28, 2024
c84c0e1
handled DateTime serialization for Telemetry litedb
IamRanjeetSingh Aug 28, 2024
c9ffb43
created dedicated TelemetryPipeline class
IamRanjeetSingh Aug 28, 2024
1b3cb0f
something
IamRanjeetSingh Aug 29, 2024
5c53281
updated test names for telemetry steps
IamRanjeetSingh Aug 30, 2024
e973630
refactored TelemetryRetryService
IamRanjeetSingh Aug 30, 2024
572cebf
something more
IamRanjeetSingh Sep 2, 2024
ad7c6f2
fixed spelling
IamRanjeetSingh Sep 2, 2024
16a5c9a
updated method name and unit tests
IamRanjeetSingh Sep 2, 2024
9c1fbca
some more
IamRanjeetSingh Sep 3, 2024
0672d33
added some dummy time to mock telemetry collector
IamRanjeetSingh Sep 3, 2024
9699bfc
removed dummy method
IamRanjeetSingh Sep 3, 2024
0f0bd41
created GRPC Telemetry Collector
IamRanjeetSingh Sep 4, 2024
48e826a
updated Google.Protobuf NuGet package
IamRanjeetSingh Sep 4, 2024
24faede
add feature usage for analyzer
IamRanjeetSingh Sep 4, 2024
9428059
added feature usage for SR Activity, BusinessFlow and RunSet Executio…
IamRanjeetSingh Sep 4, 2024
9857265
updated Protos folder path
IamRanjeetSingh Sep 4, 2024
1b17cf7
updated TelemetryCollector
IamRanjeetSingh Sep 4, 2024
45b47e0
fixed TelemetryMetadata JSON serialization
IamRanjeetSingh Sep 4, 2024
6dd992d
added feature tracking for Application API Model learning
IamRanjeetSingh Sep 6, 2024
23ced9b
implemented feature tracking for Execution Logger
IamRanjeetSingh Sep 6, 2024
94ac8c5
added feature tracking for Action executions
IamRanjeetSingh Sep 6, 2024
23183da
Merge branch 'master' into Features/Telemetry
IamRanjeetSingh Sep 9, 2024
34b7350
refactored
IamRanjeetSingh Sep 11, 2024
df2f22d
updated protobuf files
IamRanjeetSingh Sep 11, 2024
66d78d6
updated version in cs
IamRanjeetSingh Sep 11, 2024
f81544c
fixed a stupid bug
IamRanjeetSingh Sep 11, 2024
fa59e05
updated method name
IamRanjeetSingh Sep 12, 2024
1a3ec78
fixed bug
IamRanjeetSingh Sep 12, 2024
dbcacdf
added flush
IamRanjeetSingh Sep 12, 2024
be7cdc5
added solution id and account details
IamRanjeetSingh Sep 13, 2024
62800ca
Merge branch 'master' into Features/Telemetry
IamRanjeetSingh Sep 16, 2024
8ff0ac2
fixed null handling
IamRanjeetSingh Sep 16, 2024
9cc931d
Merge branch 'Features/Telemetry' of https://github.com/Ginger-Automa…
IamRanjeetSingh Sep 16, 2024
743fa30
Merge branch 'master' into Features/Telemetry
IamRanjeetSingh Sep 16, 2024
e0752e6
used address
IamRanjeetSingh Sep 16, 2024
ee557a2
added try-catch while collecting metadata
IamRanjeetSingh Sep 16, 2024
37020e6
Merge branch 'Features/Telemetry' of https://github.com/Ginger-Automa…
IamRanjeetSingh Sep 16, 2024
8d7d10f
added disposable interface on BlockingBufferQueue
IamRanjeetSingh Sep 16, 2024
338b14e
added curly braces
IamRanjeetSingh Sep 16, 2024
c183949
Merge branch 'master' into Features/Telemetry
IamRanjeetSingh Sep 16, 2024
6c0a78a
used using blocks
IamRanjeetSingh Sep 16, 2024
1cb16d7
Merge branch 'Features/Telemetry' of https://github.com/Ginger-Automa…
IamRanjeetSingh Sep 16, 2024
490c4a6
added more using
IamRanjeetSingh Sep 16, 2024
4a2f4fb
changed metadata json conversion logic
IamRanjeetSingh Sep 16, 2024
d9c2088
Merge branch 'master' into Features/Telemetry
IamRanjeetSingh Sep 16, 2024
a3cee0f
Merge branch 'master' into Features/Telemetry
IamRanjeetSingh Sep 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Ginger/Ginger/AnalyzerLib/AnalyzerPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ limitations under the License.
using amdocs.ginger.GingerCoreNET;
using Amdocs.Ginger.Common;
using Amdocs.Ginger.Common.InterfacesLib;
using Amdocs.Ginger.Common.Telemetry;
using Ginger.Actions;
using Ginger.Run;
using Ginger.SolutionGeneral;
Expand Down Expand Up @@ -209,6 +210,8 @@ public async Task AnalyzeWithoutUI()

private async Task Analyze()
{
using IFeatureTracker featureTracker = Reporter.StartFeatureTracking(FeatureId.Analyzer);

// Each analyzer will set to true once completed, this is prep for multi run in threads for speed
mIssues.Clear();
TotalIssues = 0;
Expand Down Expand Up @@ -267,7 +270,7 @@ await Task.Factory.StartNew(() =>
mAnalyzerCompleted = true;
SetAnalyzeProcessAsCompleted();
}

featureTracker.Metadata.Add("TotalIssues", TotalIssues.ToString());
}

private void SetAnalyzeProcessAsCompleted()
Expand Down
5 changes: 3 additions & 2 deletions Ginger/Ginger/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ limitations under the License.

using amdocs.ginger.GingerCoreNET;
using Amdocs.Ginger.Common;
using Amdocs.Ginger.Common.Telemetry;
using Amdocs.Ginger.CoreNET.log4netLib;
using Amdocs.Ginger.CoreNET.RunLib;
using Amdocs.Ginger.Repository;
Expand Down Expand Up @@ -171,7 +172,7 @@ private void Application_DispatcherUnhandledException(object sender, System.Wind
}

//log it
Reporter.ToLog(eLogLevel.ERROR, ex.ToString(), ex);
Reporter.ToLog(eLogLevel.ERROR, ex.ToString(), ex, TelemetryMetadata.WithTags("ApplicationUnhandledException"));

//add to dictionary to make sure same exception won't show more than 3 times
if (mExceptionsDic.ContainsKey(ex.Message))
Expand Down Expand Up @@ -256,7 +257,7 @@ private void Application_Startup(object sender, StartupEventArgs e)
// add additional classes from Ginger and GingerCore
InitClassTypesDictionary();

WorkSpace.Instance.InitWorkspace(new GingerWorkSpaceReporter(), new DotNetFrameworkHelper());
WorkSpace.Instance.InitWorkspace(new GingerWorkSpaceReporter(), new DotNetFrameworkHelper(), WorkSpace.NewTelemetryQueueManager());

Amdocs.Ginger.CoreNET.log4netLib.GingerLog.PrintStartUpInfo();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
#endregion

using Amdocs.Ginger.Common;
using Amdocs.Ginger.Common.Telemetry;
using Amdocs.Ginger.Repository;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -65,6 +66,9 @@ public class WSDLParser : APIConfigurationsDocumentParserBase

public override ObservableList<ApplicationAPIModel> ParseDocument(string URL, ObservableList<ApplicationAPIModel> AAMSList, bool avoidDuplicatesNodes = false)
{
using IFeatureTracker featureTracker = Reporter.StartFeatureTracking(FeatureId.AAMLearning);
featureTracker.Metadata.Add("APIType", "WSDL");

mURL = URL;
mAAMList = AAMSList;
AddServiceDescription(URL);
Expand Down
51 changes: 47 additions & 4 deletions Ginger/Ginger/Run/RunSetsExecutionsHistoryPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ limitations under the License.
using AccountReport.Contracts.GraphQL.ResponseModels;
using amdocs.ginger.GingerCoreNET;
using Amdocs.Ginger.Common;
using Amdocs.Ginger.Common.Telemetry;
using Amdocs.Ginger.CoreNET;
using Amdocs.Ginger.CoreNET.BPMN.Exportation;
using Amdocs.Ginger.CoreNET.Execution;
Expand Down Expand Up @@ -959,18 +960,60 @@ private async Task ExportBPMNFromRunSetReportAsync(RunSetReport runSetReport)
}

int exportedSuccessfullyCount = 0;
foreach (ExecutedBusinessFlow executedBusinessFlow in executedBusinessFlows)
using (IFeatureTracker featureTracker = Reporter.StartFeatureTracking(FeatureId.ExportRunSetExecutionHistoryBPMN))
{
try
{
exporter.Export(executedBusinessFlow, BPMNExportPath);
exportedSuccessfullyCount++;
featureTracker.Metadata.Add("BusinessFlowCount", executedBusinessFlows.Count().ToString());

int activityGroupCount = executedBusinessFlows
.Where(ex => ex != null)
.Select(ex => ex.BusinessFlow)
.Where(bf => bf != null && bf.Active && bf.ActivitiesGroups != null)
.SelectMany(bf => bf.ActivitiesGroups)
.Where(ag => ag != null)
.Count();
featureTracker.Metadata.Add("ActivityGroupCount", activityGroupCount.ToString());

int activityCount = executedBusinessFlows
.Where(ex => ex != null)
.Select(ex => ex.BusinessFlow)
.Where(bf => bf != null && bf.Active && bf.Activities != null)
.SelectMany(bf => bf.Activities)
.Where(activity => activity != null && activity.Active)
.Count();
featureTracker.Metadata.Add("ActivityCount", activityCount.ToString());

int actionCount = executedBusinessFlows
.Where(ex => ex != null)
.Select(ex => ex.BusinessFlow)
.Where(bf => bf != null && bf.Active && bf.Activities != null)
.SelectMany(bf => bf.Activities)
.Where(activity => activity != null && activity.Active && activity.Acts != null)
.SelectMany(activity => activity.Acts)
.Where(act => act != null && act.Active)
.Count();
featureTracker.Metadata.Add("ActionCount", actionCount.ToString());
}
catch (Exception ex)
{
Reporter.ToLog(eLogLevel.ERROR, $"Error occurred while exporting BPMN for business flow {executedBusinessFlow.Name}.", ex);
Reporter.ToLog(eLogLevel.DEBUG, $"error while capturing '{FeatureId.ExportRunSetExecutionHistoryBPMN}' feature metadata", ex);
}

foreach (ExecutedBusinessFlow executedBusinessFlow in executedBusinessFlows)
{
try
{
exporter.Export(executedBusinessFlow, BPMNExportPath);
exportedSuccessfullyCount++;
}
catch (Exception ex)
{
Reporter.ToLog(eLogLevel.ERROR, $"Error occurred while exporting BPMN for business flow {executedBusinessFlow.Name}.", ex);
}
}
}

if (exportedSuccessfullyCount > 0)
{
Dispatcher.Invoke(() => Reporter.ToUser(eUserMsgKey.MultipleExportToBPMNSuccessful, exportedSuccessfullyCount));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ limitations under the License.
using Amdocs.Ginger.CoreNET.BPMN.Conversion;
using Amdocs.Ginger.CoreNET.BPMN.Exportation;
using Ginger.Repository;
using Amdocs.Ginger.Common.Telemetry;
using static Amdocs.Ginger.CoreNET.BPMN.Exportation.RunSetExecutionHistoryToBPMNExporter;

namespace Ginger.SolutionWindows.TreeViewItems
{
Expand Down Expand Up @@ -335,7 +337,52 @@ private void ExportBusinessFlowBPMN()
{
ExportPath = fullBPMNExportPath
});
string exportPath = businessFlowToBPMNExporter.Export();
int? activitiesGroupCount = null;
int? activityCount = null;
int? actionCount = null;
try
{
if (mBusinessFlow.Activities != null)
{
activitiesGroupCount = mBusinessFlow.ActivitiesGroups.Count;

activityCount = mBusinessFlow.Activities.Where(a => a.Active).Count();

actionCount = mBusinessFlow
.Activities
.Select(activity =>
{
if (activity == null || !activity.Active || activity.Acts == null)
{
return 0;
}
return activity.Acts.Where(act => act != null && act.Active).Count();
})
.Aggregate((count, total) => total + count);
}
}
catch (Exception ex)
{
Reporter.ToLog(eLogLevel.DEBUG, $"error while capturing '{FeatureId.ExportBusinessFlowBPMN}' feature metadata", ex);
}

string exportPath = string.Empty;
using (IFeatureTracker featureTracker = Reporter.StartFeatureTracking(FeatureId.ExportBusinessFlowBPMN))
{
if (activitiesGroupCount != null)
{
featureTracker.Metadata.Add("ActivitiesGroupCount", activitiesGroupCount.ToString());
}
if (activityCount != null)
{
featureTracker.Metadata.Add("ActivityCount", activityCount.ToString());
}
if (actionCount != null)
{
featureTracker.Metadata.Add("ActionCount", actionCount.ToString());
}
exportPath = businessFlowToBPMNExporter.Export();
}
string solutionRelativeExportPath = WorkSpace.Instance.SolutionRepository.ConvertFullPathToBeRelative(exportPath);

Reporter.ToUser(eUserMsgKey.ExportToBPMNSuccessful, solutionRelativeExportPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ limitations under the License.
using amdocs.ginger.GingerCoreNET;
using Amdocs.Ginger.Common;
using Amdocs.Ginger.Common.Enums;
using Amdocs.Ginger.Common.Telemetry;
using Amdocs.Ginger.CoreNET.BPMN.Conversion;
using Amdocs.Ginger.CoreNET.BPMN.Exceptions;
using Amdocs.Ginger.CoreNET.BPMN.Exportation;
Expand All @@ -34,6 +35,7 @@ limitations under the License.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
Expand Down Expand Up @@ -140,7 +142,42 @@ private void ExportActivityGroupToBPMN()

string fullBPMNExportPath = WorkSpace.Instance.Solution.SolutionOperations.ConvertSolutionRelativePath(BPMNExportPath);
ActivitiesGroupToBPMNExporter activitiesGroupToBPMNExporter = new(mActivitiesGroup, fullBPMNExportPath);
string exportPath = activitiesGroupToBPMNExporter.Export();

int? activityCount = null;
int? actionCount = null;
try
{
if (mActivitiesGroup.ActivitiesIdentifiers != null)
{
activityCount = mActivitiesGroup.ActivitiesIdentifiers.Where(a => a.IdentifiedActivity != null && a.IdentifiedActivity.Active).Count();

actionCount = mActivitiesGroup
.ActivitiesIdentifiers
.Select(ai => ai.IdentifiedActivity)
.Where(activity => activity != null && activity.Active && activity.Acts != null)
.SelectMany(activity => activity.Acts.Where(act => act != null && act.Active))
.Count();
}
}
catch (Exception ex)
{
Reporter.ToLog(eLogLevel.DEBUG, $"error while capturing '{FeatureId.ExportActivitiesGroupBPMN}' feature metadata", ex);
}

string exportPath = string.Empty;
using (IFeatureTracker featureTracker = Reporter.StartFeatureTracking(FeatureId.ExportActivitiesGroupBPMN))
{
if (activityCount != null)
{
featureTracker.Metadata.Add("ActivityCount", activityCount.ToString());
}
if (actionCount != null)
{
featureTracker.Metadata.Add("ActionCount", actionCount.ToString());
}
exportPath = activitiesGroupToBPMNExporter.Export();
}

string solutionRelativeExportPath = WorkSpace.Instance.SolutionRepository.ConvertFullPathToBeRelative(exportPath);

Reporter.ToUser(eUserMsgKey.ExportToBPMNSuccessful, solutionRelativeExportPath);
Expand Down
6 changes: 5 additions & 1 deletion Ginger/GingerAutoPilot/APIModelLib/JSONTemplateParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
#endregion

using Amdocs.Ginger.Common.GeneralLib;
using Amdocs.Ginger.Common.Telemetry;
using Amdocs.Ginger.Repository;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
Expand All @@ -34,9 +35,12 @@ public class JSONTemplateParser : APIConfigurationsDocumentParserBase
{
public override ObservableList<ApplicationAPIModel> ParseDocument(string FileName, ObservableList<ApplicationAPIModel> AAMSList, bool avoidDuplicatesNodes = false)
{
using IFeatureTracker featureTracker = Reporter.StartFeatureTracking(FeatureId.AAMLearning);
featureTracker.Metadata.Add("APIType", "JSON_Template");
string jsOnText = System.IO.File.ReadAllText(FileName);
string fileName = Path.GetFileNameWithoutExtension(FileName);
return GetParameters(jsOnText, AAMSList, avoidDuplicatesNodes, fileName);
ObservableList<ApplicationAPIModel> parameters = GetParameters(jsOnText, AAMSList, avoidDuplicatesNodes, fileName);
return parameters;
}

public ObservableList<ApplicationAPIModel> ParseDocumentWithJsonContent(string fileContent, ObservableList<ApplicationAPIModel> AAMSList, bool avoidDuplicatesNodes = false)
Expand Down
52 changes: 31 additions & 21 deletions Ginger/GingerAutoPilot/APIModelLib/SwaggerApi/SwaggerParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ limitations under the License.
*/
#endregion

using Amdocs.Ginger.Common.Telemetry;
using Amdocs.Ginger.Repository;
using GingerCore;
using Newtonsoft.Json.Linq;
Expand All @@ -32,32 +33,41 @@ public override ObservableList<ApplicationAPIModel> ParseDocument(string FileNam
{
if (IsValidYaml(FileName))
{
try
using (IFeatureTracker featureTracker = Reporter.StartFeatureTracking(FeatureId.AAMLearning))
{
string fileContent = FileContentProvider(FileName);
string fileConverted = ConvertYamlToJson(fileContent);
JToken.Parse(fileConverted); // doing the Jtoken to validate the json file
Swaggerdoc = SwaggerDocument.FromJsonAsync(fileConverted).Result;
}
catch(Exception ex)
{
Reporter.ToLog(eLogLevel.ERROR, "Error occurred while trying to read provided yaml document " , ex);
Reporter.ToUser(eUserMsgKey.InvalidYAML);
}

try
{
featureTracker.Metadata.Add("APIType", "Swagger");
featureTracker.Metadata.Add("FileType", "YAML");
string fileContent = FileContentProvider(FileName);
string fileConverted = ConvertYamlToJson(fileContent);
JToken.Parse(fileConverted); // doing the Jtoken to validate the json file
Swaggerdoc = SwaggerDocument.FromJsonAsync(fileConverted).Result;
}
catch (Exception ex)
{
Reporter.ToLog(eLogLevel.ERROR, "Error occurred while trying to read provided yaml document ", ex);
Reporter.ToUser(eUserMsgKey.InvalidYAML);
}
}
}
else
{
try
{
string fileContent = FileContentProvider(FileName);
JToken.Parse(fileContent); // doing the Jtoken to validate the json file
Swaggerdoc = SwaggerDocument.FromJsonAsync(FileContentProvider(FileName)).Result;
}
catch (Exception ex)
using (IFeatureTracker featureTracker = Reporter.StartFeatureTracking(FeatureId.AAMLearning))
{
Reporter.ToLog(eLogLevel.ERROR, "Error occurred while trying to read provided json document ", ex);
Reporter.ToUser(eUserMsgKey.InvalidJSON);
try
{
featureTracker.Metadata.Add("APIType", "Swagger");
featureTracker.Metadata.Add("FileType", "JSON");
string fileContent = FileContentProvider(FileName);
JToken.Parse(fileContent); // doing the Jtoken to validate the json file
Swaggerdoc = SwaggerDocument.FromJsonAsync(FileContentProvider(FileName)).Result;
}
catch (Exception ex)
{
Reporter.ToLog(eLogLevel.ERROR, "Error occurred while trying to read provided json document ", ex);
Reporter.ToUser(eUserMsgKey.InvalidJSON);
}
}
}

Expand Down
6 changes: 5 additions & 1 deletion Ginger/GingerAutoPilot/APIModelLib/XMLTemplateParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
#endregion

using Amdocs.Ginger.Common;
using Amdocs.Ginger.Common.Telemetry;
using System.Collections.Generic;
using System.IO;
using System.Xml;
Expand All @@ -29,9 +30,12 @@ public class XMLTemplateParser : APIConfigurationsDocumentParserBase

public override ObservableList<ApplicationAPIModel> ParseDocument(string FileName, ObservableList<ApplicationAPIModel> AAMSList, bool avoidDuplicatesNodes = false)
{
using IFeatureTracker featureTracker = Reporter.StartFeatureTracking(FeatureId.AAMLearning);
featureTracker.Metadata.Add("APIType", "XMLTemplate");
XmlDocument doc = new XmlDocument();
doc.Load(FileName);
return GetParameters(doc, AAMSList, avoidDuplicatesNodes);
ObservableList<ApplicationAPIModel> parameters = GetParameters(doc, AAMSList, avoidDuplicatesNodes);
return parameters;
}

public ObservableList<ApplicationAPIModel> ParseDocumentWithXMLContent(string fileContent, ObservableList<ApplicationAPIModel> AAMSList, bool avoidDuplicatesNodes = false)
Expand Down
2 changes: 1 addition & 1 deletion Ginger/GingerAutoPilot/GingerAutoPilot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<PropertyGroup>
<LangVersion>7.3</LangVersion>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
Expand Down
2 changes: 1 addition & 1 deletion Ginger/GingerCore/GingerCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@
<Version>1.0.1</Version>
</PackageReference>
<PackageReference Include="Google.Protobuf">
<Version>3.15.0</Version>
<Version>3.28.0</Version>
</PackageReference>
<PackageReference Include="HtmlAgilityPack">
<Version>1.11.58</Version>
Expand Down
Loading
Loading