Graphing Calculator Diagnostics Instrumentation (#1041)

* Add telemetry for keyboard button usage in graphing mode

* Added the diagnostics for EquationAdded and FunctionAnalysis

* Added remaining diagnostics events for graphing calculator

* Fix proj files to include the IsStoreBuild condition. Move the Delayer class to the Calculator/Utils folder

* Ensure the variable textbox has focus before logging diagnostics

* Move maxVariableCount check into the tracelogger class

* Created enums and updated the slider value changed method to remove the variable from the map after the log method is called

* Re-enable hidden lines when the expression is updated

* Fixed extra line in grapher.h and removed the conditional logging for variable count

* Updated logging per PR feedback

* Updated variable logging and fixed issues in the IsEquationLineDisabled binding the EditTextBox control.

* Update per PR feedback

* Added TraceLogging project to contain shared logging logic.

* Updated TraceLogging project and updated tracelogger classes to use the TraceLogging project methods

* Updated VariableLogging to log variable name. And updated per PR comments

* Updated Variables logging to log count changed instead of variable added and fixed issue with variableSliders not being initialized

* Remove outdated tracelogging call caused by rebase

* Updated Delayer class to DispatcherTimerDelayer and fixed some small formatting issues

* Fixed missing Dalyer class name updates

* Removed extra line in traceloger.h
This commit is contained in:
Stephanie Anderl
2020-03-12 14:05:47 -07:00
committed by GitHub
parent 4336c58105
commit 18a1f82035
42 changed files with 981 additions and 292 deletions

View File

@@ -197,7 +197,16 @@ namespace GraphControl
return;
}
PlotGraph(true);
bool keepCurrentView = true;
// If the equation has changed, the IsLineEnabled state is reset.
// This checks if the equation has been reset and sets keepCurrentView to false in this case.
if (!equation->HasGraphError && !equation->IsValidated && equation->IsLineEnabled)
{
keepCurrentView = false;
}
PlotGraph(keepCurrentView);
}
KeyGraphFeaturesInfo ^ Grapher::AnalyzeEquation(Equation ^ equation)
@@ -254,6 +263,25 @@ namespace GraphControl
}
}
int valid = 0;
int invalid = 0;
for (Equation ^ eq : Equations)
{
if (eq->HasGraphError)
{
invalid++;
}
if (eq->IsValidated)
{
valid++;
}
}
if (!m_trigUnitsChanged)
{
TraceLogger::GetInstance()->LogEquationCountChanged(valid, invalid);
}
m_trigUnitsChanged = false;
GraphPlottedEvent(this, ref new RoutedEventArgs());
}
@@ -457,6 +485,11 @@ namespace GraphControl
}
}
if (Variables->Size != updatedVariables->Size)
{
TraceLogger::GetInstance()->LogVariableCountChanged(updatedVariables->Size);
}
Variables = updatedVariables;
VariablesUpdated(this, Variables);
}
@@ -968,6 +1001,7 @@ optional<vector<shared_ptr<Graphing::IEquation>>> Grapher::TryInitializeGraph(bo
m_graph->GetRenderer()->GetDisplayRanges(xMin, xMax, yMin, yMax);
auto initResult = m_graph->TryInitialize(graphingExp);
m_graph->GetRenderer()->SetDisplayRanges(xMin, xMax, yMin, yMax);
return initResult;
}
else

View File

@@ -12,6 +12,7 @@
#include "Common.h"
#include "Models/KeyGraphFeaturesInfo.h"
#include <ppltasks.h>
#include "Logger/TraceLogger.h"
namespace GraphControl
{
@@ -126,6 +127,7 @@ public
if (value != (int)m_solver->EvalOptions().GetTrigUnitMode())
{
m_solver->EvalOptions().SetTrigUnitMode((Graphing::EvalTrigUnitMode)value);
m_trigUnitsChanged = true;
PlotGraph(true);
}
}
@@ -296,6 +298,7 @@ public
void SetEquationsAsValid();
void SetEquationErrors();
std::optional<std::vector<std::shared_ptr<Graphing::IEquation>>> TryInitializeGraph(bool keepCurrentView, _In_ const Graphing::IExpression* graphingExp = nullptr);
private:
DX::RenderMain ^ m_renderMain = nullptr;
@@ -317,6 +320,7 @@ public
const std::shared_ptr<Graphing::IGraph> m_graph;
bool m_calculatedForceProportional = false;
bool m_tracingTracking;
bool m_trigUnitsChanged;
enum KeysPressedSlots
{
Left,

View File

@@ -283,12 +283,18 @@
<AdditionalLibraryDirectories>$(GraphingImplLibDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(IsStoreBuild)' == 'True'">
<ClCompile>
<AdditionalOptions>/DSEND_DIAGNOSTICS %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="Control\Grapher.h" />
<ClInclude Include="DirectX\DeviceResources.h" />
<ClInclude Include="DirectX\DirectXHelper.h" />
<ClInclude Include="DirectX\NearestPointRenderer.h" />
<ClInclude Include="DirectX\RenderMain.h" />
<ClInclude Include="Logger\TraceLogger.h" />
<ClInclude Include="Models\Equation.h" />
<ClInclude Include="Models\EquationCollection.h" />
<ClInclude Include="Models\KeyGraphFeaturesInfo.h" />
@@ -301,6 +307,7 @@
<ClCompile Include="DirectX\DeviceResources.cpp" />
<ClCompile Include="DirectX\NearestPointRenderer.cpp" />
<ClCompile Include="DirectX\RenderMain.cpp" />
<ClCompile Include="Logger\TraceLogger.cpp" />
<ClCompile Include="Models\Equation.cpp" />
<ClCompile Include="Models\KeyGraphFeaturesInfo.cpp" />
<ClCompile Include="pch.cpp">
@@ -322,6 +329,11 @@
<Project>{52E03A58-B378-4F50-8BFB-F659FB85E790}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TraceLogging\TraceLogging.vcxproj">
<Project>{fc81ff41-02cd-4cd9-9bc5-45a1e39ac6ed}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets" />
</Project>

View File

@@ -32,6 +32,7 @@
<ClCompile Include="Models\Equation.cpp">
<Filter>Models</Filter>
</ClCompile>
<ClCompile Include="Logger\TraceLogger.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h" />
@@ -59,6 +60,7 @@
<ClInclude Include="Models\EquationCollection.h">
<Filter>Models</Filter>
</ClInclude>
<ClInclude Include="Logger\TraceLogger.h" />
</ItemGroup>
<ItemGroup>
<Page Include="Themes\generic.xaml">
@@ -66,9 +68,8 @@
</Page>
</ItemGroup>
<ItemGroup>
<None Include="$(ProjectDir)\GraphingImplOverrides.props" />
</ItemGroup>
<ItemGroup>
<CopyFileToFolders Include="$(GraphingImplDll)" />
<CopyFileToFolders Include="$(GraphingEngineDll)" />
<CopyFileToFolders Include="$(GraphingImplDll)" />
<CopyFileToFolders Include="$(GraphingEngineDll)" />
</ItemGroup>

View File

@@ -0,0 +1,89 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "TraceLogger.h"
using namespace TraceLogging;
using namespace Concurrency;
using namespace std;
using namespace Platform;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Diagnostics;
using namespace Windows::Globalization;
namespace GraphControl
{
static reader_writer_lock s_traceLoggerLock;
constexpr auto GRAPHING_MODE = L"Graphing";
constexpr auto CALC_MODE = L"CalcMode";
// Diagnostics events. Uploaded to asimov.
constexpr auto EVENT_NAME_EQUATION_COUNT_CHANGED = L"EquationCountChanged";
constexpr auto EVENT_NAME_FUNCTION_ANALYSIS_PERFORMED = L"FunctionAnalysisPerformed";
constexpr auto EVENT_NAME_VARIABLES_COUNT_CHANGED = L"VariablesCountChanged";
TraceLogger ^ TraceLogger::GetInstance()
{
static TraceLogger ^ s_selfInstance = ref new TraceLogger();
return s_selfInstance;
}
void TraceLogger::LogEquationCountChanged(int currentValidEquations, int currentInvalidEquations)
{
static bool firstRun = true;
if (firstRun)
{
firstRun = false;
return;
}
// Update the total valid/invalid equations to record the max value.
// Equations are added/removed/updated one at a time, so we know either
// currentValidEquations or currentInvalidEquations increased,
// but they cannot both increase at the same time
// If an equation was removed, do not decrement the total count.
static uint64 TotalValidEquations = 0;
static uint64 TotalInvalidEquations = 0;
static uint64 PreviousValidEquations = 0;
static uint64 PreviousInvalidEquations = 0;
if (currentValidEquations > PreviousValidEquations)
{
TotalValidEquations++;
}
else if (currentInvalidEquations > PreviousInvalidEquations)
{
TotalInvalidEquations++;
}
PreviousValidEquations = currentValidEquations;
PreviousInvalidEquations = currentInvalidEquations;
auto fields = ref new LoggingFields();
fields->AddString(StringReference(CALC_MODE), StringReference(GRAPHING_MODE));
fields->AddUInt64(StringReference(L"ConcurrentValidFunctions"), currentValidEquations);
fields->AddUInt64(StringReference(L"ConcurrentInvalidFunctions"), currentInvalidEquations);
fields->AddUInt64(StringReference(L"TotalValidFunctions"), TotalValidEquations);
fields->AddUInt64(StringReference(L"TotalInvalidFunctions"), TotalInvalidEquations);
TraceLoggingCommon::GetInstance()->LogLevel2Event(StringReference(EVENT_NAME_EQUATION_COUNT_CHANGED), fields);
}
void TraceLogger::LogFunctionAnalysisPerformed(int analysisErrorType, uint32 tooComplexFlag)
{
auto fields = ref new LoggingFields();
fields->AddString(StringReference(CALC_MODE), StringReference(GRAPHING_MODE));
fields->AddInt32(StringReference(L"AnalysisErrorType"), analysisErrorType);
fields->AddUInt32(StringReference(L"TooComplexFeatures"), tooComplexFlag);
TraceLoggingCommon::GetInstance()->LogLevel2Event(StringReference(EVENT_NAME_FUNCTION_ANALYSIS_PERFORMED), fields);
}
void TraceLogger::LogVariableCountChanged(int variablesCount)
{
auto fields = ref new LoggingFields();
fields->AddString(StringReference(CALC_MODE), StringReference(GRAPHING_MODE));
fields->AddInt64(StringReference(L"VariableCount"), variablesCount);
TraceLoggingCommon::GetInstance()->LogLevel2Event(StringReference(EVENT_NAME_VARIABLES_COUNT_CHANGED), fields);
}
}

View File

@@ -0,0 +1,27 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#pragma once
#include "Common.h"
// A trace logging provider can only be instantiated and registered once per module.
// This class implements a singleton model ensure that only one instance is created.
namespace GraphControl
{
public ref class TraceLogger sealed
{
internal:
static TraceLogger ^ GetInstance();
void LogEquationCountChanged(int currentValidEquations, int currentInvalidEquations);
void LogFunctionAnalysisPerformed(int analysisErrorType, uint32 tooComplexFlag);
void LogVariableCountChanged(int variablesCount);
private:
TraceLogger()
{
}
};
}

View File

@@ -59,6 +59,8 @@ KeyGraphFeaturesInfo ^ KeyGraphFeaturesInfo::Create(IGraphFunctionAnalysisData d
res->ObliqueAsymptotes = ConvertWStringVector(data.ObliqueAsymptotes);
res->TooComplexFeatures = data.TooComplexFeatures;
res->AnalysisError = CalculatorApp::AnalysisErrorType::NoError;
TraceLogger::GetInstance()->LogFunctionAnalysisPerformed(CalculatorApp::AnalysisErrorType::NoError, res->TooComplexFeatures);
return res;
}
@@ -66,5 +68,7 @@ KeyGraphFeaturesInfo ^ KeyGraphFeaturesInfo::Create(CalculatorApp::AnalysisError
{
auto res = ref new KeyGraphFeaturesInfo();
res->AnalysisError = type;
TraceLogger::GetInstance()->LogFunctionAnalysisPerformed(type, 0);
return res;
}

View File

@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#pragma once
//C4453: A '[WebHostHidden]' type should not be used on the published surface of a public type that is not '[WebHostHidden]'

View File

@@ -3,6 +3,7 @@
#include <winrt/base.h>
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Foundation.Collections.h>
#include <winrt/Windows.Foundation.Diagnostics.h>
#include <winrt/Windows.UI.Xaml.Interop.h>
template <typename T>