master
h 77 lines 2.09 KB
Raw
1 /*++
2
3 Copyright (c) Microsoft. All rights reserved.
4
5 Module Name:
6
7 WslTelemetry.h
8
9 Abstract:
10
11 This file contains tracing function declarations.
12
13 --*/
14
15 #pragma once
16
17 #include <windows.h>
18 #include <winmeta.h>
19 #include <evntprov.h>
20 #include <wil/resource.h>
21 #include <type_traits>
22 #include <TraceLoggingProvider.h>
23 #include <TraceLoggingActivity.h>
24 #include "traceloggingconfig.h"
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 TRACELOGGING_DECLARE_PROVIDER(LxssTelemetryProvider);
30 TRACELOGGING_DECLARE_PROVIDER(WslServiceTelemetryProvider);
31 TRACELOGGING_DECLARE_PROVIDER(WslcTelemetryProvider);
32 #ifdef __cplusplus
33 }
34 #endif
35
36 extern TraceLoggingHProvider g_hTraceLoggingProvider;
37
38 // Initialize tracelogging for the binary.
39 // DisableTelemetryByDefault - In scenarios where there are no active users, assume telemetry is not allowed.
40 // This is used in conjunction with WslTraceLoggingClient to represent active clients.
41 // ForceDropPII - Make sure all events are tagged with MICROSOFT_EVENTTAG_DROP_PII.
42 // WARNING: This will mean backend tools like devicedrill will not work. This should be a temporary setting.
43 void WslTraceLoggingInitialize(_In_ TraceLoggingHProvider, _In_ BOOLEAN DisableTelemetryByDefault, _In_ std::optional<TLG_PENABLECALLBACK> callback = {});
44
45 void WslTraceLoggingUninitialize();
46
47 bool WslTraceLoggingShouldDisableTelemetry() noexcept;
48
49 #ifdef __cplusplus
50 class WslTraceLoggingClient
51 {
52 public:
53 WslTraceLoggingClient(bool TelemetryEnabled);
54 ~WslTraceLoggingClient();
55
56 private:
57 bool m_clientTelemetryEnabled;
58 };
59
60 #endif
61
62 #define WSL_LOG(Name, ...) TraceLoggingWrite(g_hTraceLoggingProvider, Name, __VA_ARGS__)
63
64 #define WSL_LOG_DEBUG(Name, ...) \
65 if constexpr (wsl::shared::Debug) \
66 { \
67 WSL_LOG(Name, __VA_ARGS__); \
68 }
69
70 #define WSL_LOG_TELEMETRY(Name, Tag, ...) \
71 TraceLoggingWrite( \
72 g_hTraceLoggingProvider, \
73 Name, \
74 TraceLoggingValue(WSL_PACKAGE_VERSION, "wslVersion"), \
75 TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES), \
76 TelemetryPrivacyDataTag(Tag), \
77 __VA_ARGS__);