Skip to content

Commit

Permalink
[Task-43152318] - Added Telemetry Logging to MSIXMGR Tool for Capturi…
Browse files Browse the repository at this point in the history
…ng Useful Metrics (#573)

* Added related files for Telemetry Logging

* Added changes for Telemetry to the msixmgr.cpp file

* Added code changes for ErrorCode and ErrorDesc

* Added changes related to Additional Parameter in Commands

* Added Code Comments for CorrelationId and SourceApplicationId

* Added changes to Code comments

* Changed the Operation name to comply with the actual commands, also removed the check for Operation Type for SourceApplicationId and CorrelationID

* Changed the casing for Local variables and parameters. Added OutputImageType to be captured in Telemetry

* Changed the casing of Local Variables, extracting OperationType from Command Line

* Changed the msixmgrTraceLogging from .h file to a .hpp and added a .cpp file for that. Also, removed unnecessary #defines from msixmgrTelemetry.hpp file

* Changed the ErrorDesc to comply with the existing Error Messages being displayed on the Console

* Removed the Telemetry Logging when VHDSize is 0 as it is not needed anymore

* Changed a telemetry logging statement for unpacking int VHD(X)/Folder

* Removed TraceLoggingOptionGroupValue with dummy value

* [Task - 43152318] - Added Comments and Description in the Code for newly added files
  • Loading branch information
pratiksinha07 authored Apr 11, 2023
1 parent 2a124e3 commit 7adc5ae
Show file tree
Hide file tree
Showing 9 changed files with 935 additions and 27 deletions.
168 changes: 163 additions & 5 deletions MsixCore/msixmgr/CommandLineInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,26 @@ std::map<std::wstring, Options, CaseInsensitiveLess> CommandLineInterface::s_opt
commandLineInterface->m_operationType = OperationType::Add;
commandLineInterface->m_packageFilePath = utf8_to_utf16(path);
return S_OK;
},
{
{
L"-sourceApplicationId",
Option(true, IDS_STRING_HELP_OPTION_UNPACK_DESTINATION,
[&](CommandLineInterface* commandLineInterface, const std::string& sourceApplicationId)
{
commandLineInterface->m_sourceApplicationId = utf8_to_utf16(sourceApplicationId);
return S_OK;
}),
},
{
L"-correlationId",
Option(true, IDS_STRING_HELP_OPTION_UNPACK_DESTINATION,
[&](CommandLineInterface* commandLineInterface, const std::string& correlationId)
{
commandLineInterface->m_correlationId = utf8_to_utf16(correlationId);
return S_OK;
}),
}
})
},
{
Expand All @@ -37,6 +57,26 @@ std::map<std::wstring, Options, CaseInsensitiveLess> CommandLineInterface::s_opt
commandLineInterface->m_operationType = OperationType::Remove;
commandLineInterface->m_packageFullName = utf8_to_utf16(packageFullName);
return S_OK;
},
{
{
L"-sourceApplicationId",
Option(true, IDS_STRING_HELP_OPTION_UNPACK_DESTINATION,
[&](CommandLineInterface* commandLineInterface, const std::string& sourceApplicationId)
{
commandLineInterface->m_sourceApplicationId = utf8_to_utf16(sourceApplicationId);
return S_OK;
}),
},
{
L"-correlationId",
Option(true, IDS_STRING_HELP_OPTION_UNPACK_DESTINATION,
[&](CommandLineInterface* commandLineInterface, const std::string& correlationId)
{
commandLineInterface->m_correlationId = utf8_to_utf16(correlationId);
return S_OK;
}),
}
})
},
{
Expand All @@ -60,6 +100,26 @@ std::map<std::wstring, Options, CaseInsensitiveLess> CommandLineInterface::s_opt
commandLineInterface->m_operationType = OperationType::FindPackage;
commandLineInterface->m_packageFullName = utf8_to_utf16(packageFullName);
return S_OK;
},
{
{
L"-sourceApplicationId",
Option(true, IDS_STRING_HELP_OPTION_UNPACK_DESTINATION,
[&](CommandLineInterface* commandLineInterface, const std::string& sourceApplicationId)
{
commandLineInterface->m_sourceApplicationId = utf8_to_utf16(sourceApplicationId);
return S_OK;
}),
},
{
L"-correlationId",
Option(true, IDS_STRING_HELP_OPTION_UNPACK_DESTINATION,
[&](CommandLineInterface* commandLineInterface, const std::string& correlationId)
{
commandLineInterface->m_correlationId = utf8_to_utf16(correlationId);
return S_OK;
}),
}
})
},
{
Expand Down Expand Up @@ -192,7 +252,25 @@ std::map<std::wstring, Options, CaseInsensitiveLess> CommandLineInterface::s_opt
commandLineInterface->m_vhdSize = vhdSizeUll;
return S_OK;
}),
}
},
{
L"-sourceApplicationId",
Option(true, IDS_STRING_HELP_OPTION_UNPACK_DESTINATION,
[&](CommandLineInterface* commandLineInterface, const std::string& sourceApplicationId)
{
commandLineInterface->m_sourceApplicationId = utf8_to_utf16(sourceApplicationId);
return S_OK;
}),
},
{
L"-correlationId",
Option(true, IDS_STRING_HELP_OPTION_UNPACK_DESTINATION,
[&](CommandLineInterface* commandLineInterface, const std::string& correlationId)
{
commandLineInterface->m_correlationId = utf8_to_utf16(correlationId);
return S_OK;
}),
}
})
},
{
Expand Down Expand Up @@ -220,7 +298,25 @@ std::map<std::wstring, Options, CaseInsensitiveLess> CommandLineInterface::s_opt
commandLineInterface->m_packageFilePath = utf8_to_utf16(packagePath);
return S_OK;
}),
}
},
{
L"-sourceApplicationId",
Option(true, IDS_STRING_HELP_OPTION_UNPACK_DESTINATION,
[&](CommandLineInterface* commandLineInterface, const std::string& sourceApplicationId)
{
commandLineInterface->m_sourceApplicationId = utf8_to_utf16(sourceApplicationId);
return S_OK;
}),
},
{
L"-correlationId",
Option(true, IDS_STRING_HELP_OPTION_UNPACK_DESTINATION,
[&](CommandLineInterface* commandLineInterface, const std::string& correlationId)
{
commandLineInterface->m_correlationId = utf8_to_utf16(correlationId);
return S_OK;
}),
}
})
},
{
Expand Down Expand Up @@ -285,7 +381,25 @@ std::map<std::wstring, Options, CaseInsensitiveLess> CommandLineInterface::s_opt
}
return S_OK;
}),
}
},
{
L"-sourceApplicationId",
Option(true, IDS_STRING_HELP_OPTION_UNPACK_DESTINATION,
[&](CommandLineInterface* commandLineInterface, const std::string& sourceApplicationId)
{
commandLineInterface->m_sourceApplicationId = utf8_to_utf16(sourceApplicationId);
return S_OK;
}),
},
{
L"-correlationId",
Option(true, IDS_STRING_HELP_OPTION_UNPACK_DESTINATION,
[&](CommandLineInterface* commandLineInterface, const std::string& correlationId)
{
commandLineInterface->m_correlationId = utf8_to_utf16(correlationId);
return S_OK;
}),
}
})
},
{
Expand Down Expand Up @@ -339,7 +453,25 @@ std::map<std::wstring, Options, CaseInsensitiveLess> CommandLineInterface::s_opt
commandLineInterface->SetWVDFileType(utf8_to_utf16(fileType));
return S_OK;
}),
}
},
{
L"-sourceApplicationId",
Option(true, IDS_STRING_HELP_OPTION_UNPACK_DESTINATION,
[&](CommandLineInterface* commandLineInterface, const std::string& sourceApplicationId)
{
commandLineInterface->m_sourceApplicationId = utf8_to_utf16(sourceApplicationId);
return S_OK;
}),
},
{
L"-correlationId",
Option(true, IDS_STRING_HELP_OPTION_UNPACK_DESTINATION,
[&](CommandLineInterface* commandLineInterface, const std::string& correlationId)
{
commandLineInterface->m_correlationId = utf8_to_utf16(correlationId);
return S_OK;
}),
}
})
},
{
Expand Down Expand Up @@ -479,4 +611,30 @@ void CommandLineInterface::SetWVDFileType(std::wstring fileType)
{
this->m_fileType = WVDFileType::NotSpecified;
}
}
}

std::wstring CommandLineInterface::GetFileTypeAsString()
{
switch (this->m_fileType)
{
case WVDFileType::CIM: return L"CIM";
case WVDFileType::VHD: return L"VHD";
case WVDFileType::VHDX: return L"VHDX";
case WVDFileType::NotSpecified: return L"NotSpecified";
}
}

std::wstring CommandLineInterface::GetOperationTypeAsString()
{
switch (this->m_operationType)
{
case OperationType::Add: return L"AddPackage";
case OperationType::Remove: return L"RemovePackage";
case OperationType::FindPackage: return L"FindPackage";
case OperationType::Unpack: return L"Unpack";
case OperationType::ApplyACLs: return L"ApplyACLs";
case OperationType::MountImage: return L"MountImage";
case OperationType::UnmountImage: return L"UnmountImage";
case OperationType::Undefined: return L"Undefined";
}
}
6 changes: 6 additions & 0 deletions MsixCore/msixmgr/CommandLineInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,17 @@ class CommandLineInterface
bool IsCreate() { return m_create; }
bool isMountReadOnly() { return m_readOnly; }
std::wstring GetPackageFilePathToInstall() { return m_packageFilePath; }
std::wstring GetSourceApplicationId() { return m_sourceApplicationId; }
std::wstring GetCorrelationId() { return m_correlationId; }
std::wstring GetPackageFullName() { return m_packageFullName; }
std::wstring GetUnpackDestination() { return m_unpackDestination; }
std::wstring GetRootDirectory() { return m_rootDirectory; }
std::wstring GetMountImagePath() { return m_mountImagePath; }
std::wstring GetVolumeId() { return m_volumeId; }
WVDFileType GetFileType() { return m_fileType; }
std::wstring GetFileTypeAsString();
OperationType GetOperationType() { return m_operationType; }
std::wstring GetOperationTypeAsString();
ULONGLONG GetVHDSize() { return m_vhdSize; }
private:
int m_argc = 0;
Expand All @@ -117,6 +121,8 @@ class CommandLineInterface
std::wstring m_rootDirectory;
std::wstring m_mountImagePath;
std::wstring m_volumeId;
std::wstring m_sourceApplicationId = L"MSIX_MGR"; // m_sourceApplicationId (Optional parameter) indicates which application is executing the MSIXMGR commands. Useful during integration of MSIXMGR with other Tools.
std::wstring m_correlationId = L""; // m_correlationId (Optional parameter) can be used to establish a correlation between MSIXMGR's Workflow and the parent application's Workflow, when MSIXMGR is being used in integration with any other Tool.
bool m_quietMode;
bool m_applyACLs;
bool m_validateSignature;
Expand Down
Loading

0 comments on commit 7adc5ae

Please sign in to comment.