22 #define __INIT_node_perfctr_provider_IMP 28 #include "node_perfctr_provider.h" 32 __in LPGUID ProviderGuid,
33 __in_opt PPERF_PROVIDER_CONTEXT ProviderContext,
34 __out PHANDLE Provider);
37 __in HANDLE ProviderHandle);
40 __in HANDLE ProviderHandle,
41 __inout_bcount(TemplateSize) PPERF_COUNTERSET_INFO Template,
42 __in ULONG TemplateSize);
45 __in HANDLE ProviderHandle,
46 __in LPCGUID CounterSetGuid,
52 __in PPERF_COUNTERSET_INSTANCE InstanceBlock);
56 __inout PPERF_COUNTERSET_INSTANCE Instance,
62 __inout PPERF_COUNTERSET_INSTANCE Instance,
64 __in ULONGLONG Value);
68 __inout PPERF_COUNTERSET_INSTANCE Instance,
74 __inout PPERF_COUNTERSET_INSTANCE Instance,
76 __in ULONGLONG Value);
80 __inout PPERF_COUNTERSET_INSTANCE Instance,
86 __inout PPERF_COUNTERSET_INSTANCE Instance,
88 __in ULONGLONG Value);
107 #define NODE_COUNTER_HTTP_SERVER_REQUEST 1 108 #define NODE_COUNTER_HTTP_SERVER_RESPONSE 2 109 #define NODE_COUNTER_HTTP_CLIENT_REQUEST 3 110 #define NODE_COUNTER_HTTP_CLIENT_RESPONSE 4 111 #define NODE_COUNTER_SERVER_CONNS 5 112 #define NODE_COUNTER_NET_BYTES_SENT 6 113 #define NODE_COUNTER_NET_BYTES_RECV 7 114 #define NODE_COUNTER_GC_PERCENTTIME 8 115 #define NODE_COUNTER_PIPE_BYTES_SENT 9 116 #define NODE_COUNTER_PIPE_BYTES_RECV 10 126 PERF_PROVIDER_CONTEXT providerContext;
129 #define INST_MAX_LEN 32 130 #define INST_PREFIX_LEN 5 131 #define INST_PREFIX L"node_" 134 DWORD pid = GetCurrentProcessId();
138 advapimod = LoadLibraryW(L
"advapi32.dll");
141 GetProcAddress(
advapimod,
"PerfStartProviderEx");
143 GetProcAddress(
advapimod,
"PerfStopProvider");
145 GetProcAddress(
advapimod,
"PerfSetCounterSetInfo");
147 GetProcAddress(
advapimod,
"PerfCreateInstance");
149 GetProcAddress(
advapimod,
"PerfDeleteInstance");
151 GetProcAddress(
advapimod,
"PerfSetULongCounterValue");
153 GetProcAddress(
advapimod,
"PerfSetULongLongCounterValue");
155 GetProcAddress(
advapimod,
"PerfIncrementULongCounterValue");
157 GetProcAddress(
advapimod,
"PerfIncrementULongLongCounterValue");
159 GetProcAddress(
advapimod,
"PerfDecrementULongCounterValue");
161 GetProcAddress(
advapimod,
"PerfDecrementULongLongCounterValue");
163 ZeroMemory(&providerContext,
sizeof(providerContext));
164 providerContext.ContextSize =
sizeof(providerContext);
169 NodeCounterProvider =
nullptr;
175 &NodeCounterProvider);
176 if (status != ERROR_SUCCESS) {
177 NodeCounterProvider =
nullptr;
182 &NodeCounterSetInfo.CounterSet,
183 sizeof(NodeCounterSetInfo));
184 if (status != ERROR_SUCCESS) {
186 NodeCounterProvider =
nullptr;
196 NodeCounterProvider =
nullptr;
203 if (NodeCounterProvider !=
nullptr &&
206 NodeCounterProvider =
nullptr;
217 if (NodeCounterProvider !=
nullptr &&
228 if (NodeCounterProvider !=
nullptr &&
239 if (NodeCounterProvider !=
nullptr &&
250 if (NodeCounterProvider !=
nullptr &&
261 if (NodeCounterProvider !=
nullptr &&
272 if (NodeCounterProvider !=
nullptr &&
283 if (NodeCounterProvider !=
nullptr &&
288 static_cast<ULONGLONG>(bytes));
294 if (NodeCounterProvider !=
nullptr &&
299 static_cast<ULONGLONG>(bytes));
305 LARGE_INTEGER timegc;
306 if (QueryPerformanceCounter(&timegc)) {
307 return timegc.QuadPart;
309 return static_cast<uint64_t
>(GetTickCount());
325 if (NodeCounterProvider !=
nullptr &&
330 static_cast<ULONGLONG>(bytes));
336 if (NodeCounterProvider !=
nullptr &&
341 static_cast<ULONGLONG>(bytes));
ULONG(WINAPI * PerfDecrementULongLongCounterValueFunc)(__in HANDLE Provider, __inout PPERF_COUNTERSET_INSTANCE Instance, __in ULONG CounterId, __in ULONGLONG Value)
void NODE_COUNT_HTTP_SERVER_RESPONSE()
#define NODE_COUNTER_HTTP_CLIENT_RESPONSE
PerfIncrementULongLongCounterValueFunc perfctr_incrementULongLongValue
PerfSetULongCounterValueFunc perfctr_setULongValue
void InitPerfCountersWin32()
void NODE_COUNT_NET_BYTES_SENT(int bytes)
PPERF_COUNTERSET_INSTANCE(WINAPI * PerfCreateInstanceFunc)(__in HANDLE ProviderHandle, __in LPCGUID CounterSetGuid, __in PCWSTR Name, __in ULONG Id)
ULONG(WINAPI * PerfSetULongCounterValueFunc)(__in HANDLE Provider, __inout PPERF_COUNTERSET_INSTANCE Instance, __in ULONG CounterId, __in ULONG Value)
ULONG(WINAPI * PerfSetCounterSetInfoFunc)(__in HANDLE ProviderHandle, __inout_bcount(TemplateSize) PPERF_COUNTERSET_INFO Template, __in ULONG TemplateSize)
#define NODE_COUNTER_NET_BYTES_RECV
ULONG(WINAPI * PerfDeleteInstanceFunc)(__in HANDLE Provider, __in PPERF_COUNTERSET_INSTANCE InstanceBlock)
void NODE_COUNT_PIPE_BYTES_SENT(int bytes)
void NODE_COUNT_SERVER_CONN_OPEN()
PerfDeleteInstanceFunc perfctr_deleteInstance
void NODE_COUNT_HTTP_CLIENT_RESPONSE()
PPERF_COUNTERSET_INSTANCE perfctr_instance
#define NODE_COUNTER_HTTP_SERVER_RESPONSE
void NODE_COUNT_HTTP_SERVER_REQUEST()
void NODE_COUNT_SERVER_CONN_CLOSE()
ULONG(WINAPI * PerfStopProviderFunc)(__in HANDLE ProviderHandle)
#define NODE_COUNTER_HTTP_SERVER_REQUEST
#define NODE_COUNTER_GC_PERCENTTIME
ULONG(WINAPI * PerfIncrementULongCounterValueFunc)(__in HANDLE Provider, __inout PPERF_COUNTERSET_INSTANCE Instance, __in ULONG CounterId, __in ULONG Value)
PerfStopProviderFunc perfctr_stopProvider
PerfIncrementULongCounterValueFunc perfctr_incrementULongValue
#define NODE_COUNTER_SERVER_CONNS
PerfSetULongLongCounterValueFunc perfctr_setULongLongValue
void NODE_COUNT_NET_BYTES_RECV(int bytes)
ULONG(WINAPI * PerfDecrementULongCounterValueFunc)(__in HANDLE Provider, __inout PPERF_COUNTERSET_INSTANCE Instance, __in ULONG CounterId, __in ULONG Value)
PerfDecrementULongCounterValueFunc perfctr_decrementULongValue
PerfDecrementULongLongCounterValueFunc perfctr_decrementULongLongValue
ULONG(WINAPI * PerfIncrementULongLongCounterValueFunc)(__in HANDLE Provider, __inout PPERF_COUNTERSET_INSTANCE Instance, __in ULONG CounterId, __in ULONGLONG Value)
void NODE_COUNT_GC_PERCENTTIME(unsigned int percent)
EXTERN_C DECLSPEC_SELECTANY HANDLE NodeCounterProvider
#define NODE_COUNTER_PIPE_BYTES_RECV
ULONG(WINAPI * PerfSetULongLongCounterValueFunc)(__in HANDLE Provider, __inout PPERF_COUNTERSET_INSTANCE Instance, __in ULONG CounterId, __in ULONGLONG Value)
PerfSetCounterSetInfoFunc perfctr_setCounterSetInfo
void TermPerfCountersWin32()
#define NODE_COUNTER_PIPE_BYTES_SENT
void NODE_COUNT_PIPE_BYTES_RECV(int bytes)
PerfCreateInstanceFunc perfctr_createInstance
uint64_t NODE_COUNT_GET_GC_RAWTIME()
#define NODE_COUNTER_NET_BYTES_SENT
ULONG(WINAPI * PerfStartProviderExFunc)(__in LPGUID ProviderGuid, __in_opt PPERF_PROVIDER_CONTEXT ProviderContext, __out PHANDLE Provider)
void NODE_COUNT_HTTP_CLIENT_REQUEST()
#define NODE_COUNTER_HTTP_CLIENT_REQUEST
PerfStartProviderExFunc perfctr_startProvider