-
Notifications
You must be signed in to change notification settings - Fork 334
/
Copy pathMddBootstrapTracelogging.h
142 lines (127 loc) · 5.73 KB
/
MddBootstrapTracelogging.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
#pragma once
#include "pch.h"
bool __stdcall wilResultLoggingThreadCallback(const wil::FailureInfo& failure) noexcept;
GUID& GetLifetimeActivityId() noexcept;
class WindowsAppRuntimeBootstrap_TraceLogger final : public wil::TraceLoggingProvider
{
IMPLEMENT_TRACELOGGING_CLASS(
WindowsAppRuntimeBootstrap_TraceLogger,
"Microsoft.WindowsAppRuntime.MddBootstrap",
// {d71ecd75-2924-589c-16dd-68208d1b4015}
(0xd71ecd75, 0x2924, 0x589c, 0x16, 0xdd, 0x68, 0x20, 0x8d, 0x1b, 0x40, 0x15));
public:
BEGIN_COMPLIANT_CRITICAL_DATA_ACTIVITY_CLASS(Initialize, PDT_ProductAndServicePerformance);
void StartActivity(
UINT32 majorMinorVersion,
PCWSTR versionTag,
PACKAGE_VERSION minVersion,
UINT32 mddInitializeOptions,
UINT32 initializationCount)
{
// Set lifetime activity Id that helps in corelating all sub-activities/telemetry from a single Mdd Bootstrap lifetime
SetRelatedActivityId(GetLifetimeActivityId());
TraceLoggingClassWriteStart(Initialize,
_GENERIC_PARTB_FIELDS_ENABLED,
TraceLoggingValue(majorMinorVersion, "majorMinorVersion"),
TraceLoggingValue(!versionTag ? L"": versionTag, "versionTag"),
TraceLoggingValue(minVersion.Version, "minVersion"),
TraceLoggingValue(mddInitializeOptions, "mddInitializeOptions"),
TraceLoggingValue(initializationCount, "initializationCount"));
}
void StopWithResult(
const HRESULT hresult,
UINT32 initializationCount,
UINT32 IntegrityFlags,
PWSTR resolvedFrameworkPackageFullName,
UINT32 failureType,
PCSTR failureFile,
unsigned int failureLineNumber,
PCWSTR failureMessage,
PCSTR failureModule)
{
SetStopResult(hresult);
if (hresult)
{
TraceLoggingClassWriteStop(Initialize,
_GENERIC_PARTB_FIELDS_ENABLED,
TraceLoggingValue(initializationCount, "initializationCount"),
TraceLoggingValue(IntegrityFlags, "IntegrityFlags"),
TraceLoggingValue(resolvedFrameworkPackageFullName, "resolvedFrameworkPackageFullName"),
TraceLoggingValue(failureType, "wilFailureType"),
TraceLoggingValue(failureFile, "failureFile"),
TraceLoggingValue(failureLineNumber, "failureLineNumber"),
TraceLoggingValue(failureMessage, "failureMessage"),
TraceLoggingValue(failureModule, "failureModule"));
}
else
{
TraceLoggingClassWriteStop(Initialize,
_GENERIC_PARTB_FIELDS_ENABLED,
TraceLoggingValue(initializationCount, "initializationCount"),
TraceLoggingValue(IntegrityFlags, "IntegrityFlags"),
TraceLoggingValue(resolvedFrameworkPackageFullName, "resolvedFrameworkPackageFullName"));
}
}
END_ACTIVITY_CLASS();
BEGIN_COMPLIANT_CRITICAL_DATA_ACTIVITY_CLASS(Shutdown, PDT_ProductAndServicePerformance);
void StartActivity(
UINT32 initializationCount,
PWSTR resolvedFrameworkPackageFullName)
{
// Set lifetime activity Id that helps in corelating all sub-activities/telemetry from a single Mdd Bootstrap lifetime
SetRelatedActivityId(GetLifetimeActivityId());
TraceLoggingClassWriteStart(Shutdown,
_GENERIC_PARTB_FIELDS_ENABLED,
TraceLoggingValue(initializationCount, "initializationCount"),
TraceLoggingValue(resolvedFrameworkPackageFullName, "resolvedFrameworkPackageFullName"));
}
void StopWithResult(
HRESULT hresult,
UINT32 initializationCount,
UINT32 failureType,
PCSTR failureFile,
unsigned int failureLineNumber,
PCWSTR failureMessage,
PCSTR failureModule)
{
SetStopResult(hresult);
if (hresult)
{
TraceLoggingClassWriteStop(Shutdown,
_GENERIC_PARTB_FIELDS_ENABLED,
TraceLoggingValue(initializationCount, "initializationCount"),
TraceLoggingValue(failureType, "WilFailureType"),
TraceLoggingValue(failureFile, "FailureFile"),
TraceLoggingValue(failureLineNumber, "FailureLineNumber"),
TraceLoggingValue(failureMessage, "FailureMessage"),
TraceLoggingValue(failureModule, "FailureModule"));
}
else
{
TraceLoggingClassWriteStop(Shutdown,
_GENERIC_PARTB_FIELDS_ENABLED,
TraceLoggingValue(initializationCount, "initializationCount"));
}
}
END_ACTIVITY_CLASS();
};
#define MddBootstrap_TraceLoggingWString(_wstring_, _name_) TraceLoggingCountedWideString(_wstring_.c_str(),\
static_cast<ULONG>(_wstring_.size()), _name_)
// In the future, if the project includes multiple modules and threads, we could log that data as well from FailureInfo
// In the future and on need basis, we could log call stack as well
#define MddBootstrap_WriteEventWithActivity(_eventname_,_activityId_,...) TraceLoggingWriteActivity(\
WindowsAppRuntimeBootstrap_TraceLogger::Provider(),\
_eventname_,\
_activityId_,\
nullptr,\
_WRITE_FAILURE_INFO,\
__VA_ARGS__)
#define _WRITE_FAILURE_INFO \
TraceLoggingValue(static_cast<uint32_t>(failure.type), "Type"),\
TraceLoggingValue(failure.hr, "HResult"),\
TraceLoggingValue(failure.pszFile, "File"),\
TraceLoggingValue(failure.uLineNumber,"Line"),\
TraceLoggingValue(failure.pszModule, "Module"),\
TraceLoggingValue(failure.pszMessage,"Message")