Skip to content

Commit 7adc5ae

Browse files
[Task-43152318] - Added Telemetry Logging to MSIXMGR Tool for Capturing 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
1 parent 2a124e3 commit 7adc5ae

File tree

9 files changed

+935
-27
lines changed

9 files changed

+935
-27
lines changed

MsixCore/msixmgr/CommandLineInterface.cpp

Lines changed: 163 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,26 @@ std::map<std::wstring, Options, CaseInsensitiveLess> CommandLineInterface::s_opt
2323
commandLineInterface->m_operationType = OperationType::Add;
2424
commandLineInterface->m_packageFilePath = utf8_to_utf16(path);
2525
return S_OK;
26+
},
27+
{
28+
{
29+
L"-sourceApplicationId",
30+
Option(true, IDS_STRING_HELP_OPTION_UNPACK_DESTINATION,
31+
[&](CommandLineInterface* commandLineInterface, const std::string& sourceApplicationId)
32+
{
33+
commandLineInterface->m_sourceApplicationId = utf8_to_utf16(sourceApplicationId);
34+
return S_OK;
35+
}),
36+
},
37+
{
38+
L"-correlationId",
39+
Option(true, IDS_STRING_HELP_OPTION_UNPACK_DESTINATION,
40+
[&](CommandLineInterface* commandLineInterface, const std::string& correlationId)
41+
{
42+
commandLineInterface->m_correlationId = utf8_to_utf16(correlationId);
43+
return S_OK;
44+
}),
45+
}
2646
})
2747
},
2848
{
@@ -37,6 +57,26 @@ std::map<std::wstring, Options, CaseInsensitiveLess> CommandLineInterface::s_opt
3757
commandLineInterface->m_operationType = OperationType::Remove;
3858
commandLineInterface->m_packageFullName = utf8_to_utf16(packageFullName);
3959
return S_OK;
60+
},
61+
{
62+
{
63+
L"-sourceApplicationId",
64+
Option(true, IDS_STRING_HELP_OPTION_UNPACK_DESTINATION,
65+
[&](CommandLineInterface* commandLineInterface, const std::string& sourceApplicationId)
66+
{
67+
commandLineInterface->m_sourceApplicationId = utf8_to_utf16(sourceApplicationId);
68+
return S_OK;
69+
}),
70+
},
71+
{
72+
L"-correlationId",
73+
Option(true, IDS_STRING_HELP_OPTION_UNPACK_DESTINATION,
74+
[&](CommandLineInterface* commandLineInterface, const std::string& correlationId)
75+
{
76+
commandLineInterface->m_correlationId = utf8_to_utf16(correlationId);
77+
return S_OK;
78+
}),
79+
}
4080
})
4181
},
4282
{
@@ -60,6 +100,26 @@ std::map<std::wstring, Options, CaseInsensitiveLess> CommandLineInterface::s_opt
60100
commandLineInterface->m_operationType = OperationType::FindPackage;
61101
commandLineInterface->m_packageFullName = utf8_to_utf16(packageFullName);
62102
return S_OK;
103+
},
104+
{
105+
{
106+
L"-sourceApplicationId",
107+
Option(true, IDS_STRING_HELP_OPTION_UNPACK_DESTINATION,
108+
[&](CommandLineInterface* commandLineInterface, const std::string& sourceApplicationId)
109+
{
110+
commandLineInterface->m_sourceApplicationId = utf8_to_utf16(sourceApplicationId);
111+
return S_OK;
112+
}),
113+
},
114+
{
115+
L"-correlationId",
116+
Option(true, IDS_STRING_HELP_OPTION_UNPACK_DESTINATION,
117+
[&](CommandLineInterface* commandLineInterface, const std::string& correlationId)
118+
{
119+
commandLineInterface->m_correlationId = utf8_to_utf16(correlationId);
120+
return S_OK;
121+
}),
122+
}
63123
})
64124
},
65125
{
@@ -192,7 +252,25 @@ std::map<std::wstring, Options, CaseInsensitiveLess> CommandLineInterface::s_opt
192252
commandLineInterface->m_vhdSize = vhdSizeUll;
193253
return S_OK;
194254
}),
195-
}
255+
},
256+
{
257+
L"-sourceApplicationId",
258+
Option(true, IDS_STRING_HELP_OPTION_UNPACK_DESTINATION,
259+
[&](CommandLineInterface* commandLineInterface, const std::string& sourceApplicationId)
260+
{
261+
commandLineInterface->m_sourceApplicationId = utf8_to_utf16(sourceApplicationId);
262+
return S_OK;
263+
}),
264+
},
265+
{
266+
L"-correlationId",
267+
Option(true, IDS_STRING_HELP_OPTION_UNPACK_DESTINATION,
268+
[&](CommandLineInterface* commandLineInterface, const std::string& correlationId)
269+
{
270+
commandLineInterface->m_correlationId = utf8_to_utf16(correlationId);
271+
return S_OK;
272+
}),
273+
}
196274
})
197275
},
198276
{
@@ -220,7 +298,25 @@ std::map<std::wstring, Options, CaseInsensitiveLess> CommandLineInterface::s_opt
220298
commandLineInterface->m_packageFilePath = utf8_to_utf16(packagePath);
221299
return S_OK;
222300
}),
223-
}
301+
},
302+
{
303+
L"-sourceApplicationId",
304+
Option(true, IDS_STRING_HELP_OPTION_UNPACK_DESTINATION,
305+
[&](CommandLineInterface* commandLineInterface, const std::string& sourceApplicationId)
306+
{
307+
commandLineInterface->m_sourceApplicationId = utf8_to_utf16(sourceApplicationId);
308+
return S_OK;
309+
}),
310+
},
311+
{
312+
L"-correlationId",
313+
Option(true, IDS_STRING_HELP_OPTION_UNPACK_DESTINATION,
314+
[&](CommandLineInterface* commandLineInterface, const std::string& correlationId)
315+
{
316+
commandLineInterface->m_correlationId = utf8_to_utf16(correlationId);
317+
return S_OK;
318+
}),
319+
}
224320
})
225321
},
226322
{
@@ -285,7 +381,25 @@ std::map<std::wstring, Options, CaseInsensitiveLess> CommandLineInterface::s_opt
285381
}
286382
return S_OK;
287383
}),
288-
}
384+
},
385+
{
386+
L"-sourceApplicationId",
387+
Option(true, IDS_STRING_HELP_OPTION_UNPACK_DESTINATION,
388+
[&](CommandLineInterface* commandLineInterface, const std::string& sourceApplicationId)
389+
{
390+
commandLineInterface->m_sourceApplicationId = utf8_to_utf16(sourceApplicationId);
391+
return S_OK;
392+
}),
393+
},
394+
{
395+
L"-correlationId",
396+
Option(true, IDS_STRING_HELP_OPTION_UNPACK_DESTINATION,
397+
[&](CommandLineInterface* commandLineInterface, const std::string& correlationId)
398+
{
399+
commandLineInterface->m_correlationId = utf8_to_utf16(correlationId);
400+
return S_OK;
401+
}),
402+
}
289403
})
290404
},
291405
{
@@ -339,7 +453,25 @@ std::map<std::wstring, Options, CaseInsensitiveLess> CommandLineInterface::s_opt
339453
commandLineInterface->SetWVDFileType(utf8_to_utf16(fileType));
340454
return S_OK;
341455
}),
342-
}
456+
},
457+
{
458+
L"-sourceApplicationId",
459+
Option(true, IDS_STRING_HELP_OPTION_UNPACK_DESTINATION,
460+
[&](CommandLineInterface* commandLineInterface, const std::string& sourceApplicationId)
461+
{
462+
commandLineInterface->m_sourceApplicationId = utf8_to_utf16(sourceApplicationId);
463+
return S_OK;
464+
}),
465+
},
466+
{
467+
L"-correlationId",
468+
Option(true, IDS_STRING_HELP_OPTION_UNPACK_DESTINATION,
469+
[&](CommandLineInterface* commandLineInterface, const std::string& correlationId)
470+
{
471+
commandLineInterface->m_correlationId = utf8_to_utf16(correlationId);
472+
return S_OK;
473+
}),
474+
}
343475
})
344476
},
345477
{
@@ -479,4 +611,30 @@ void CommandLineInterface::SetWVDFileType(std::wstring fileType)
479611
{
480612
this->m_fileType = WVDFileType::NotSpecified;
481613
}
482-
}
614+
}
615+
616+
std::wstring CommandLineInterface::GetFileTypeAsString()
617+
{
618+
switch (this->m_fileType)
619+
{
620+
case WVDFileType::CIM: return L"CIM";
621+
case WVDFileType::VHD: return L"VHD";
622+
case WVDFileType::VHDX: return L"VHDX";
623+
case WVDFileType::NotSpecified: return L"NotSpecified";
624+
}
625+
}
626+
627+
std::wstring CommandLineInterface::GetOperationTypeAsString()
628+
{
629+
switch (this->m_operationType)
630+
{
631+
case OperationType::Add: return L"AddPackage";
632+
case OperationType::Remove: return L"RemovePackage";
633+
case OperationType::FindPackage: return L"FindPackage";
634+
case OperationType::Unpack: return L"Unpack";
635+
case OperationType::ApplyACLs: return L"ApplyACLs";
636+
case OperationType::MountImage: return L"MountImage";
637+
case OperationType::UnmountImage: return L"UnmountImage";
638+
case OperationType::Undefined: return L"Undefined";
639+
}
640+
}

MsixCore/msixmgr/CommandLineInterface.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,17 @@ class CommandLineInterface
9696
bool IsCreate() { return m_create; }
9797
bool isMountReadOnly() { return m_readOnly; }
9898
std::wstring GetPackageFilePathToInstall() { return m_packageFilePath; }
99+
std::wstring GetSourceApplicationId() { return m_sourceApplicationId; }
100+
std::wstring GetCorrelationId() { return m_correlationId; }
99101
std::wstring GetPackageFullName() { return m_packageFullName; }
100102
std::wstring GetUnpackDestination() { return m_unpackDestination; }
101103
std::wstring GetRootDirectory() { return m_rootDirectory; }
102104
std::wstring GetMountImagePath() { return m_mountImagePath; }
103105
std::wstring GetVolumeId() { return m_volumeId; }
104106
WVDFileType GetFileType() { return m_fileType; }
107+
std::wstring GetFileTypeAsString();
105108
OperationType GetOperationType() { return m_operationType; }
109+
std::wstring GetOperationTypeAsString();
106110
ULONGLONG GetVHDSize() { return m_vhdSize; }
107111
private:
108112
int m_argc = 0;
@@ -117,6 +121,8 @@ class CommandLineInterface
117121
std::wstring m_rootDirectory;
118122
std::wstring m_mountImagePath;
119123
std::wstring m_volumeId;
124+
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.
125+
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.
120126
bool m_quietMode;
121127
bool m_applyACLs;
122128
bool m_validateSignature;

0 commit comments

Comments
 (0)