Skip to content

Commit

Permalink
Add basic tracing for builds
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanKert committed Apr 27, 2019
1 parent 3519228 commit b1b0530
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 30 deletions.
1 change: 1 addition & 0 deletions src/BuildVision.Contracts/Models/IBuildInformationModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace BuildVision.Contracts.Models
{
public interface IBuildInformationModel : INotifyPropertyChanged
{
Guid BuildId { get; set; }
BuildAction BuildAction { get; set; }
DateTime? BuildFinishTime { get; set; }
BuildScope BuildScope { get; set; }
Expand Down
4 changes: 3 additions & 1 deletion src/BuildVision/Helpers/StateConverterHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using BuildVision.Contracts;
using BuildVision.Common.Diagnostics;
using BuildVision.Contracts;
using Microsoft.VisualStudio.Shell.Interop;

namespace BuildVision.Tool.Models
Expand All @@ -21,6 +22,7 @@ public static BuildAction ConvertSolutionBuildFlagsToBuildAction(uint dwAction,
}
else
{
DiagnosticsClient.TrackTrace($"Received unknown DW Action {dwAction} (SolutionFlags: {solutionFlags}.");
return BuildAction.Unknown;
}
}
Expand Down
30 changes: 1 addition & 29 deletions src/BuildVision/Properties/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,4 @@
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1305:Specify IFormatProvider", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.Helpers.ProjectExtensions.GetFrameworkString(EnvDTE.Project)~System.String")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1305:Specify IFormatProvider", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.Helpers.ProjectExtensions.GetProjectTypeFromRegistry(System.String,System.String)~System.String")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1305:Specify IFormatProvider", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.Tool.Building.BuildService.GetCopyBuildOutputFilesToClipboardActionMessage(System.String,System.String[])~System.String")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.Core.BuildInformationProvider.BuildOutputLogger_OnErrorRaised(BuildVision.UI.Contracts.BuildProjectContextEntry,System.Object,BuildVision.Contracts.ErrorLevel)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.Core.BuildInformationProvider.ProjectBuildStarted(BuildVision.UI.Models.IProjectItem,BuildVision.Contracts.BuildAction)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.Core.SolutionProvider.RefrehSolutionModel")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.Helpers.ProjectExtensions.GetExtenderNames(EnvDTE.Project)~System.String")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.Helpers.ProjectExtensions.GetFlavourTypes(EnvDTE.Project)~System.Collections.Generic.IEnumerable{System.String}")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.Helpers.ProjectExtensions.GetFrameworkString(EnvDTE.Project)~System.String")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.Helpers.ProjectExtensions.GetLanguageName(EnvDTE.Project)~System.String")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.Helpers.ProjectExtensions.GetOutputType(EnvDTE.Project)~System.String")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.Helpers.ProjectExtensions.GetProjectTypeFromRegistry(System.String,System.String)~System.String")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.Helpers.ProjectExtensions.GetTreePath(EnvDTE.Project,System.Boolean)~System.String")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.Helpers.ProjectExtensions.IsHidden(EnvDTE.Project)~System.Boolean")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.Helpers.ProjectExtensions.IsProjectHidden(System.String)~System.Boolean")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.Helpers.ProjectExtensions.TryGetParentProject(EnvDTE.Project)~EnvDTE.Project")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.Helpers.PropertiesExtensions.TryGetPropertyValueOrDefault(EnvDTE.Properties,System.String)~System.Object")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.Helpers.SolutionProjectsExtensions.GetProjectItems(EnvDTE.Solution)~System.Collections.Generic.IList{BuildVision.UI.Models.ProjectItem}")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.Helpers.SolutionProjectsExtensions.ToSolutionBuildState(EnvDTE.Solution)~BuildVision.Core.SolutionModel")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.Helpers.SolutionProjectsExtensions.UpdateNameProperties(EnvDTE.Project,BuildVision.UI.Models.ProjectItem)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.Helpers.SolutionProjectsExtensions.UpdateProperties(EnvDTE.Project,BuildVision.UI.Models.ProjectItem,System.String,System.String)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.Services.ErrorNavigationService.NavigateToErrorItem(BuildVision.Contracts.ErrorItem)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.Tool.Building.BuildOutputLogger.Attach")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.Tool.Building.BuildOutputLogger.EventSource_ErrorRaised(Microsoft.Build.Framework.BuildEventArgs,BuildVision.Contracts.ErrorLevel)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.Tool.Building.BuildService.CancelBuildAsync(BuildVision.Contracts.Models.IBuildInformationModel)~System.Threading.Tasks.Task")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.Tool.Building.BuildService.ProjectCopyBuildOutputFilesToClipBoard(BuildVision.UI.Models.IProjectItem)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.Tool.Building.BuildService.RaiseCommand(Microsoft.VisualStudio.VSConstants.VSStd97CmdID)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.Tool.Building.BuildService.RaiseCommandForSelectedProject(BuildVision.UI.Models.IProjectItem,System.Int32)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<Pending>", Scope = "member", Target = "~M:BuildVision.Views.Settings.PackageSettingsProvider.LoadSettings")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1305:Specify IFormatProvider", Justification = "<Pending>")]
21 changes: 21 additions & 0 deletions src/BuildVision/Services/BuildInformationProvider.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel.Composition;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using BuildVision.Common;
using BuildVision.Common.Diagnostics;
using BuildVision.Common.Logging;
using BuildVision.Contracts;
using BuildVision.Contracts.Models;
Expand Down Expand Up @@ -206,6 +208,7 @@ public void BuildStarted(BuildAction buildAction, BuildScope buildScope)
BuildInformationModel.CurrentBuildState = BuildState.InProgress;
BuildInformationModel.BuildAction = buildAction;
BuildInformationModel.BuildScope = buildScope;
BuildInformationModel.BuildId = Guid.NewGuid();

_buildProcessCancellationToken = new CancellationTokenSource();
_windowStateService.ApplyToolWindowStateAction(_packageSettingsProvider.Settings.WindowSettings.WindowActionOnBuildBegin);
Expand All @@ -216,6 +219,13 @@ public void BuildStarted(BuildAction buildAction, BuildScope buildScope)
_origTextCurrentState = message;
BuildInformationModel.StateMessage = _origTextCurrentState;
_taskBarInfoService.UpdateTaskBarInfo(BuildInformationModel.CurrentBuildState, BuildInformationModel.BuildScope, Projects.Count, GetFinishedProjectsCount());

DiagnosticsClient.TrackEvent("BuildStarted", new Dictionary<string, string>
{
{ "BuildId", BuildInformationModel.BuildId.ToString() },
{ "BuildAction", buildAction.ToString() },
{ "BuildScope", buildScope.ToString() }
});
}

public void ProjectBuildStarted(IProjectItem projectItem, BuildAction buildAction)
Expand Down Expand Up @@ -369,6 +379,17 @@ public void BuildFinished(bool success, bool canceled)
BuildInformationModel.CurrentBuildState = canceled ? BuildState.Cancelled : BuildState.Failed;
}

DiagnosticsClient.TrackEvent("BuildFinished", new Dictionary<string, string>
{
{ "BuildId", BuildInformationModel.BuildId.ToString() },
{ "BuildAction", BuildInformationModel.BuildAction.ToString() },
{ "BuildScope", BuildInformationModel.BuildScope.ToString() },
{ "BuildState", BuildInformationModel.CurrentBuildState.ToString() },
{ "BuildStartTime", BuildInformationModel.BuildStartTime.ToString() },
{ "BuildFinishTime", BuildInformationModel.BuildFinishTime.ToString() },
{ "ProjectsCount", Projects.Count.ToString() },
});

var message = _buildMessagesFactory.GetBuildDoneMessage(BuildInformationModel);
_statusBarNotificationService.ShowText(message);
BuildInformationModel.StateMessage = message;
Expand Down
2 changes: 2 additions & 0 deletions src/BuildVision/Views/Settings/SettingsDialogPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using BuildVision.Core;
using BuildVision.UI.Settings.Models;
using Microsoft;
using BuildVision.Common.Diagnostics;

namespace BuildVision.Views.Settings
{
Expand Down Expand Up @@ -46,6 +47,7 @@ protected override void OnActivate(CancelEventArgs e)
}

base.OnActivate(e);
DiagnosticsClient.TrackPageView(GetType().Name);
}

protected override void OnApply(PageApplyEventArgs args)
Expand Down

0 comments on commit b1b0530

Please sign in to comment.