Repository: microsoft/terminal (language: cpp)

Issue:
Can we drop the telemetry for VT sequences?
# Description of the new feature/enhancement

We've now reached the point that if we add another VT sequence to the telemetry tracker, the `TraceLoggingWriteActivity` call will fail to compile. I'm not exactly sure what the problem is, but the initial warning/error is: `pasting '_tlg_FOR_imp' and '(' does not result in a valid preprocessing token`, after which there are another 20 or so lines of errors.

It's possible there is a way to work around that, but if we don't really need this telemetry, it would be nicer if we could just drop it altogether. And maybe that will save a bit of parsing overhead in the process.

# Proposed technical implementation details (optional)

Drop the `TermTelemetry` class, and then remove all code that was making calls to it.


Discussion / hints:
I'm all for it. This was more valuable when we like, hardly implemented any sequences. I don't think this is even hooked up to anything at this point. 
YES. PLEASE. Thank you!
The way we implemented this telemetry is wrong, anyway - `TraceLogging` is supposed to be zero-cost if it is not enabled, so every time we put the log behind a function call we're wasting a branch and likely cache fault to determine we aren't supposed to be doing anything.

Fix patch:
diff --git a/src/host/telemetry.cpp b/src/host/telemetry.cpp
index ac37440653b..c8318f118a0 100644
--- a/src/host/telemetry.cpp
+++ b/src/host/telemetry.cpp
@@ -34,9 +34,6 @@ Telemetry::Telemetry() :
     _rgiProcessFileNameIndex(),
     _rguiProcessFileNamesCount(),
     _rgiAlphabeticalIndex(),
-    _rguiProcessFileNamesCodesCount(),
-    _rguiProcessFileNamesFailedCodesCount(),
-    _rguiProcessFileNamesFailedOutsideCodesCount(),
     _rguiTimesApiUsed(),
     _rguiTimesApiUsedAnsi(),
     _uiNumberProcessFileNames(0),
@@ -214,28 +211,6 @@ void Telemetry::FindDialogClosed()
     _uiFindNextClickedTotal = 0;
 }
 
-// Total up all the used VT100 codes and assign them to the last process that was attached.
-// We originally did this when each process disconnected, but some processes don't
-// disconnect when the conhost process exits.  So we have to remember the last process that connected.
-void Telemetry::TotalCodesForPreviousProcess()
-{
-    using namespace Microsoft::Console::VirtualTerminal;
-    // Get the values even if we aren't recording the previously connected process, since we want to reset them to 0.
-    auto _uiTimesUsedCurrent = TermTelemetry::Instance().GetAndResetTimesUsedCurrent();
-    auto _uiTimesFailedCurrent = TermTelemetry::Instance().GetAndResetTimesFailedCurrent();
-    auto _uiTimesFailedOutsideRangeCurrent = TermTelemetry::Instance().GetAndResetTimesFailedOutsideRangeCurrent();
-
-    if (_iProcessConnectedCurrently < c_iMaxProcessesConnected)
-    {
-        _rguiProcessFileNamesCodesCount[_iProcessConnectedCurrently] += _uiTimesUsedCurrent;
-        _rguiProcessFileNamesFailedCodesCount[_iProcessConnectedCurrently] += _uiTimesFailedCurrent;
-        _rguiProcessFileNamesFailedOutsideCodesCount[_iProcessConnectedCurrently] += _uiTimesFailedOutsideRangeCurrent;
-
-        // Don't total any more process connected telemetry, unless a new processes attaches that we want to gather.
-        _iProcessConnectedCurrently = SIZE_MAX;
-    }
-}
-
 // Tries to find the process name amongst our previous process names by doing a binary search.
 // The main difference between this and the standard bsearch library call, is that if this
 // can't find the string, it returns the position the new string should be inserted at.  This saves
@@ -284,8 +259,6 @@ void Telemetry::LogProcessConnected(const HANDLE hProcess)
     // This is a bit of processing, so don't do it for the 95% of machines that aren't being sampled.
     if (TraceLoggingProviderEnabled(g_hConhostV2EventTraceProvider, 0, MICROSOFT_KEYWORD_MEASURES))
     {
-        TotalCodesForPreviousProcess();
-
         // Don't initialize wszFilePathAndName, QueryFullProcessImageName does that for us.  Use QueryFullProcessImageName instead of
         // GetProcessImageFileName because we need the path to begin with a drive letter and not a device name.
         WCHAR wszFilePathAndName[MAX_PATH];
@@ -360,15 +333,8 @@ void Telemetry::WriteFinalTraceLog()
     // This is a bit of processing, so don't do it for the 95% of machines that aren't being sampled.
     if (TraceLoggingProviderEnabled(g_hConhostV2EventTraceProvider, 0, MICROSOFT_KEYWORD_MEASURES))
     {
-        // Normally we would set the activity Id earlier, but since we know the parser only sends
-        // one final log at the end, setting the activity this late should be fine.
-        Microsoft::Console::VirtualTerminal::TermTelemetry::Instance().SetActivityId(_activity.Id());
-        Microsoft::Console::VirtualTerminal::TermTelemetry::Instance().SetShouldWriteFinalLog(_fUserInteractiveForTelemetry);
-
         if (_fUserInteractiveForTelemetry)
         {
-            TotalCodesForPreviousProcess();
-
             // Send this back using "measures" since we want a good sampling of our entire userbase.
             time_t tEndedAt;
             time(&tEndedAt);
@@ -395,9 +361,6 @@ void Telemetry::WriteFinalTraceLog()
                                     // Casting to UINT should be fine, since our array size is only 2K.
                                     TraceLoggingPackedField(_wchProcessFileNames, static_cast<UINT>(sizeof(WCHAR) * _iProcessFileNamesNext), TlgInUNICODESTRING | TlgInVcount, "ProcessesConnected"),
                                     TraceLoggingUInt32Array(_rguiProcessFileNamesCount, _uiNumberProcessFileNames, "ProcessesConnectedCount"),
-                                    TraceLoggingUInt32Array(_rguiProcessFileNamesCodesCount, _uiNumberProcessFileNames, "ProcessesConnectedCodesCount"),
-                                    TraceLoggingUInt32Array(_rguiProcessFileNamesFailedCodesCount, _uiNumberProcessFileNames, "ProcessesConnectedFailedCodesCount"),
-                                    TraceLoggingUInt32Array(_rguiProcessFileNamesFailedOutsideCodesCount, _uiNumberProcessFileNames, "ProcessesConnectedFailedOutsideCount"),
                                     // Send back both starting and ending times separately instead just usage time (ending - starting).
                                     // This can help us determine if they were using multiple consoles at the same time.
                                     TraceLoggingInt32(static_cast<int>(_tStartedAt), "StartedUsingAtSeconds"),
diff --git a/src/host/telemetry.hpp b/src/host/telemetry.hpp
index e35659cb3f1..45cbea796a4 100644
--- a/src/host/telemetry.hpp
+++ b/src/host/telemetry.hpp
@@ -133,7 +133,6 @@ class Telemetry
     void operator=(const Telemetry&);
 
     bool FindProcessName(const WCHAR* pszProcessName, _Out_ size_t* iPosition) const;
-    void TotalCodesForPreviousProcess();
 
     static const int c_iMaxProcessesConnected = 100;
 
@@ -159,12 +158,6 @@ class Telemetry
     unsigned int _rguiProcessFileNamesCount[c_iMaxProcessesConnected];
     // To speed up searching the Process Names, create an alphabetically sorted index.
     size_t _rgiAlphabeticalIndex[c_iMaxProcessesConnected];
-    // Total of how many codes each process used
-    unsigned int _rguiProcessFileNamesCodesCount[c_iMaxProcessesConnected];
-    // Total of how many failed codes each process used
-    unsigned int _rguiProcessFileNamesFailedCodesCount[c_iMaxProcessesConnected];
-    // Total of how many failed codes each process used outside the valid range.
-    unsigned int _rguiProcessFileNamesFailedOutsideCodesCount[c_iMaxProcessesConnected];
     unsigned int _rguiTimesApiUsed[NUMBER_OF_APIS];
     // Most of this array will be empty, and is only used if an API has an ansi specific variant.
     unsigned int _rguiTimesApiUsedAnsi[NUMBER_OF_APIS];
diff --git a/src/terminal/parser/InputStateMachineEngine.hpp b/src/terminal/parser/InputStateMachineEngine.hpp
index 0bcc8398ebf..a2ab34623fd 100644
--- a/src/terminal/parser/InputStateMachineEngine.hpp
+++ b/src/terminal/parser/InputStateMachineEngine.hpp
@@ -15,7 +15,6 @@ Author(s):
 --*/
 #pragma once
 
-#include "telemetry.hpp"
 #include "IStateMachineEngine.hpp"
 #include <functional>
 #include "../../types/inc/IInputEvent.hpp"
diff --git a/src/terminal/parser/OutputStateMachineEngine.cpp b/src/terminal/parser/OutputStateMachineEngine.cpp
index b04a02ff11a..84ec0fa90e0 100644
--- a/src/terminal/parser/OutputStateMachineEngine.cpp
+++ b/src/terminal/parser/OutputStateMachineEngine.cpp
@@ -211,103 +211,78 @@ bool OutputStateMachineEngine::ActionEscDispatch(const VTID id)
         break;
     case EscActionCodes::DECBI_BackIndex:
         success = _dispatch->BackIndex();
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DECBI);
         break;
     case EscActionCodes::DECSC_CursorSave:
         success = _dispatch->CursorSaveState();
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DECSC);
         break;
     case EscActionCodes::DECRC_CursorRestore:
         success = _dispatch->CursorRestoreState();
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DECRC);
         break;
     case EscActionCodes::DECFI_ForwardIndex:
         success = _dispatch->ForwardIndex();
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DECFI);
         break;
     case EscActionCodes::DECKPAM_KeypadApplicationMode:
         success = _dispatch->SetKeypadMode(true);
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DECKPAM);
         break;
     case EscActionCodes::DECKPNM_KeypadNumericMode:
         success = _dispatch->SetKeypadMode(false);
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DECKPNM);
         break;
     case EscActionCodes::NEL_NextLine:
         success = _dispatch->LineFeed(DispatchTypes::LineFeedType::WithReturn);
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::NEL);
         break;
     case EscActionCodes::IND_Index:
         success = _dispatch->LineFeed(DispatchTypes::LineFeedType::WithoutReturn);
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::IND);
         break;
     case EscActionCodes::RI_ReverseLineFeed:
         success = _dispatch->ReverseLineFeed();
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::RI);
         break;
     case EscActionCodes::HTS_HorizontalTabSet:
         success = _dispatch->HorizontalTabSet();
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::HTS);
         break;
     case EscActionCodes::DECID_IdentifyDevice:
         success = _dispatch->DeviceAttributes();
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DA);
         break;
     case EscActionCodes::RIS_ResetToInitialState:
         success = _dispatch->HardReset();
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::RIS);
         break;
     case EscActionCodes::SS2_SingleShift:
         success = _dispatch->SingleShift(2);
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::SS2);
         break;
     case EscActionCodes::SS3_SingleShift:
         success = _dispatch->SingleShift(3);
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::SS3);
         break;
     case EscActionCodes::LS2_LockingShift:
         success = _dispatch->LockingShift(2);
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::LS2);
         break;
     case EscActionCodes::LS3_LockingShift:
         success = _dispatch->LockingShift(3);
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::LS3);
         break;
     case EscActionCodes::LS1R_LockingShift:
         success = _dispatch->LockingShiftRight(1);
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::LS1R);
         break;
     case EscActionCodes::LS2R_LockingShift:
         success = _dispatch->LockingShiftRight(2);
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::LS2R);
         break;
     case EscActionCodes::LS3R_LockingShift:
         success = _dispatch->LockingShiftRight(3);
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::LS3R);
         break;
     case EscActionCodes::DECAC1_AcceptC1Controls:
         success = _dispatch->AcceptC1Controls(true);
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DECAC1);
         break;
     case EscActionCodes::DECDHL_DoubleHeightLineTop:
         success = _dispatch->SetLineRendition(LineRendition::DoubleHeightTop);
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DECDHL);
         break;
     case EscActionCodes::DECDHL_DoubleHeightLineBottom:
         success = _dispatch->SetLineRendition(LineRendition::DoubleHeightBottom);
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DECDHL);
         break;
     case EscActionCodes::DECSWL_SingleWidthLine:
         success = _dispatch->SetLineRendition(LineRendition::SingleWidth);
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DECSWL);
         break;
     case EscActionCodes::DECDWL_DoubleWidthLine:
         success = _dispatch->SetLineRendition(LineRendition::DoubleWidth);
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DECDWL);
         break;
     case EscActionCodes::DECALN_ScreenAlignmentPattern:
         success = _dispatch->ScreenAlignmentPattern();
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DECALN);
         break;
     default:
         const auto commandChar = id[0];
@@ -316,35 +291,27 @@ bool OutputStateMachineEngine::ActionEscDispatch(const VTID id)
         {
         case '%':
             success = _dispatch->DesignateCodingSystem(commandParameter);
-            TermTelemetry::Instance().Log(TermTelemetry::Codes::DOCS);
             break;
         case '(':
             success = _dispatch->Designate94Charset(0, commandParameter);
-            TermTelemetry::Instance().Log(TermTelemetry::Codes::DesignateG0);
             break;
         case ')':
             success = _dispatch->Designate94Charset(1, commandParameter);
-            TermTelemetry::Instance().Log(TermTelemetry::Codes::DesignateG1);
             break;
         case '*':
             success = _dispatch->Designate94Charset(2, commandParameter);
-            TermTelemetry::Instance().Log(TermTelemetry::Codes::DesignateG2);
             break;
         case '+':
             success = _dispatch->Designate94Charset(3, commandParameter);
-            TermTelemetry::Instance().Log(TermTelemetry::Codes::DesignateG3);
             break;
         case '-':
             success = _dispatch->Designate96Charset(1, commandParameter);
-            TermTelemetry::Instance().Log(TermTelemetry::Codes::DesignateG1);
             break;
         case '.':
             success = _dispatch->Designate96Charset(2, commandParameter);
-            TermTelemetry::Instance().Log(TermTelemetry::Codes::DesignateG2);
             break;
         case '/':
             success = _dispatch->Designate96Charset(3, commandParameter);
-            TermTelemetry::Instance().Log(TermTelemetry::Codes::DesignateG3);
             break;
         default:
             // If no functions to call, overall dispatch was a failure.
@@ -455,185 +422,144 @@ bool OutputStateMachineEngine::ActionCsiDispatch(const VTID id, const VTParamete
     {
     case CsiActionCodes::CUU_CursorUp:
         success = _dispatch->CursorUp(parameters.at(0));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::CUU);
         break;
     case CsiActionCodes::CUD_CursorDown:
         success = _dispatch->CursorDown(parameters.at(0));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::CUD);
         break;
     case CsiActionCodes::CUF_CursorForward:
         success = _dispatch->CursorForward(parameters.at(0));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::CUF);
         break;
     case CsiActionCodes::CUB_CursorBackward:
         success = _dispatch->CursorBackward(parameters.at(0));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::CUB);
         break;
     case CsiActionCodes::CNL_CursorNextLine:
         success = _dispatch->CursorNextLine(parameters.at(0));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::CNL);
         break;
     case CsiActionCodes::CPL_CursorPrevLine:
         success = _dispatch->CursorPrevLine(parameters.at(0));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::CPL);
         break;
     case CsiActionCodes::CHA_CursorHorizontalAbsolute:
     case CsiActionCodes::HPA_HorizontalPositionAbsolute:
         success = _dispatch->CursorHorizontalPositionAbsolute(parameters.at(0));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::CHA);
         break;
     case CsiActionCodes::VPA_VerticalLinePositionAbsolute:
         success = _dispatch->VerticalLinePositionAbsolute(parameters.at(0));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::VPA);
         break;
     case CsiActionCodes::HPR_HorizontalPositionRelative:
         success = _dispatch->HorizontalPositionRelative(parameters.at(0));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::HPR);
         break;
     case CsiActionCodes::VPR_VerticalPositionRelative:
         success = _dispatch->VerticalPositionRelative(parameters.at(0));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::VPR);
         break;
     case CsiActionCodes::CUP_CursorPosition:
     case CsiActionCodes::HVP_HorizontalVerticalPosition:
         success = _dispatch->CursorPosition(parameters.at(0), parameters.at(1));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::CUP);
         break;
     case CsiActionCodes::DECSTBM_SetTopBottomMargins:
         success = _dispatch->SetTopBottomScrollingMargins(parameters.at(0).value_or(0), parameters.at(1).value_or(0));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DECSTBM);
         break;
     case CsiActionCodes::DECSLRM_SetLeftRightMargins:
         // Note that this can also be ANSISYSSC, depending on the state of DECLRMM.
         success = _dispatch->SetLeftRightScrollingMargins(parameters.at(0).value_or(0), parameters.at(1).value_or(0));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DECSTBM);
         break;
     case CsiActionCodes::ICH_InsertCharacter:
         success = _dispatch->InsertCharacter(parameters.at(0));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::ICH);
         break;
     case CsiActionCodes::DCH_DeleteCharacter:
         success = _dispatch->DeleteCharacter(parameters.at(0));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DCH);
         break;
     case CsiActionCodes::ED_EraseDisplay:
         success = parameters.for_each([&](const auto eraseType) {
             return _dispatch->EraseInDisplay(eraseType);
         });
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::ED);
         break;
     case CsiActionCodes::DECSED_SelectiveEraseDisplay:
         success = parameters.for_each([&](const auto eraseType) {
             return _dispatch->SelectiveEraseInDisplay(eraseType);
         });
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DECSED);
         break;
     case CsiActionCodes::EL_EraseLine:
         success = parameters.for_each([&](const auto eraseType) {
             return _dispatch->EraseInLine(eraseType);
         });
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::EL);
         break;
     case CsiActionCodes::DECSEL_SelectiveEraseLine:
         success = parameters.for_each([&](const auto eraseType) {
             return _dispatch->SelectiveEraseInLine(eraseType);
         });
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DECSEL);
         break;
     case CsiActionCodes::SM_SetMode:
         success = parameters.for_each([&](const auto mode) {
             return _dispatch->SetMode(DispatchTypes::ANSIStandardMode(mode));
         });
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::SM);
         break;
     case CsiActionCodes::DECSET_PrivateModeSet:
         success = parameters.for_each([&](const auto mode) {
             return _dispatch->SetMode(DispatchTypes::DECPrivateMode(mode));
         });
-        //TODO: MSFT:6367459 Add specific logging for each of the DECSET/DECRST codes
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DECSET);
         break;
     case CsiActionCodes::RM_ResetMode:
         success = parameters.for_each([&](const auto mode) {
             return _dispatch->ResetMode(DispatchTypes::ANSIStandardMode(mode));
         });
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::RM);
         break;
     case CsiActionCodes::DECRST_PrivateModeReset:
         success = parameters.for_each([&](const auto mode) {
             return _dispatch->ResetMode(DispatchTypes::DECPrivateMode(mode));
         });
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DECRST);
         break;
     case CsiActionCodes::SGR_SetGraphicsRendition:
         success = _dispatch->SetGraphicsRendition(parameters);
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::SGR);
         break;
     case CsiActionCodes::DSR_DeviceStatusReport:
         success = _dispatch->DeviceStatusReport(DispatchTypes::ANSIStandardStatus(parameters.at(0)), parameters.at(1));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DSR);
         break;
     case CsiActionCodes::DSR_PrivateDeviceStatusReport:
         success = _dispatch->DeviceStatusReport(DispatchTypes::DECPrivateStatus(parameters.at(0)), parameters.at(1));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DSR);
         break;
     case CsiActionCodes::DA_DeviceAttributes:
         success = parameters.at(0).value_or(0) == 0 && _dispatch->DeviceAttributes();
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DA);
         break;
     case CsiActionCodes::DA2_SecondaryDeviceAttributes:
         success = parameters.at(0).value_or(0) == 0 && _dispatch->SecondaryDeviceAttributes();
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DA2);
         break;
     case CsiActionCodes::DA3_TertiaryDeviceAttributes:
         success = parameters.at(0).value_or(0) == 0 && _dispatch->TertiaryDeviceAttributes();
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DA3);
         break;
     case CsiActionCodes::DECREQTPARM_RequestTerminalParameters:
         success = _dispatch->RequestTerminalParameters(parameters.at(0));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DECREQTPARM);
         break;
     case CsiActionCodes::SU_ScrollUp:
         success = _dispatch->ScrollUp(parameters.at(0));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::SU);
         break;
     case CsiActionCodes::SD_ScrollDown:
         success = _dispatch->ScrollDown(parameters.at(0));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::SD);
         break;
     case CsiActionCodes::ANSISYSRC_CursorRestore:
         success = _dispatch->CursorRestoreState();
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::ANSISYSRC);
         break;
     case CsiActionCodes::IL_InsertLine:
         success = _dispatch->InsertLine(parameters.at(0));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::IL);
         break;
     case CsiActionCodes::DL_DeleteLine:
         success = _dispatch->DeleteLine(parameters.at(0));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DL);
         break;
     case CsiActionCodes::CHT_CursorForwardTab:
         success = _dispatch->ForwardTab(parameters.at(0));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::CHT);
         break;
     case CsiActionCodes::CBT_CursorBackTab:
         success = _dispatch->BackwardsTab(parameters.at(0));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::CBT);
         break;
     case CsiActionCodes::TBC_TabClear:
         success = parameters.for_each([&](const auto clearType) {
             return _dispatch->TabClear(clearType);
         });
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::TBC);
         break;
     case CsiActionCodes::ECH_EraseCharacters:
         success = _dispatch->EraseCharacters(parameters.at(0));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::ECH);
         break;
     case CsiActionCodes::DTTERM_WindowManipulation:
         success = _dispatch->WindowManipulation(parameters.at(0), parameters.at(1), parameters.at(2));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DTTERM_WM);
         break;
     case CsiActionCodes::REP_RepeatCharacter:
         // Handled w/o the dispatch. This function is unique in that way
@@ -648,93 +574,71 @@ bool OutputStateMachineEngine::ActionCsiDispatch(const VTID id, const VTParamete
             _dispatch->PrintString(wstr);
         }
         success = true;
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::REP);
         break;
     case CsiActionCodes::DECSCUSR_SetCursorStyle:
         success = _dispatch->SetCursorStyle(parameters.at(0));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DECSCUSR);
         break;
     case CsiActionCodes::DECSTR_SoftReset:
         success = _dispatch->SoftReset();
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DECSTR);
         break;
     case CsiActionCodes::DECSCA_SetCharacterProtectionAttribute:
         success = _dispatch->SetCharacterProtectionAttribute(parameters);
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DECSCA);
         break;
     case CsiActionCodes::XT_PushSgr:
     case CsiActionCodes::XT_PushSgrAlias:
         success = _dispatch->PushGraphicsRendition(parameters);
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::XTPUSHSGR);
         break;
     case CsiActionCodes::XT_PopSgr:
     case CsiActionCodes::XT_PopSgrAlias:
         success = _dispatch->PopGraphicsRendition();
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::XTPOPSGR);
         break;
     case CsiActionCodes::DECRQM_RequestMode:
         success = _dispatch->RequestMode(DispatchTypes::ANSIStandardMode(parameters.at(0)));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DECRQM);
         break;
     case CsiActionCodes::DECRQM_PrivateRequestMode:
         success = _dispatch->RequestMode(DispatchTypes::DECPrivateMode(parameters.at(0)));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DECRQM);
         break;
     case CsiActionCodes::DECCARA_ChangeAttributesRectangularArea:
         success = _dispatch->ChangeAttributesRectangularArea(parameters.at(0), parameters.at(1), parameters.at(2).value_or(0), parameters.at(3).value_or(0), parameters.subspan(4));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DECCARA);
         break;
     case CsiActionCodes::DECRARA_ReverseAttributesRectangularArea:
         success = _dispatch->ReverseAttributesRectangularArea(parameters.at(0), parameters.at(1), parameters.at(2).value_or(0), parameters.at(3).value_or(0), parameters.subspan(4));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DECRARA);
         break;
     case CsiActionCodes::DECCRA_CopyRectangularArea:
         success = _dispatch->CopyRectangularArea(parameters.at(0), parameters.at(1), parameters.at(2).value_or(0), parameters.at(3).value_or(0), parameters.at(4), parameters.at(5), parameters.at(6), parameters.at(7));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DECCRA);
         break;
     case CsiActionCodes::DECRQPSR_RequestPresentationStateReport:
         success = _dispatch->RequestPresentationStateReport(parameters.at(0));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DECRQPSR);
         break;
     case CsiActionCodes::DECFRA_FillRectangularArea:
         success = _dispatch->FillRectangularArea(parameters.at(0), parameters.at(1), parameters.at(2), parameters.at(3).value_or(0), parameters.at(4).value_or(0));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DECFRA);
         break;
     case CsiActionCodes::DECERA_EraseRectangularArea:
         success = _dispatch->EraseRectangularArea(parameters.at(0), parameters.at(1), parameters.at(2).value_or(0), parameters.at(3).value_or(0));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DECERA);
         break;
     case CsiActionCodes::DECSERA_SelectiveEraseRectangularArea:
         success = _dispatch->SelectiveEraseRectangularArea(parameters.at(0), parameters.at(1), parameters.at(2).value_or(0), parameters.at(3).value_or(0));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DECSERA);
         break;
     case CsiActionCodes::DECIC_InsertColumn:
         success = _dispatch->InsertColumn(parameters.at(0));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DECIC);
         break;
     case CsiActionCodes::DECDC_DeleteColumn:
         success = _dispatch->DeleteColumn(parameters.at(0));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DECDC);
         break;
     case CsiActionCodes::DECSACE_SelectAttributeChangeExtent:
         success = _dispatch->SelectAttributeChangeExtent(parameters.at(0));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DECSACE);
         break;
     case CsiActionCodes::DECRQCRA_RequestChecksumRectangularArea:
         success = _dispatch->RequestChecksumRectangularArea(parameters.at(0).value_or(0), parameters.at(1).value_or(0), parameters.at(2), parameters.at(3), parameters.at(4).value_or(0), parameters.at(5).value_or(0));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DECRQCRA);
         break;
     case CsiActionCodes::DECINVM_InvokeMacro:
         success = _dispatch->InvokeMacro(parameters.at(0).value_or(0));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DECINVM);
         break;
     case CsiActionCodes::DECAC_AssignColor:
         success = _dispatch->AssignColor(parameters.at(0), parameters.at(1).value_or(0), parameters.at(2).value_or(0));
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DECAC);
         break;
     case CsiActionCodes::DECPS_PlaySound:
         success = _dispatch->PlaySounds(parameters);
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::DECPS);
         break;
     default:
         // If no functions to call, overall dispatch was a failure.
@@ -851,7 +755,6 @@ bool OutputStateMachineEngine::ActionOscDispatch(const wchar_t /*wch*/,
         std::wstring title;
         success = _GetOscTitle(string, title);
         success = success && _dispatch->SetWindowTitle(title);
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::OSCWT);
         break;
     }
     case OscActionCodes::SetColor:
@@ -865,7 +768,6 @@ bool OutputStateMachineEngine::ActionOscDispatch(const wchar_t /*wch*/,
             const auto rgb = til::at(colors, i);
             success = success && _dispatch->SetColorTableEntry(tableIndex, rgb);
         }
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::OSCCT);
         break;
     }
     case OscActionCodes::SetForegroundColor:
@@ -886,7 +788,6 @@ bool OutputStateMachineEngine::ActionOscDispatch(const wchar_t /*wch*/,
                 {
                     success = success && _dispatch->SetDefaultForeground(color);
                 }
-                TermTelemetry::Instance().Log(TermTelemetry::Codes::OSCFG);
                 commandIndex++;
                 colorIndex++;
             }
@@ -898,7 +799,6 @@ bool OutputStateMachineEngine::ActionOscDispatch(const wchar_t /*wch*/,
                 {
                     success = success && _dispatch->SetDefaultBackground(color);
                 }
-                TermTelemetry::Instance().Log(TermTelemetry::Codes::OSCBG);
                 commandIndex++;
                 colorIndex++;
             }
@@ -910,7 +810,6 @@ bool OutputStateMachineEngine::ActionOscDispatch(const wchar_t /*wch*/,
                 {
                     success = success && _dispatch->SetCursorColor(color);
                 }
-                TermTelemetry::Instance().Log(TermTelemetry::Codes::OSCSCC);
                 commandIndex++;
                 colorIndex++;
             }
@@ -926,13 +825,11 @@ bool OutputStateMachineEngine::ActionOscDispatch(const wchar_t /*wch*/,
         {
             success = _dispatch->SetClipboard(setClipboardContent);
         }
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::OSCSCB);
         break;
     }
     case OscActionCodes::ResetCursorColor:
     {
         success = _dispatch->SetCursorColor(INVALID_COLOR);
-        TermTelemetry::Instance().Log(TermTelemetry::Codes::OSCRCC);
         break;
     }
     case OscActionCodes::Hyperlink:
diff --git a/src/terminal/parser/OutputStateMachineEngine.hpp b/src/terminal/parser/OutputStateMachineEngine.hpp
index 0613ea3bc64..edb8982f7da 100644
--- a/src/terminal/parser/OutputStateMachineEngine.hpp
+++ b/src/terminal/parser/OutputStateMachineEngine.hpp
@@ -13,7 +13,6 @@ Module Name:
 #include <functional>
 
 #include "../adapter/termDispatch.hpp"
-#include "telemetry.hpp"
 #include "IStateMachineEngine.hpp"
 
 namespace Microsoft::Console::Render
diff --git a/src/terminal/parser/lib/parser.vcxproj.filters b/src/terminal/parser/lib/parser.vcxproj.filters
index 409f4e4071f..f62588b65d0 100644
--- a/src/terminal/parser/lib/parser.vcxproj.filters
+++ b/src/terminal/parser/lib/parser.vcxproj.filters
@@ -18,9 +18,6 @@
     <ClCompile Include="..\stateMachine.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="..\telemetry.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="..\tracing.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
@@ -38,9 +35,6 @@
     <ClInclude Include="..\stateMachine.hpp">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="..\telemetry.hpp">
-      <Filter>Header Files</Filter>
-    </ClInclude>
     <ClInclude Include="..\termDispatch.hpp">
       <Filter>Header Files</Filter>
     </ClInclude>
diff --git a/src/terminal/parser/parser-common.vcxitems b/src/terminal/parser/parser-common.vcxitems
index f60ddec6eee..a929e694468 100644
--- a/src/terminal/parser/parser-common.vcxitems
+++ b/src/terminal/parser/parser-common.vcxitems
@@ -6,7 +6,6 @@
   <ItemGroup>
     <ClCompile Include="..\OutputStateMachineEngine.cpp" />
     <ClCompile Include="..\stateMachine.cpp" />
-    <ClCompile Include="..\telemetry.cpp" />
     <ClCompile Include="..\tracing.cpp" />
     <ClCompile Include="..\precomp.cpp">
       <PrecompiledHeader>Create</PrecompiledHeader>
@@ -19,7 +18,6 @@
     <ClInclude Include="..\stateMachine.hpp" />
     <ClInclude Include="..\IStateMachineEngine.hpp" />
     <ClInclude Include="..\OutputStateMachineEngine.hpp" />
-    <ClInclude Include="..\telemetry.hpp" />
     <ClInclude Include="..\tracing.hpp" />
     <ClInclude Include="..\base64.hpp" />
   </ItemGroup>
diff --git a/src/terminal/parser/precomp.h b/src/terminal/parser/precomp.h
index 38a4422bc24..03611a47941 100644
--- a/src/terminal/parser/precomp.h
+++ b/src/terminal/parser/precomp.h
@@ -22,5 +22,4 @@ Module Name:
 #define ENABLE_INTSAFE_SIGNED_FUNCTIONS
 #include <intsafe.h>
 
-#include "telemetry.hpp"
 #include "tracing.hpp"
diff --git a/src/terminal/parser/sources.inc b/src/terminal/parser/sources.inc
index 5e05cc566f7..e39b8a2aa3c 100644
--- a/src/terminal/parser/sources.inc
+++ b/src/terminal/parser/sources.inc
@@ -33,7 +33,6 @@ SOURCES = \
     ..\stateMachine.cpp \
     ..\InputStateMachineEngine.cpp \
     ..\OutputStateMachineEngine.cpp \
-    ..\telemetry.cpp \
     ..\tracing.cpp \
     ..\base64.cpp \
 
diff --git a/src/terminal/parser/stateMachine.cpp b/src/terminal/parser/stateMachine.cpp
index d6a9aa31489..6fe5d5bd979 100644
--- a/src/terminal/parser/stateMachine.cpp
+++ b/src/terminal/parser/stateMachine.cpp
@@ -447,7 +447,7 @@ void StateMachine::_ActionPrintString(const std::wstring_view string)
 void StateMachine::_ActionEscDispatch(const wchar_t wch)
 {
     _trace.TraceOnAction(L"EscDispatch");
-    _trace.DispatchSequenceTrace(_SafeExecuteWithLog(wch, [=]() {
+    _trace.DispatchSequenceTrace(_SafeExecute([=]() {
         return _engine->ActionEscDispatch(_identifier.Finalize(wch));
     }));
 }
@@ -462,7 +462,7 @@ void StateMachine::_ActionEscDispatch(const wchar_t wch)
 void StateMachine::_ActionVt52EscDispatch(const wchar_t wch)
 {
     _trace.TraceOnAction(L"Vt52EscDispatch");
-    _trace.DispatchSequenceTrace(_SafeExecuteWithLog(wch, [=]() {
+    _trace.DispatchSequenceTrace(_SafeExecute([=]() {
         return _engine->ActionVt52EscDispatch(_identifier.Finalize(wch), { _parameters.data(), _parameters.size() });
     }));
 }
@@ -477,7 +477,7 @@ void StateMachine::_ActionVt52EscDispatch(const wchar_t wch)
 void StateMachine::_ActionCsiDispatch(const wchar_t wch)
 {
     _trace.TraceOnAction(L"CsiDispatch");
-    _trace.DispatchSequenceTrace(_SafeExecuteWithLog(wch, [=]() {
+    _trace.DispatchSequenceTrace(_SafeExecute([=]() {
         return _engine->ActionCsiDispatch(_identifier.Finalize(wch), { _parameters.data(), _parameters.size() });
     }));
 }
@@ -635,7 +635,7 @@ void StateMachine::_ActionOscPut(const wchar_t wch)
 void StateMachine::_ActionOscDispatch(const wchar_t wch)
 {
     _trace.TraceOnAction(L"OscDispatch");
-    _trace.DispatchSequenceTrace(_SafeExecuteWithLog(wch, [=]() {
+    _trace.DispatchSequenceTrace(_SafeExecute([=]() {
         return _engine->ActionOscDispatch(wch, _oscParameter, _oscString);
     }));
 }
@@ -650,7 +650,7 @@ void StateMachine::_ActionOscDispatch(const wchar_t wch)
 void StateMachine::_ActionSs3Dispatch(const wchar_t wch)
 {
     _trace.TraceOnAction(L"Ss3Dispatch");
-    _trace.DispatchSequenceTrace(_SafeExecuteWithLog(wch, [=]() {
+    _trace.DispatchSequenceTrace(_SafeExecute([=]() {
         return _engine->ActionSs3Dispatch(wch, { _parameters.data(), _parameters.size() });
     }));
 }
@@ -666,7 +666,7 @@ void StateMachine::_ActionDcsDispatch(const wchar_t wch)
 {
     _trace.TraceOnAction(L"DcsDispatch");
 
-    const auto success = _SafeExecuteWithLog(wch, [=]() {
+    const auto success = _SafeExecute([=]() {
         _dcsStringHandler = _engine->ActionDcsDispatch(_identifier.Finalize(wch), { _parameters.data(), _parameters.size() });
         // If the returned handler is null, the sequence is not supported.
         return _dcsStringHandler != nullptr;
@@ -2063,17 +2063,6 @@ catch (...)
     return false;
 }
 
-template<typename TLambda>
-bool StateMachine::_SafeExecuteWithLog(const wchar_t wch, TLambda&& lambda)
-{
-    const bool success = _SafeExecute(std::forward<TLambda>(lambda));
-    if (!success)
-    {
-        TermTelemetry::Instance().LogFailed(wch);
-    }
-    return success;
-}
-
 void StateMachine::_ExecuteCsiCompleteCallback()
 {
     if (_onCsiCompleteCallback)
diff --git a/src/terminal/parser/stateMachine.hpp b/src/terminal/parser/stateMachine.hpp
index a51351e456f..e6a78d23d9f 100644
--- a/src/terminal/parser/stateMachine.hpp
+++ b/src/terminal/parser/stateMachine.hpp
@@ -15,7 +15,6 @@ Module Name:
 #pragma once
 
 #include "IStateMachineEngine.hpp"
-#include "telemetry.hpp"
 #include "tracing.hpp"
 #include <memory>
 
@@ -141,8 +140,6 @@ namespace Microsoft::Console::VirtualTerminal
 
         template<typename TLambda>
         bool _SafeExecute(TLambda&& lambda);
-        template<typename TLambda>
-        bool _SafeExecuteWithLog(const wchar_t wch, TLambda&& lambda);
 
         void _ExecuteCsiCompleteCallback();
 
diff --git a/src/terminal/parser/telemetry.cpp b/src/terminal/parser/telemetry.cpp
deleted file mode 100644
index 98d752a3a45..00000000000
--- a/src/terminal/parser/telemetry.cpp
+++ /dev/null
@@ -1,311 +0,0 @@
-// Copyright (c) Microsoft Corporation.
-// Licensed under the MIT license.
-
-#include "precomp.h"
-
-#include "telemetry.hpp"
-
-#pragma warning(push)
-#pragma warning(disable : 26494) // _Tlgdata uninitialized from TraceLoggingWrite
-#pragma warning(disable : 26477) // Use nullptr instead of NULL or 0 from TraceLoggingWrite
-#pragma warning(disable : 26485) // _Tlgdata, no array to pointer decay from TraceLoggingWrite
-#pragma warning(disable : 26446) // Prefer gsl::at over unchecked subscript from TraceLoggingLevel
-#pragma warning(disable : 26482) // Only index to arrays with constant expressions from TraceLoggingLevel
-
-TRACELOGGING_DEFINE_PROVIDER(g_hConsoleVirtTermParserEventTraceProvider,
-                             "Microsoft.Windows.Console.VirtualTerminal.Parser",
-                             // {c9ba2a84-d3ca-5e19-2bd6-776a0910cb9d}
-                             (0xc9ba2a84, 0xd3ca, 0x5e19, 0x2b, 0xd6, 0x77, 0x6a, 0x09, 0x10, 0xcb, 0x9d));
-
-using namespace Microsoft::Console::VirtualTerminal;
-
-#pragma warning(push)
-// Disable 4351 so we can initialize the arrays to 0 without a warning.
-#pragma warning(disable : 4351)
-TermTelemetry::TermTelemetry() noexcept :
-    _uiTimesUsedCurrent(0),
-    _uiTimesFailedCurrent(0),
-    _uiTimesFailedOutsideRangeCurrent(0),
-    _uiTimesUsed(),
-    _uiTimesFailed(),
-    _uiTimesFailedOutsideRange(0),
-    _activityId(),
-    _fShouldWriteFinalLog(false)
-{
-    TraceLoggingRegister(g_hConsoleVirtTermParserEventTraceProvider);
-
-    // Create a random activityId just in case it doesn't get set later in SetActivityId().
-    EventActivityIdControl(EVENT_ACTIVITY_CTRL_CREATE_ID, &_activityId);
-}
-#pragma warning(pop)
-
-TermTelemetry::~TermTelemetry()
-{
-    try
-    {
-        WriteFinalTraceLog();
-        TraceLoggingUnregister(g_hConsoleVirtTermParserEventTraceProvider);
-    }
-    CATCH_LOG()
-}
-
-// Routine Description:
-// - Logs the usage of a particular VT100 code.
-//
-// Arguments:
-// - code - VT100 code.
-// Return Value:
-// - <none>
-void TermTelemetry::Log(const Codes code) noexcept
-{
-    // Initially we wanted to pass over a string (ex. "CUU") and use a dictionary data type to hold the counts.
-    // However we would have to search through the dictionary every time we called this method, so we decided
-    // to use an array which has very quick access times.
-    // The downside is we have to create an enum type, and then convert them to strings when we finally
-    // send out the telemetry, but the upside is we should have very good performance.
-    _uiTimesUsed[code]++;
-    _uiTimesUsedCurrent++;
-}
-
-// Routine Description:
-// - Logs a particular VT100 escape code failed or was unsupported.
-//
-// Arguments:
-// - code - VT100 code.
-// Return Value:
-// - <none>
-void TermTelemetry::LogFailed(const wchar_t wch) noexcept
-{
-    if (wch > CHAR_MAX)
-    {
-        _uiTimesFailedOutsideRange++;
-        _uiTimesFailedOutsideRangeCurrent++;
-    }
-    else
-    {
-        // Even though we pass over a wide character, we only care about the ASCII single byte character.
-        _uiTimesFailed[wch]++;
-        _uiTimesFailedCurrent++;
-    }
-}
-
-// Routine Description:
-// - Gets and resets the total count of codes used.
-//
-// Arguments:
-// - <none>
-// Return Value:
-// - total number.
-unsigned int TermTelemetry::GetAndResetTimesUsedCurrent() noexcept
-{
-    const auto temp = _uiTimesUsedCurrent;
-    _uiTimesUsedCurrent = 0;
-    return temp;
-}
-
-// Routine Description:
-// - Gets and resets the total count of codes failed.
-//
-// Arguments:
-// - <none>
-// Return Value:
-// - total number.
-unsigned int TermTelemetry::GetAndResetTimesFailedCurrent() noexcept
-{
-    const auto temp = _uiTimesFailedCurrent;
-    _uiTimesFailedCurrent = 0;
-    return temp;
-}
-
-// Routine Description:
-// - Gets and resets the total count of codes failed outside the valid range.
-//
-// Arguments:
-// - <none>
-// Return Value:
-// - total number.
-unsigned int TermTelemetry::GetAndResetTimesFailedOutsideRangeCurrent() noexcept
-{
-    const auto temp = _uiTimesFailedOutsideRangeCurrent;
-    _uiTimesFailedOutsideRangeCurrent = 0;
-    return temp;
-}
-
-// Routine Description:
-// - Lets us know whether we should write the final log.  Typically set true when the console has been
-// interacted with, to help reduce the amount of telemetry we're sending.
-//
-// Arguments:
-// - writeLog - true if we should write the log.
-// Return Value:
-// - <none>
-void TermTelemetry::SetShouldWriteFinalLog(const bool writeLog) noexcept
-{
-    _fShouldWriteFinalLog = writeLog;
-}
-
-// Routine Description:
-// - Sets the activity Id, so we can match our events with other providers (such as Microsoft.Windows.Console.Host).
-//
-// Arguments:
-// - activityId - Pointer to Guid to set our activity Id to.
-// Return Value:
-// - <none>
-void TermTelemetry::SetActivityId(const GUID* activityId) noexcept
-{
-    _activityId = *activityId;
-}
-
-// Routine Description:
-// - Writes the final log of all the telemetry collected.  The primary reason to send back a final log instead
-// of individual events is to reduce the amount of telemetry being sent and potentially overloading our servers.
-//
-// Arguments:
-// - code - VT100 code.
-// Return Value:
-// - <none>
-void TermTelemetry::WriteFinalTraceLog() const
-{
-    if (_fShouldWriteFinalLog)
-    {
-        // Determine if we've logged any VT100 sequences at all.
-        auto fLoggedSequence = (_uiTimesFailedOutsideRange > 0);
-
-        if (!fLoggedSequence)
-        {
-            for (auto n = 0; n < ARRAYSIZE(_uiTimesUsed); n++)
-            {
-                if (_uiTimesUsed[n] > 0)
-                {
-                    fLoggedSequence = true;
-                    break;
-                }
-            }
-        }
-
-        if (!fLoggedSequence)
-        {
-            for (auto n = 0; n < ARRAYSIZE(_uiTimesFailed); n++)
-            {
-                if (_uiTimesFailed[n] > 0)
-                {
-                    fLoggedSequence = true;
-                    break;
-                }
-            }
-        }
-
-        // Only send telemetry if we've logged some VT100 sequences.  This should help reduce the amount of unnecessary
-        // telemetry being sent.
-        if (fLoggedSequence)
-        {
-            // I could use the TraceLoggingUIntArray, but then we would have to know the order of the enums on the backend.
-            // So just log each enum count separately with its string representation which makes it more human readable.
-            // Set the related activity to NULL since we aren't using it.
-            TraceLoggingWriteActivity(g_hConsoleVirtTermParserEventTraceProvider,
-                                      "ControlCodesUsed",
-                                      &_activityId,
-                                      NULL,
-                                      TraceLoggingUInt32(_uiTimesUsed[CUU], "CUU"),
-                                      TraceLoggingUInt32(_uiTimesUsed[CUD], "CUD"),
-                                      TraceLoggingUInt32(_uiTimesUsed[CUF], "CUF"),
-                                      TraceLoggingUInt32(_uiTimesUsed[CUB], "CUB"),
-                                      TraceLoggingUInt32(_uiTimesUsed[CNL], "CNL"),
-                                      TraceLoggingUInt32(_uiTimesUsed[CPL], "CPL"),
-                                      TraceLoggingUInt32(_uiTimesUsed[CHA], "CHA"),
-                                      TraceLoggingUInt32(_uiTimesUsed[CUP], "CUP"),
-                                      TraceLoggingUInt32(_uiTimesUsed[ED], "ED"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DECSED], "DECSED"),
-                                      TraceLoggingUInt32(_uiTimesUsed[EL], "EL"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DECSEL], "DECSEL"),
-                                      TraceLoggingUInt32(_uiTimesUsed[SGR], "SGR"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DECBI], "DECBI"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DECSC], "DECSC"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DECRC], "DECRC"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DECFI], "DECFI"),
-                                      TraceLoggingUInt32(_uiTimesUsed[SM], "SM"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DECSET], "DECSET"),
-                                      TraceLoggingUInt32(_uiTimesUsed[RM], "RM"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DECRST], "DECRST"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DECKPAM], "DECKPAM"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DECKPNM], "DECKPNM"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DSR], "DSR"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DA], "DA"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DA2], "DA2"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DA3], "DA3"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DECREQTPARM], "DECREQTPARM"),
-                                      TraceLoggingUInt32(_uiTimesUsed[VPA], "VPA"),
-                                      TraceLoggingUInt32(_uiTimesUsed[HPR], "HPR"),
-                                      TraceLoggingUInt32(_uiTimesUsed[VPR], "VPR"),
-                                      TraceLoggingUInt32(_uiTimesUsed[ICH], "ICH"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DCH], "DCH"),
-                                      TraceLoggingUInt32(_uiTimesUsed[IL], "IL"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DL], "DL"),
-                                      TraceLoggingUInt32(_uiTimesUsed[SU], "SU"),
-                                      TraceLoggingUInt32(_uiTimesUsed[SD], "SD"),
-                                      TraceLoggingUInt32(_uiTimesUsed[ANSISYSRC], "ANSISYSRC"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DECSTBM], "DECSTBM"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DECSLRM], "DECSLRM"),
-                                      TraceLoggingUInt32(_uiTimesUsed[NEL], "NEL"),
-                                      TraceLoggingUInt32(_uiTimesUsed[IND], "IND"),
-                                      TraceLoggingUInt32(_uiTimesUsed[RI], "RI"),
-                                      TraceLoggingUInt32(_uiTimesUsed[OSCWT], "OscWindowTitle"),
-                                      TraceLoggingUInt32(_uiTimesUsed[HTS], "HTS"),
-                                      TraceLoggingUInt32(_uiTimesUsed[CHT], "CHT"),
-                                      TraceLoggingUInt32(_uiTimesUsed[CBT], "CBT"),
-                                      TraceLoggingUInt32(_uiTimesUsed[TBC], "TBC"),
-                                      TraceLoggingUInt32(_uiTimesUsed[ECH], "ECH"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DesignateG0], "DesignateG0"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DesignateG1], "DesignateG1"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DesignateG2], "DesignateG2"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DesignateG3], "DesignateG3"),
-                                      TraceLoggingUInt32(_uiTimesUsed[LS2], "LS2"),
-                                      TraceLoggingUInt32(_uiTimesUsed[LS3], "LS3"),
-                                      TraceLoggingUInt32(_uiTimesUsed[LS1R], "LS1R"),
-                                      TraceLoggingUInt32(_uiTimesUsed[LS2R], "LS2R"),
-                                      TraceLoggingUInt32(_uiTimesUsed[LS3R], "LS3R"),
-                                      TraceLoggingUInt32(_uiTimesUsed[SS2], "SS2"),
-                                      TraceLoggingUInt32(_uiTimesUsed[SS3], "SS3"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DOCS], "DOCS"),
-                                      TraceLoggingUInt32(_uiTimesUsed[HVP], "HVP"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DECSTR], "DECSTR"),
-                                      TraceLoggingUInt32(_uiTimesUsed[RIS], "RIS"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DECSCUSR], "DECSCUSR"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DECSCA], "DECSCA"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DTTERM_WM], "DTTERM_WM"),
-                                      TraceLoggingUInt32(_uiTimesUsed[OSCCT], "OscColorTable"),
-                                      TraceLoggingUInt32(_uiTimesUsed[OSCSCC], "OscSetCursorColor"),
-                                      TraceLoggingUInt32(_uiTimesUsed[OSCRCC], "OscResetCursorColor"),
-                                      TraceLoggingUInt32(_uiTimesUsed[OSCFG], "OscForegroundColor"),
-                                      TraceLoggingUInt32(_uiTimesUsed[OSCBG], "OscBackgroundColor"),
-                                      TraceLoggingUInt32(_uiTimesUsed[OSCSCB], "OscSetClipboard"),
-                                      TraceLoggingUInt32(_uiTimesUsed[REP], "REP"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DECAC1], "DECAC1"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DECSWL], "DECSWL"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DECDWL], "DECDWL"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DECDHL], "DECDHL"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DECALN], "DECALN"),
-                                      TraceLoggingUInt32(_uiTimesUsed[XTPUSHSGR], "XTPUSHSGR"),
-                                      TraceLoggingUInt32(_uiTimesUsed[XTPOPSGR], "XTPOPSGR"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DECRQM], "DECRQM"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DECCARA], "DECCARA"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DECRARA], "DECRARA"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DECCRA], "DECCRA"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DECRQPSR], "DECRQPSR"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DECFRA], "DECFRA"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DECERA], "DECERA"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DECSERA], "DECSERA"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DECIC], "DECIC"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DECDC], "DECDC"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DECSACE], "DECSACE"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DECRQCRA], "DECRQCRA"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DECINVM], "DECINVM"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DECAC], "DECAC"),
-                                      TraceLoggingUInt32(_uiTimesUsed[DECPS], "DECPS"),
-                                      TraceLoggingUInt32Array(_uiTimesFailed, ARRAYSIZE(_uiTimesFailed), "Failed"),
-                                      TraceLoggingUInt32(_uiTimesFailedOutsideRange, "FailedOutsideRange"));
-        }
-    }
-}
-
-#pragma warning(pop)
diff --git a/src/terminal/parser/telemetry.hpp b/src/terminal/parser/telemetry.hpp
deleted file mode 100644
index dd71c61a104..00000000000
--- a/src/terminal/parser/telemetry.hpp
+++ /dev/null
@@ -1,164 +0,0 @@
-// Copyright (c) Microsoft Corporation.
-// Licensed under the MIT license.
-
-/*
-Module Name:
-- telemetry.hpp
-
-Abstract:
-- This module is used for recording all telemetry feedback from the console virtual terminal parser
-*/
-#pragma once
-
-// Including TraceLogging essentials for the binary
-#include <windows.h>
-#include <winmeta.h>
-#include <TraceLoggingProvider.h>
-#include "climits"
-
-TRACELOGGING_DECLARE_PROVIDER(g_hConsoleVirtTermParserEventTraceProvider);
-
-namespace Microsoft::Console::VirtualTerminal
-{
-    class TermTelemetry sealed
-    {
-    public:
-        // Implement this as a singleton class.
-        static TermTelemetry& Instance() noexcept
-        {
-            static TermTelemetry s_Instance;
-            return s_Instance;
-        }
-
-        // Names primarily from http://inwap.com/pdp10/ansicode.txt
-        enum Codes
-        {
-            CUU = 0,
-            CUD,
-            CUF,
-            CUB,
-            CNL,
-            CPL,
-            CHA,
-            CUP,
-            ED,
-            DECSED,
-            EL,
-            DECSEL,
-            SGR,
-            DECBI,
-            DECSC,
-            DECRC,
-            DECFI,
-            SM,
-            DECSET,
-            RM,
-            DECRST,
-            DECKPAM,
-            DECKPNM,
-            DSR,
-            DA,
-            DA2,
-            DA3,
-            DECREQTPARM,
-            VPA,
-            HPR,
-            VPR,
-            ICH,
-            DCH,
-            SU,
-            SD,
-            ANSISYSRC,
-            IL,
-            DL,
-            DECSTBM,
-            DECSLRM,
-            NEL,
-            IND,
-            RI,
-            OSCWT,
-            HTS,
-            CHT,
-            CBT,
-            TBC,
-            ECH,
-            DesignateG0,
-            DesignateG1,
-            DesignateG2,
-            DesignateG3,
-            LS2,
-            LS3,
-            LS1R,
-            LS2R,
-            LS3R,
-            SS2,
-            SS3,
-            DOCS,
-            HVP,
-            DECSTR,
-            RIS,
-            DECSCUSR,
-            DECSCA,
-            DTTERM_WM,
-            OSCCT,
-            OSCSCC,
-            OSCRCC,
-            REP,
-            OSCFG,
-            OSCBG,
-            DECAC1,
-            DECSWL,
-            DECDWL,
-            DECDHL,
-            DECALN,
-            OSCSCB,
-            XTPUSHSGR,
-            XTPOPSGR,
-            DECRQM,
-            DECCARA,
-            DECRARA,
-            DECCRA,
-            DECRQPSR,
-            DECFRA,
-            DECERA,
-            DECSERA,
-            DECIC,
-            DECDC,
-            DECSACE,
-            DECRQCRA,
-            DECINVM,
-            DECAC,
-            DECPS,
-            // Only use this last enum as a count of the number of codes.
-            NUMBER_OF_CODES
-        };
-        void Log(const Codes code) noexcept;
-        void LogFailed(const wchar_t wch) noexcept;
-        void SetShouldWriteFinalLog(const bool writeLog) noexcept;
-        void SetActivityId(const GUID* activityId) noexcept;
-        unsigned int GetAndResetTimesUsedCurrent() noexcept;
-        unsigned int GetAndResetTimesFailedCurrent() noexcept;
-        unsigned int GetAndResetTimesFailedOutsideRangeCurrent() noexcept;
-
-    private:
-        // Used to prevent multiple instances
-        TermTelemetry() noexcept;
-        ~TermTelemetry();
-        TermTelemetry(const TermTelemetry&) = delete;
-        TermTelemetry(TermTelemetry&&) = delete;
-        TermTelemetry& operator=(const TermTelemetry&) = delete;
-        TermTelemetry& operator=(TermTelemetry&&) = delete;
-
-        void WriteFinalTraceLog() const;
-
-        unsigned int _uiTimesUsedCurrent;
-        unsigned int _uiTimesFailedCurrent;
-        unsigned int _uiTimesFailedOutsideRangeCurrent;
-        unsigned int _uiTimesUsed[NUMBER_OF_CODES];
-        unsigned int _uiTimesFailed[CHAR_MAX + 1];
-        unsigned int _uiTimesFailedOutsideRange;
-        GUID _activityId;
-
-        bool _fShouldWriteFinalLog;
-    };
-}
diff --git a/src/terminal/parser/tracing.cpp b/src/terminal/parser/tracing.cpp
index 5ddc5f453e3..9ab684ac95d 100644
--- a/src/terminal/parser/tracing.cpp
+++ b/src/terminal/parser/tracing.cpp
@@ -10,6 +10,11 @@ using namespace Microsoft::Console::VirtualTerminal;
 #pragma warning(disable : 26447) // The function is declared 'noexcept' but calls function '_tlgWrapBinary<wchar_t>()' which may throw exceptions
 #pragma warning(disable : 26477) // Use 'nullptr' rather than 0 or NULL
 
+TRACELOGGING_DEFINE_PROVIDER(g_hConsoleVirtTermParserEventTraceProvider,
+                             "Microsoft.Windows.Console.VirtualTerminal.Parser",
+                             // {c9ba2a84-d3ca-5e19-2bd6-776a0910cb9d}
+                             (0xc9ba2a84, 0xd3ca, 0x5e19, 0x2b, 0xd6, 0x77, 0x6a, 0x09, 0x10, 0xcb, 0x9d));
+
 void ParserTracing::TraceStateChange(_In_z_ const wchar_t* name) const noexcept
 {
     TraceLoggingWrite(g_hConsoleVirtTermParserEventTraceProvider,
diff --git a/src/terminal/parser/tracing.hpp b/src/terminal/parser/tracing.hpp
index 27e3e3352d6..ecc357c3236 100644
--- a/src/terminal/parser/tracing.hpp
+++ b/src/terminal/parser/tracing.hpp
@@ -14,7 +14,11 @@ Module Name:
 
 #pragma once
 
-#include "telemetry.hpp"
+// Including TraceLogging essentials for the binary
+#include <winmeta.h>
+#include <TraceLoggingProvider.h>
+
+TRACELOGGING_DECLARE_PROVIDER(g_hConsoleVirtTermParserEventTraceProvider);
 
 namespace Microsoft::Console::VirtualTerminal
 {


Test patch: