From 23db53eae664db68ff3e8d3bd5051ae5a80988ca Mon Sep 17 00:00:00 2001 From: Justin Kotalik Date: Tue, 9 Oct 2018 10:25:12 -0700 Subject: [PATCH] Add more FREB events/ tests for FREB events (#1461) --- src/AspNetCoreModuleV2/AspNetCore/ancm.mof | 116 ++- .../CommonLib/CommonLib.vcxproj | 3 +- .../CommonLib/ModuleTracer.h | 98 ++ .../CommonLib/aspnetcore_event.h | 908 ++++++++++++------ .../InProcessRhStaticHtml.htm | 2 +- .../InProcessRequestHandler/dllmain.cpp | 1 + .../inprocesshandler.cpp | 50 +- .../inprocesshandler.h | 4 +- .../IISDeploymentParameterExtensions.cs | 74 +- .../Inprocess/FrebTests.cs | 118 +++ .../Utilities/Helpers.cs | 33 + .../Utilities/IISCapability.cs | 3 +- .../RequiresIISAttribute.cs | 16 +- .../OutOfProcess/MultipleAppTests.cs | 24 +- 14 files changed, 1116 insertions(+), 334 deletions(-) create mode 100644 src/AspNetCoreModuleV2/CommonLib/ModuleTracer.h create mode 100644 test/Common.FunctionalTests/Inprocess/FrebTests.cs diff --git a/src/AspNetCoreModuleV2/AspNetCore/ancm.mof b/src/AspNetCoreModuleV2/AspNetCore/ancm.mof index f3f7fcd15a..289225477d 100644 --- a/src/AspNetCoreModuleV2/AspNetCore/ancm.mof +++ b/src/AspNetCoreModuleV2/AspNetCore/ancm.mof @@ -186,12 +186,28 @@ class ANCMWinHttpCallBack:ANCM_Events }; [Dynamic, - Description("Inprocess executing request failure") : amended, - EventType(7), - EventLevel(2), - EventTypeName("ANCM_EXECUTE_REQUEST_FAIL") : amended + Description("Starting inprocess execute request") : amended, + EventType(8), + EventLevel(4), + EventTypeName("ANCM_INPROC_EXECUTE_REQUEST_START") : amended ] -class ANCMExecuteFailed:ANCM_Events +class ANCMExecuteStart:ANCM_Events +{ + [WmiDataId(1), + Description("Context ID") : amended, + extension("Guid"), + ActivityID, + read] + object ContextId; +}; + +[Dynamic, + Description("Ending inprocess execute request") : amended, + EventType(10), + EventLevel(5), + EventTypeName("ANCM_INPROC_EXECUTE_REQUEST_COMPLETION") : amended +] +class ANCMExecuteEnd:ANCM_Events { [WmiDataId(1), Description("Context ID") : amended, @@ -200,9 +216,93 @@ class ANCMExecuteFailed:ANCM_Events read] object ContextId; [WmiDataId(2), - Description("InternetStatus") : amended, - format("x"), + Description("Notification status") : amended, + format("d"), read] - uint32 ErrorCode; + uint32 requestStatus; }; +[Dynamic, + Description("Starting inprocess async completion") : amended, + EventType(8), + EventLevel(5), + EventTypeName("ANCM_INPROC_ASYNC_COMPLETION_START") : amended +] +class ANCMAsyncStart:ANCM_Events +{ + [WmiDataId(1), + Description("Context ID") : amended, + extension("Guid"), + ActivityID, + read] + object ContextId; +}; + +[Dynamic, + Description("Ending inprocess async completion") : amended, + EventType(10), + EventLevel(5), + EventTypeName("ANCM_INPROC_ASYNC_COMPLETION_COMPLETION") : amended +] +class ANCMAsyncEnd:ANCM_Events +{ + [WmiDataId(1), + Description("Context ID") : amended, + extension("Guid"), + ActivityID, + read] + object ContextId; + [WmiDataId(2), + Description("Notification status") : amended, + format("d"), + read] + uint32 requestStatus; +}; + +[Dynamic, + Description("Inprocess app shutdown") : amended, + EventType(11), + EventLevel(4), + EventTypeName("ANCM_INPROC_REQUEST_SHUTDOWN") : amended +] +class ANCMRequestShutdown:ANCM_Events +{ + [WmiDataId(1), + Description("Context ID") : amended, + extension("Guid"), + ActivityID, + read] + object ContextId; +}; + +[Dynamic, + Description("Inprocess request disconnect") : amended, + EventType(12), + EventLevel(4), + EventTypeName("ANCM_INPROC_REQUEST_DISCONNECT") : amended +] +class ANCMRequestDisconnect:ANCM_Events +{ + [WmiDataId(1), + Description("Context ID") : amended, + extension("Guid"), + ActivityID, + read] + object ContextId; +}; + +[Dynamic, + Description("Indicate managed request complete") : amended, + EventType(12), + EventLevel(4), + EventTypeName("ANCM_INPROC_MANAGED_REQUEST_COMPLETION") : amended +] +class ANCMManagedRequestCompletion:ANCM_Events +{ + [WmiDataId(1), + Description("Context ID") : amended, + extension("Guid"), + ActivityID, + read] + object ContextId; +}; diff --git a/src/AspNetCoreModuleV2/CommonLib/CommonLib.vcxproj b/src/AspNetCoreModuleV2/CommonLib/CommonLib.vcxproj index caa53ff29d..7968238f90 100644 --- a/src/AspNetCoreModuleV2/CommonLib/CommonLib.vcxproj +++ b/src/AspNetCoreModuleV2/CommonLib/CommonLib.vcxproj @@ -219,7 +219,8 @@ - + + diff --git a/src/AspNetCoreModuleV2/CommonLib/ModuleTracer.h b/src/AspNetCoreModuleV2/CommonLib/ModuleTracer.h new file mode 100644 index 0000000000..6ef03fb53a --- /dev/null +++ b/src/AspNetCoreModuleV2/CommonLib/ModuleTracer.h @@ -0,0 +1,98 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +#pragma once +#include "aspnetcore_event.h" + +class ModuleTracer +{ +public: + + ModuleTracer(IHttpTraceContext* traceContext) + { + m_traceContext = traceContext; + } + + VOID + ExecuteRequestStart() + { + if (ANCMEvents::ANCM_INPROC_EXECUTE_REQUEST_START::IsEnabled(m_traceContext)) + { + ANCMEvents::ANCM_INPROC_EXECUTE_REQUEST_START::RaiseEvent( + m_traceContext, + NULL); + } + } + + VOID + ExecuteRequestEnd(REQUEST_NOTIFICATION_STATUS status) + { + if (ANCMEvents::ANCM_INPROC_EXECUTE_REQUEST_COMPLETION::IsEnabled(m_traceContext)) + { + ANCMEvents::ANCM_INPROC_EXECUTE_REQUEST_COMPLETION::RaiseEvent( + m_traceContext, + NULL, + status); + } + } + + VOID + AsyncCompletionStart() + { + + if (ANCMEvents::ANCM_INPROC_ASYNC_COMPLETION_START::IsEnabled(m_traceContext)) + { + ANCMEvents::ANCM_INPROC_ASYNC_COMPLETION_START::RaiseEvent( + m_traceContext, + NULL); + } + } + + VOID + AsyncCompletionEnd(REQUEST_NOTIFICATION_STATUS status) + { + if (ANCMEvents::ANCM_INPROC_ASYNC_COMPLETION_COMPLETION::IsEnabled(m_traceContext)) + { + ANCMEvents::ANCM_INPROC_ASYNC_COMPLETION_COMPLETION::RaiseEvent( + m_traceContext, + NULL, + status); + } + } + + VOID + RequestShutdown() + { + if (ANCMEvents::ANCM_INPROC_REQUEST_SHUTDOWN::IsEnabled(m_traceContext)) + { + ANCMEvents::ANCM_INPROC_REQUEST_SHUTDOWN::RaiseEvent( + m_traceContext, + NULL); + } + } + + VOID + RequestDisconnect() + { + if (ANCMEvents::ANCM_INPROC_REQUEST_DISCONNECT::IsEnabled(m_traceContext)) + { + ANCMEvents::ANCM_INPROC_REQUEST_DISCONNECT::RaiseEvent( + m_traceContext, + NULL); + } + } + + VOID + ManagedCompletion() + { + if (ANCMEvents::ANCM_INPROC_MANAGED_REQUEST_COMPLETION::IsEnabled(m_traceContext)) + { + ANCMEvents::ANCM_INPROC_MANAGED_REQUEST_COMPLETION::RaiseEvent( + m_traceContext, + NULL); + } + } + +private: + IHttpTraceContext * m_traceContext; +}; diff --git a/src/AspNetCoreModuleV2/CommonLib/aspnetcore_event.h b/src/AspNetCoreModuleV2/CommonLib/aspnetcore_event.h index 2c13d20d1e..f40dc0d2bb 100644 --- a/src/AspNetCoreModuleV2/CommonLib/aspnetcore_event.h +++ b/src/AspNetCoreModuleV2/CommonLib/aspnetcore_event.h @@ -1,37 +1,41 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. #ifndef __ASPNETCOREEVENT_H__ #define __ASPNETCOREEVENT_H__ /*++ - Module Name: +Copyright (c) 2005 Microsoft Corporation - aspnetcore_event.h +Module Name: - Abstract: +aspnetcore_event.h - Header file has been generated from mof file containing - IIS trace event descriptions +Abstract: + +Header file has been generated from mof file containing +IIS trace event descriptions --*/ + + // // Start of the new provider class WWWServerTraceProvider, // GUID: {3a2a4e84-4c21-4981-ae10-3fda0d9b0f83} // Description: IIS: WWW Server // +#include "httptrace.h" + class WWWServerTraceProvider { public: static - LPCGUID - GetProviderGuid( VOID ) - // return GUID for the current event class + LPCGUID + GetProviderGuid(VOID) + // return GUID for the current event class { - static const GUID ProviderGuid = - {0x3a2a4e84,0x4c21,0x4981,{0xae,0x10,0x3f,0xda,0x0d,0x9b,0x0f,0x83}}; + static const GUID ProviderGuid = + { 0x3a2a4e84,0x4c21,0x4981,{ 0xae,0x10,0x3f,0xda,0x0d,0x9b,0x0f,0x83 } }; return &ProviderGuid; }; enum enumAreaFlags @@ -40,10 +44,10 @@ public: ANCM = 0x10000 }; static - LPCWSTR - TranslateEnumAreaFlagsToString( enum enumAreaFlags EnumValue) + LPCWSTR + TranslateEnumAreaFlagsToString(enum enumAreaFlags EnumValue) { - switch( (DWORD) EnumValue ) + switch ((DWORD)EnumValue) { case 0x10000: return L"ANCM"; } @@ -51,26 +55,26 @@ public: }; static - BOOL - CheckTracingEnabled( - IHttpTraceContext * pHttpTraceContext, - enumAreaFlags AreaFlags, - DWORD dwVerbosity ) + BOOL + CheckTracingEnabled( + IHttpTraceContext * pHttpTraceContext, + enumAreaFlags AreaFlags, + DWORD dwVerbosity) { HRESULT hr; HTTP_TRACE_CONFIGURATION TraceConfig; TraceConfig.pProviderGuid = GetProviderGuid(); - hr = pHttpTraceContext->GetTraceConfiguration( &TraceConfig ); - if ( FAILED( hr ) || !TraceConfig.fProviderEnabled ) + hr = pHttpTraceContext->GetTraceConfiguration(&TraceConfig); + if (FAILED(hr) || !TraceConfig.fProviderEnabled) { return FALSE; } - if ( TraceConfig.dwVerbosity >= dwVerbosity && - ( TraceConfig.dwAreas == (DWORD) AreaFlags || - ( TraceConfig.dwAreas & (DWORD)AreaFlags ) == (DWORD)AreaFlags ) ) - { + if (TraceConfig.dwVerbosity >= dwVerbosity && + (TraceConfig.dwAreas == (DWORD)AreaFlags || + (TraceConfig.dwAreas & (DWORD)AreaFlags) == (DWORD)AreaFlags)) + { return TRUE; - } + } return FALSE; }; }; @@ -85,12 +89,12 @@ class ANCMEvents { public: static - LPCGUID - GetAreaGuid( VOID ) - // return GUID for the current event class + LPCGUID + GetAreaGuid(VOID) + // return GUID for the current event class { - static const GUID AreaGuid = - {0x82adead7,0x12b2,0x4781,{0xbd,0xca,0x5a,0x4b,0x6c,0x75,0x71,0x91}}; + static const GUID AreaGuid = + { 0x82adead7,0x12b2,0x4781,{ 0xbd,0xca,0x5a,0x4b,0x6c,0x75,0x71,0x91 } }; return &AreaGuid; }; @@ -101,24 +105,24 @@ public: // EventType: 1 // EventLevel: 4 // - + class ANCM_START_APPLICATION_SUCCESS { public: static - HRESULT - RaiseEvent( - IHttpTraceContext * pHttpTraceContext, - LPCGUID pContextId, - LPCWSTR pAppDescription - ) - // - // Raise ANCM_START_APPLICATION_SUCCESS Event - // + HRESULT + RaiseEvent( + IHttpTraceContext * pHttpTraceContext, + LPCGUID pContextId, + LPCWSTR pAppDescription + ) + // + // Raise ANCM_START_APPLICATION_SUCCESS Event + // { HTTP_TRACE_EVENT Event; Event.pProviderGuid = WWWServerTraceProvider::GetProviderGuid(); - Event.dwArea = WWWServerTraceProvider::ANCM; + Event.dwArea = WWWServerTraceProvider::ANCM; Event.pAreaGuid = ANCMEvents::GetAreaGuid(); Event.dwEvent = 1; Event.pszEventName = L"ANCM_START_APPLICATION_SUCCESS"; @@ -129,36 +133,36 @@ public: Event.pRelatedActivityGuid = NULL; Event.dwTimeStamp = 0; Event.dwFlags = HTTP_TRACE_EVENT_FLAG_STATIC_DESCRIPTIVE_FIELDS; - + // pActivityGuid, pRelatedActivityGuid, Timestamp to be filled in by IIS - - HTTP_TRACE_EVENT_ITEM Items[ 2 ]; - Items[ 0 ].pszName = L"ContextId"; - Items[ 0 ].dwDataType = HTTP_TRACE_TYPE_LPCGUID; // mof type (object) - Items[ 0 ].pbData = (PBYTE) pContextId; - Items[ 0 ].cbData = 16; - Items[ 0 ].pszDataDescription = NULL; - Items[ 1 ].pszName = L"AppDescription"; - Items[ 1 ].dwDataType = HTTP_TRACE_TYPE_LPCWSTR; // mof type (string) - Items[ 1 ].pbData = (PBYTE) pAppDescription; - Items[ 1 ].cbData = - ( Items[ 1 ].pbData == NULL )? 0 : ( sizeof(WCHAR) * (1 + (DWORD) wcslen( (PWSTR) Items[ 1 ].pbData ) ) ); - Items[ 1 ].pszDataDescription = NULL; + + HTTP_TRACE_EVENT_ITEM Items[2]; + Items[0].pszName = L"ContextId"; + Items[0].dwDataType = HTTP_TRACE_TYPE_LPCGUID; // mof type (object) + Items[0].pbData = (PBYTE)pContextId; + Items[0].cbData = 16; + Items[0].pszDataDescription = NULL; + Items[1].pszName = L"AppDescription"; + Items[1].dwDataType = HTTP_TRACE_TYPE_LPCWSTR; // mof type (string) + Items[1].pbData = (PBYTE)pAppDescription; + Items[1].cbData = + (Items[1].pbData == NULL) ? 0 : (sizeof(WCHAR) * (1 + (DWORD)wcslen((PWSTR)Items[1].pbData))); + Items[1].pszDataDescription = NULL; Event.pEventItems = Items; - pHttpTraceContext->RaiseTraceEvent( &Event ); + pHttpTraceContext->RaiseTraceEvent(&Event); return S_OK; }; - + static - BOOL - IsEnabled( - IHttpTraceContext * pHttpTraceContext ) - // Check if tracing for this event is enabled + BOOL + IsEnabled( + IHttpTraceContext * pHttpTraceContext) + // Check if tracing for this event is enabled { - return WWWServerTraceProvider::CheckTracingEnabled( - pHttpTraceContext, - WWWServerTraceProvider::ANCM, - 4 ); //Verbosity + return WWWServerTraceProvider::CheckTracingEnabled( + pHttpTraceContext, + WWWServerTraceProvider::ANCM, + 4); //Verbosity }; }; // @@ -168,24 +172,24 @@ public: // EventType: 2 // EventLevel: 2 // - + class ANCM_START_APPLICATION_FAIL { public: static - HRESULT - RaiseEvent( - IHttpTraceContext * pHttpTraceContext, - LPCGUID pContextId, - LPCWSTR pFailureDescription - ) - // - // Raise ANCM_START_APPLICATION_FAIL Event - // + HRESULT + RaiseEvent( + IHttpTraceContext * pHttpTraceContext, + LPCGUID pContextId, + LPCWSTR pFailureDescription + ) + // + // Raise ANCM_START_APPLICATION_FAIL Event + // { HTTP_TRACE_EVENT Event; Event.pProviderGuid = WWWServerTraceProvider::GetProviderGuid(); - Event.dwArea = WWWServerTraceProvider::ANCM; + Event.dwArea = WWWServerTraceProvider::ANCM; Event.pAreaGuid = ANCMEvents::GetAreaGuid(); Event.dwEvent = 2; Event.pszEventName = L"ANCM_START_APPLICATION_FAIL"; @@ -196,36 +200,36 @@ public: Event.pRelatedActivityGuid = NULL; Event.dwTimeStamp = 0; Event.dwFlags = HTTP_TRACE_EVENT_FLAG_STATIC_DESCRIPTIVE_FIELDS; - + // pActivityGuid, pRelatedActivityGuid, Timestamp to be filled in by IIS - - HTTP_TRACE_EVENT_ITEM Items[ 2 ]; - Items[ 0 ].pszName = L"ContextId"; - Items[ 0 ].dwDataType = HTTP_TRACE_TYPE_LPCGUID; // mof type (object) - Items[ 0 ].pbData = (PBYTE) pContextId; - Items[ 0 ].cbData = 16; - Items[ 0 ].pszDataDescription = NULL; - Items[ 1 ].pszName = L"FailureDescription"; - Items[ 1 ].dwDataType = HTTP_TRACE_TYPE_LPCWSTR; // mof type (string) - Items[ 1 ].pbData = (PBYTE) pFailureDescription; - Items[ 1 ].cbData = - ( Items[ 1 ].pbData == NULL )? 0 : ( sizeof(WCHAR) * (1 + (DWORD) wcslen( (PWSTR) Items[ 1 ].pbData ) ) ); - Items[ 1 ].pszDataDescription = NULL; + + HTTP_TRACE_EVENT_ITEM Items[2]; + Items[0].pszName = L"ContextId"; + Items[0].dwDataType = HTTP_TRACE_TYPE_LPCGUID; // mof type (object) + Items[0].pbData = (PBYTE)pContextId; + Items[0].cbData = 16; + Items[0].pszDataDescription = NULL; + Items[1].pszName = L"FailureDescription"; + Items[1].dwDataType = HTTP_TRACE_TYPE_LPCWSTR; // mof type (string) + Items[1].pbData = (PBYTE)pFailureDescription; + Items[1].cbData = + (Items[1].pbData == NULL) ? 0 : (sizeof(WCHAR) * (1 + (DWORD)wcslen((PWSTR)Items[1].pbData))); + Items[1].pszDataDescription = NULL; Event.pEventItems = Items; - pHttpTraceContext->RaiseTraceEvent( &Event ); + pHttpTraceContext->RaiseTraceEvent(&Event); return S_OK; }; - + static - BOOL - IsEnabled( - IHttpTraceContext * pHttpTraceContext ) - // Check if tracing for this event is enabled + BOOL + IsEnabled( + IHttpTraceContext * pHttpTraceContext) + // Check if tracing for this event is enabled { - return WWWServerTraceProvider::CheckTracingEnabled( - pHttpTraceContext, - WWWServerTraceProvider::ANCM, - 2 ); //Verbosity + return WWWServerTraceProvider::CheckTracingEnabled( + pHttpTraceContext, + WWWServerTraceProvider::ANCM, + 2); //Verbosity }; }; // @@ -235,23 +239,23 @@ public: // EventType: 3 // EventLevel: 4 // - + class ANCM_REQUEST_FORWARD_START { public: static - HRESULT - RaiseEvent( - IHttpTraceContext * pHttpTraceContext, - LPCGUID pContextId - ) - // - // Raise ANCM_REQUEST_FORWARD_START Event - // + HRESULT + RaiseEvent( + IHttpTraceContext * pHttpTraceContext, + LPCGUID pContextId + ) + // + // Raise ANCM_REQUEST_FORWARD_START Event + // { HTTP_TRACE_EVENT Event; Event.pProviderGuid = WWWServerTraceProvider::GetProviderGuid(); - Event.dwArea = WWWServerTraceProvider::ANCM; + Event.dwArea = WWWServerTraceProvider::ANCM; Event.pAreaGuid = ANCMEvents::GetAreaGuid(); Event.dwEvent = 3; Event.pszEventName = L"ANCM_REQUEST_FORWARD_START"; @@ -262,30 +266,30 @@ public: Event.pRelatedActivityGuid = NULL; Event.dwTimeStamp = 0; Event.dwFlags = HTTP_TRACE_EVENT_FLAG_STATIC_DESCRIPTIVE_FIELDS; - + // pActivityGuid, pRelatedActivityGuid, Timestamp to be filled in by IIS - - HTTP_TRACE_EVENT_ITEM Items[ 1 ]; - Items[ 0 ].pszName = L"ContextId"; - Items[ 0 ].dwDataType = HTTP_TRACE_TYPE_LPCGUID; // mof type (object) - Items[ 0 ].pbData = (PBYTE) pContextId; - Items[ 0 ].cbData = 16; - Items[ 0 ].pszDataDescription = NULL; + + HTTP_TRACE_EVENT_ITEM Items[1]; + Items[0].pszName = L"ContextId"; + Items[0].dwDataType = HTTP_TRACE_TYPE_LPCGUID; // mof type (object) + Items[0].pbData = (PBYTE)pContextId; + Items[0].cbData = 16; + Items[0].pszDataDescription = NULL; Event.pEventItems = Items; - pHttpTraceContext->RaiseTraceEvent( &Event ); + pHttpTraceContext->RaiseTraceEvent(&Event); return S_OK; }; - + static - BOOL - IsEnabled( - IHttpTraceContext * pHttpTraceContext ) - // Check if tracing for this event is enabled + BOOL + IsEnabled( + IHttpTraceContext * pHttpTraceContext) + // Check if tracing for this event is enabled { - return WWWServerTraceProvider::CheckTracingEnabled( - pHttpTraceContext, - WWWServerTraceProvider::ANCM, - 4 ); //Verbosity + return WWWServerTraceProvider::CheckTracingEnabled( + pHttpTraceContext, + WWWServerTraceProvider::ANCM, + 4); //Verbosity }; }; // @@ -295,23 +299,23 @@ public: // EventType: 4 // EventLevel: 4 // - + class ANCM_REQUEST_FORWARD_END { public: static - HRESULT - RaiseEvent( - IHttpTraceContext * pHttpTraceContext, - LPCGUID pContextId - ) - // - // Raise ANCM_REQUEST_FORWARD_END Event - // + HRESULT + RaiseEvent( + IHttpTraceContext * pHttpTraceContext, + LPCGUID pContextId + ) + // + // Raise ANCM_REQUEST_FORWARD_END Event + // { HTTP_TRACE_EVENT Event; Event.pProviderGuid = WWWServerTraceProvider::GetProviderGuid(); - Event.dwArea = WWWServerTraceProvider::ANCM; + Event.dwArea = WWWServerTraceProvider::ANCM; Event.pAreaGuid = ANCMEvents::GetAreaGuid(); Event.dwEvent = 4; Event.pszEventName = L"ANCM_REQUEST_FORWARD_END"; @@ -322,30 +326,30 @@ public: Event.pRelatedActivityGuid = NULL; Event.dwTimeStamp = 0; Event.dwFlags = HTTP_TRACE_EVENT_FLAG_STATIC_DESCRIPTIVE_FIELDS; - + // pActivityGuid, pRelatedActivityGuid, Timestamp to be filled in by IIS - - HTTP_TRACE_EVENT_ITEM Items[ 1 ]; - Items[ 0 ].pszName = L"ContextId"; - Items[ 0 ].dwDataType = HTTP_TRACE_TYPE_LPCGUID; // mof type (object) - Items[ 0 ].pbData = (PBYTE) pContextId; - Items[ 0 ].cbData = 16; - Items[ 0 ].pszDataDescription = NULL; + + HTTP_TRACE_EVENT_ITEM Items[1]; + Items[0].pszName = L"ContextId"; + Items[0].dwDataType = HTTP_TRACE_TYPE_LPCGUID; // mof type (object) + Items[0].pbData = (PBYTE)pContextId; + Items[0].cbData = 16; + Items[0].pszDataDescription = NULL; Event.pEventItems = Items; - pHttpTraceContext->RaiseTraceEvent( &Event ); + pHttpTraceContext->RaiseTraceEvent(&Event); return S_OK; }; - + static - BOOL - IsEnabled( - IHttpTraceContext * pHttpTraceContext ) - // Check if tracing for this event is enabled + BOOL + IsEnabled( + IHttpTraceContext * pHttpTraceContext) + // Check if tracing for this event is enabled { - return WWWServerTraceProvider::CheckTracingEnabled( - pHttpTraceContext, - WWWServerTraceProvider::ANCM, - 4 ); //Verbosity + return WWWServerTraceProvider::CheckTracingEnabled( + pHttpTraceContext, + WWWServerTraceProvider::ANCM, + 4); //Verbosity }; }; // @@ -355,24 +359,24 @@ public: // EventType: 5 // EventLevel: 2 // - + class ANCM_REQUEST_FORWARD_FAIL { public: static - HRESULT - RaiseEvent( - IHttpTraceContext * pHttpTraceContext, - LPCGUID pContextId, - ULONG ErrorCode - ) - // - // Raise ANCM_REQUEST_FORWARD_FAIL Event - // + HRESULT + RaiseEvent( + IHttpTraceContext * pHttpTraceContext, + LPCGUID pContextId, + ULONG ErrorCode + ) + // + // Raise ANCM_REQUEST_FORWARD_FAIL Event + // { HTTP_TRACE_EVENT Event; Event.pProviderGuid = WWWServerTraceProvider::GetProviderGuid(); - Event.dwArea = WWWServerTraceProvider::ANCM; + Event.dwArea = WWWServerTraceProvider::ANCM; Event.pAreaGuid = ANCMEvents::GetAreaGuid(); Event.dwEvent = 5; Event.pszEventName = L"ANCM_REQUEST_FORWARD_FAIL"; @@ -383,35 +387,35 @@ public: Event.pRelatedActivityGuid = NULL; Event.dwTimeStamp = 0; Event.dwFlags = HTTP_TRACE_EVENT_FLAG_STATIC_DESCRIPTIVE_FIELDS; - + // pActivityGuid, pRelatedActivityGuid, Timestamp to be filled in by IIS - - HTTP_TRACE_EVENT_ITEM Items[ 2 ]; - Items[ 0 ].pszName = L"ContextId"; - Items[ 0 ].dwDataType = HTTP_TRACE_TYPE_LPCGUID; // mof type (object) - Items[ 0 ].pbData = (PBYTE) pContextId; - Items[ 0 ].cbData = 16; - Items[ 0 ].pszDataDescription = NULL; - Items[ 1 ].pszName = L"ErrorCode"; - Items[ 1 ].dwDataType = HTTP_TRACE_TYPE_ULONG; // mof type (uint32) - Items[ 1 ].pbData = (PBYTE) &ErrorCode; - Items[ 1 ].cbData = 4; - Items[ 1 ].pszDataDescription = NULL; + + HTTP_TRACE_EVENT_ITEM Items[2]; + Items[0].pszName = L"ContextId"; + Items[0].dwDataType = HTTP_TRACE_TYPE_LPCGUID; // mof type (object) + Items[0].pbData = (PBYTE)pContextId; + Items[0].cbData = 16; + Items[0].pszDataDescription = NULL; + Items[1].pszName = L"ErrorCode"; + Items[1].dwDataType = HTTP_TRACE_TYPE_ULONG; // mof type (uint32) + Items[1].pbData = (PBYTE)&ErrorCode; + Items[1].cbData = 4; + Items[1].pszDataDescription = NULL; Event.pEventItems = Items; - pHttpTraceContext->RaiseTraceEvent( &Event ); + pHttpTraceContext->RaiseTraceEvent(&Event); return S_OK; }; - + static - BOOL - IsEnabled( - IHttpTraceContext * pHttpTraceContext ) - // Check if tracing for this event is enabled + BOOL + IsEnabled( + IHttpTraceContext * pHttpTraceContext) + // Check if tracing for this event is enabled { - return WWWServerTraceProvider::CheckTracingEnabled( - pHttpTraceContext, - WWWServerTraceProvider::ANCM, - 2 ); //Verbosity + return WWWServerTraceProvider::CheckTracingEnabled( + pHttpTraceContext, + WWWServerTraceProvider::ANCM, + 2); //Verbosity }; }; // @@ -421,24 +425,24 @@ public: // EventType: 6 // EventLevel: 4 // - + class ANCM_WINHTTP_CALLBACK { public: static - HRESULT - RaiseEvent( - IHttpTraceContext * pHttpTraceContext, - LPCGUID pContextId, - ULONG InternetStatus - ) - // - // Raise ANCM_WINHTTP_CALLBACK Event - // + HRESULT + RaiseEvent( + IHttpTraceContext * pHttpTraceContext, + LPCGUID pContextId, + ULONG InternetStatus + ) + // + // Raise ANCM_WINHTTP_CALLBACK Event + // { HTTP_TRACE_EVENT Event; Event.pProviderGuid = WWWServerTraceProvider::GetProviderGuid(); - Event.dwArea = WWWServerTraceProvider::ANCM; + Event.dwArea = WWWServerTraceProvider::ANCM; Event.pAreaGuid = ANCMEvents::GetAreaGuid(); Event.dwEvent = 6; Event.pszEventName = L"ANCM_WINHTTP_CALLBACK"; @@ -449,101 +453,467 @@ public: Event.pRelatedActivityGuid = NULL; Event.dwTimeStamp = 0; Event.dwFlags = HTTP_TRACE_EVENT_FLAG_STATIC_DESCRIPTIVE_FIELDS; - + // pActivityGuid, pRelatedActivityGuid, Timestamp to be filled in by IIS - - HTTP_TRACE_EVENT_ITEM Items[ 2 ]; - Items[ 0 ].pszName = L"ContextId"; - Items[ 0 ].dwDataType = HTTP_TRACE_TYPE_LPCGUID; // mof type (object) - Items[ 0 ].pbData = (PBYTE) pContextId; - Items[ 0 ].cbData = 16; - Items[ 0 ].pszDataDescription = NULL; - Items[ 1 ].pszName = L"InternetStatus"; - Items[ 1 ].dwDataType = HTTP_TRACE_TYPE_ULONG; // mof type (uint32) - Items[ 1 ].pbData = (PBYTE) &InternetStatus; - Items[ 1 ].cbData = 4; - Items[ 1 ].pszDataDescription = NULL; + + HTTP_TRACE_EVENT_ITEM Items[2]; + Items[0].pszName = L"ContextId"; + Items[0].dwDataType = HTTP_TRACE_TYPE_LPCGUID; // mof type (object) + Items[0].pbData = (PBYTE)pContextId; + Items[0].cbData = 16; + Items[0].pszDataDescription = NULL; + Items[1].pszName = L"InternetStatus"; + Items[1].dwDataType = HTTP_TRACE_TYPE_ULONG; // mof type (uint32) + Items[1].pbData = (PBYTE)&InternetStatus; + Items[1].cbData = 4; + Items[1].pszDataDescription = NULL; Event.pEventItems = Items; - pHttpTraceContext->RaiseTraceEvent( &Event ); + pHttpTraceContext->RaiseTraceEvent(&Event); return S_OK; }; - + static - BOOL - IsEnabled( - IHttpTraceContext * pHttpTraceContext ) - // Check if tracing for this event is enabled + BOOL + IsEnabled( + IHttpTraceContext * pHttpTraceContext) + // Check if tracing for this event is enabled { - return WWWServerTraceProvider::CheckTracingEnabled( - pHttpTraceContext, - WWWServerTraceProvider::ANCM, - 4 ); //Verbosity + return WWWServerTraceProvider::CheckTracingEnabled( + pHttpTraceContext, + WWWServerTraceProvider::ANCM, + 4); //Verbosity }; }; // - // Event: mof class name ANCMForwardEnd, - // Description: Inprocess executing request failure - // EventTypeName: ANCM_EXECUTE_REQUEST_FAIL - // EventType: 7 - // EventLevel: 2 + // Event: mof class name ANCMExecuteStart, + // Description: Starting inprocess execute request + // EventTypeName: ANCM_INPROC_EXECUTE_REQUEST_START + // EventType: 8 + // EventLevel: 4 // - - class ANCM_EXECUTE_REQUEST_FAIL + + class ANCM_INPROC_EXECUTE_REQUEST_START { public: static - HRESULT - RaiseEvent( - IHttpTraceContext * pHttpTraceContext, - LPCGUID pContextId, - ULONG ErrorCode - ) - // - // Raise ANCM_EXECUTE_REQUEST_FAIL Event - // + HRESULT + RaiseEvent( + IHttpTraceContext * pHttpTraceContext, + LPCGUID pContextId + ) + // + // Raise ANCM_INPROC_EXECUTE_REQUEST_START Event + // { HTTP_TRACE_EVENT Event; Event.pProviderGuid = WWWServerTraceProvider::GetProviderGuid(); - Event.dwArea = WWWServerTraceProvider::ANCM; + Event.dwArea = WWWServerTraceProvider::ANCM; Event.pAreaGuid = ANCMEvents::GetAreaGuid(); - Event.dwEvent = 7; - Event.pszEventName = L"ANCM_EXECUTE_REQUEST_FAIL"; + Event.dwEvent = 8; + Event.pszEventName = L"ANCM_INPROC_EXECUTE_REQUEST_START"; Event.dwEventVersion = 1; - Event.dwVerbosity = 2; + Event.dwVerbosity = 4; + Event.cEventItems = 1; + Event.pActivityGuid = NULL; + Event.pRelatedActivityGuid = NULL; + Event.dwTimeStamp = 0; + Event.dwFlags = HTTP_TRACE_EVENT_FLAG_STATIC_DESCRIPTIVE_FIELDS; + + // pActivityGuid, pRelatedActivityGuid, Timestamp to be filled in by IIS + + HTTP_TRACE_EVENT_ITEM Items[1]; + Items[0].pszName = L"ContextId"; + Items[0].dwDataType = HTTP_TRACE_TYPE_LPCGUID; // mof type (object) + Items[0].pbData = (PBYTE)pContextId; + Items[0].cbData = 16; + Items[0].pszDataDescription = NULL; + Event.pEventItems = Items; + pHttpTraceContext->RaiseTraceEvent(&Event); + return S_OK; + }; + + static + BOOL + IsEnabled( + IHttpTraceContext * pHttpTraceContext) + // Check if tracing for this event is enabled + { + return WWWServerTraceProvider::CheckTracingEnabled( + pHttpTraceContext, + WWWServerTraceProvider::ANCM, + 4); //Verbosity + }; + }; + // + // Event: mof class name ANCMExecuteEnd, + // Description: Ending inprocess execute request + // EventTypeName: ANCM_INPROC_EXECUTE_REQUEST_COMPLETION + // EventType: 10 + // EventLevel: 5 + // + + class ANCM_INPROC_EXECUTE_REQUEST_COMPLETION + { + public: + static + HRESULT + RaiseEvent( + IHttpTraceContext * pHttpTraceContext, + LPCGUID pContextId, + ULONG requestStatus + ) + // + // Raise ANCM_INPROC_EXECUTE_REQUEST_COMPLETION Event + // + { + HTTP_TRACE_EVENT Event; + Event.pProviderGuid = WWWServerTraceProvider::GetProviderGuid(); + Event.dwArea = WWWServerTraceProvider::ANCM; + Event.pAreaGuid = ANCMEvents::GetAreaGuid(); + Event.dwEvent = 10; + Event.pszEventName = L"ANCM_INPROC_EXECUTE_REQUEST_COMPLETION"; + Event.dwEventVersion = 1; + Event.dwVerbosity = 5; Event.cEventItems = 2; Event.pActivityGuid = NULL; Event.pRelatedActivityGuid = NULL; Event.dwTimeStamp = 0; Event.dwFlags = HTTP_TRACE_EVENT_FLAG_STATIC_DESCRIPTIVE_FIELDS; - + // pActivityGuid, pRelatedActivityGuid, Timestamp to be filled in by IIS - - HTTP_TRACE_EVENT_ITEM Items[ 2 ]; - Items[ 0 ].pszName = L"ContextId"; - Items[ 0 ].dwDataType = HTTP_TRACE_TYPE_LPCGUID; // mof type (object) - Items[ 0 ].pbData = (PBYTE) pContextId; - Items[ 0 ].cbData = 16; - Items[ 0 ].pszDataDescription = NULL; - Items[ 1 ].pszName = L"ErrorCode"; - Items[ 1 ].dwDataType = HTTP_TRACE_TYPE_ULONG; // mof type (uint32) - Items[ 1 ].pbData = (PBYTE) &ErrorCode; - Items[ 1 ].cbData = 4; - Items[ 1 ].pszDataDescription = NULL; + + HTTP_TRACE_EVENT_ITEM Items[2]; + Items[0].pszName = L"ContextId"; + Items[0].dwDataType = HTTP_TRACE_TYPE_LPCGUID; // mof type (object) + Items[0].pbData = (PBYTE)pContextId; + Items[0].cbData = 16; + Items[0].pszDataDescription = NULL; + Items[1].pszName = L"requestStatus"; + Items[1].dwDataType = HTTP_TRACE_TYPE_ULONG; // mof type (uint32) + Items[1].pbData = (PBYTE)&requestStatus; + Items[1].cbData = 4; + Items[1].pszDataDescription = NULL; Event.pEventItems = Items; - pHttpTraceContext->RaiseTraceEvent( &Event ); + pHttpTraceContext->RaiseTraceEvent(&Event); return S_OK; }; - + static - BOOL - IsEnabled( - IHttpTraceContext * pHttpTraceContext ) - // Check if tracing for this event is enabled + BOOL + IsEnabled( + IHttpTraceContext * pHttpTraceContext) + // Check if tracing for this event is enabled { - return WWWServerTraceProvider::CheckTracingEnabled( - pHttpTraceContext, - WWWServerTraceProvider::ANCM, - 2 ); //Verbosity + return WWWServerTraceProvider::CheckTracingEnabled( + pHttpTraceContext, + WWWServerTraceProvider::ANCM, + 5); //Verbosity + }; + }; + // + // Event: mof class name ANCMAsyncStart, + // Description: Starting inprocess async completion + // EventTypeName: ANCM_INPROC_ASYNC_COMPLETION_START + // EventType: 8 + // EventLevel: 5 + // + + class ANCM_INPROC_ASYNC_COMPLETION_START + { + public: + static + HRESULT + RaiseEvent( + IHttpTraceContext * pHttpTraceContext, + LPCGUID pContextId + ) + // + // Raise ANCM_INPROC_ASYNC_COMPLETION_START Event + // + { + HTTP_TRACE_EVENT Event; + Event.pProviderGuid = WWWServerTraceProvider::GetProviderGuid(); + Event.dwArea = WWWServerTraceProvider::ANCM; + Event.pAreaGuid = ANCMEvents::GetAreaGuid(); + Event.dwEvent = 8; + Event.pszEventName = L"ANCM_INPROC_ASYNC_COMPLETION_START"; + Event.dwEventVersion = 1; + Event.dwVerbosity = 5; + Event.cEventItems = 1; + Event.pActivityGuid = NULL; + Event.pRelatedActivityGuid = NULL; + Event.dwTimeStamp = 0; + Event.dwFlags = HTTP_TRACE_EVENT_FLAG_STATIC_DESCRIPTIVE_FIELDS; + + // pActivityGuid, pRelatedActivityGuid, Timestamp to be filled in by IIS + + HTTP_TRACE_EVENT_ITEM Items[1]; + Items[0].pszName = L"ContextId"; + Items[0].dwDataType = HTTP_TRACE_TYPE_LPCGUID; // mof type (object) + Items[0].pbData = (PBYTE)pContextId; + Items[0].cbData = 16; + Items[0].pszDataDescription = NULL; + Event.pEventItems = Items; + pHttpTraceContext->RaiseTraceEvent(&Event); + return S_OK; + }; + + static + BOOL + IsEnabled( + IHttpTraceContext * pHttpTraceContext) + // Check if tracing for this event is enabled + { + return WWWServerTraceProvider::CheckTracingEnabled( + pHttpTraceContext, + WWWServerTraceProvider::ANCM, + 5); //Verbosity + }; + }; + // + // Event: mof class name ANCMAsyncEnd, + // Description: Ending inprocess async completion + // EventTypeName: ANCM_INPROC_ASYNC_COMPLETION_COMPLETION + // EventType: 10 + // EventLevel: 5 + // + + class ANCM_INPROC_ASYNC_COMPLETION_COMPLETION + { + public: + static + HRESULT + RaiseEvent( + IHttpTraceContext * pHttpTraceContext, + LPCGUID pContextId, + ULONG requestStatus + ) + // + // Raise ANCM_INPROC_ASYNC_COMPLETION_COMPLETION Event + // + { + HTTP_TRACE_EVENT Event; + Event.pProviderGuid = WWWServerTraceProvider::GetProviderGuid(); + Event.dwArea = WWWServerTraceProvider::ANCM; + Event.pAreaGuid = ANCMEvents::GetAreaGuid(); + Event.dwEvent = 10; + Event.pszEventName = L"ANCM_INPROC_ASYNC_COMPLETION_COMPLETION"; + Event.dwEventVersion = 1; + Event.dwVerbosity = 5; + Event.cEventItems = 2; + Event.pActivityGuid = NULL; + Event.pRelatedActivityGuid = NULL; + Event.dwTimeStamp = 0; + Event.dwFlags = HTTP_TRACE_EVENT_FLAG_STATIC_DESCRIPTIVE_FIELDS; + + // pActivityGuid, pRelatedActivityGuid, Timestamp to be filled in by IIS + + HTTP_TRACE_EVENT_ITEM Items[2]; + Items[0].pszName = L"ContextId"; + Items[0].dwDataType = HTTP_TRACE_TYPE_LPCGUID; // mof type (object) + Items[0].pbData = (PBYTE)pContextId; + Items[0].cbData = 16; + Items[0].pszDataDescription = NULL; + Items[1].pszName = L"requestStatus"; + Items[1].dwDataType = HTTP_TRACE_TYPE_ULONG; // mof type (uint32) + Items[1].pbData = (PBYTE)&requestStatus; + Items[1].cbData = 4; + Items[1].pszDataDescription = NULL; + Event.pEventItems = Items; + pHttpTraceContext->RaiseTraceEvent(&Event); + return S_OK; + }; + + static + BOOL + IsEnabled( + IHttpTraceContext * pHttpTraceContext) + // Check if tracing for this event is enabled + { + return WWWServerTraceProvider::CheckTracingEnabled( + pHttpTraceContext, + WWWServerTraceProvider::ANCM, + 5); //Verbosity + }; + }; + // + // Event: mof class name ANCMRequestShutdown, + // Description: Inprocess app shutdown + // EventTypeName: ANCM_INPROC_REQUEST_SHUTDOWN + // EventType: 11 + // EventLevel: 4 + // + + class ANCM_INPROC_REQUEST_SHUTDOWN + { + public: + static + HRESULT + RaiseEvent( + IHttpTraceContext * pHttpTraceContext, + LPCGUID pContextId + ) + // + // Raise ANCM_INPROC_REQUEST_SHUTDOWN Event + // + { + HTTP_TRACE_EVENT Event; + Event.pProviderGuid = WWWServerTraceProvider::GetProviderGuid(); + Event.dwArea = WWWServerTraceProvider::ANCM; + Event.pAreaGuid = ANCMEvents::GetAreaGuid(); + Event.dwEvent = 11; + Event.pszEventName = L"ANCM_INPROC_REQUEST_SHUTDOWN"; + Event.dwEventVersion = 1; + Event.dwVerbosity = 4; + Event.cEventItems = 1; + Event.pActivityGuid = NULL; + Event.pRelatedActivityGuid = NULL; + Event.dwTimeStamp = 0; + Event.dwFlags = HTTP_TRACE_EVENT_FLAG_STATIC_DESCRIPTIVE_FIELDS; + + // pActivityGuid, pRelatedActivityGuid, Timestamp to be filled in by IIS + + HTTP_TRACE_EVENT_ITEM Items[1]; + Items[0].pszName = L"ContextId"; + Items[0].dwDataType = HTTP_TRACE_TYPE_LPCGUID; // mof type (object) + Items[0].pbData = (PBYTE)pContextId; + Items[0].cbData = 16; + Items[0].pszDataDescription = NULL; + Event.pEventItems = Items; + pHttpTraceContext->RaiseTraceEvent(&Event); + return S_OK; + }; + + static + BOOL + IsEnabled( + IHttpTraceContext * pHttpTraceContext) + // Check if tracing for this event is enabled + { + return WWWServerTraceProvider::CheckTracingEnabled( + pHttpTraceContext, + WWWServerTraceProvider::ANCM, + 4); //Verbosity + }; + }; + // + // Event: mof class name ANCMRequestDisconnect, + // Description: Inprocess request disconnect + // EventTypeName: ANCM_INPROC_REQUEST_DISCONNECT + // EventType: 12 + // EventLevel: 4 + // + + class ANCM_INPROC_REQUEST_DISCONNECT + { + public: + static + HRESULT + RaiseEvent( + IHttpTraceContext * pHttpTraceContext, + LPCGUID pContextId + ) + // + // Raise ANCM_INPROC_REQUEST_DISCONNECT Event + // + { + HTTP_TRACE_EVENT Event; + Event.pProviderGuid = WWWServerTraceProvider::GetProviderGuid(); + Event.dwArea = WWWServerTraceProvider::ANCM; + Event.pAreaGuid = ANCMEvents::GetAreaGuid(); + Event.dwEvent = 12; + Event.pszEventName = L"ANCM_INPROC_REQUEST_DISCONNECT"; + Event.dwEventVersion = 1; + Event.dwVerbosity = 4; + Event.cEventItems = 1; + Event.pActivityGuid = NULL; + Event.pRelatedActivityGuid = NULL; + Event.dwTimeStamp = 0; + Event.dwFlags = HTTP_TRACE_EVENT_FLAG_STATIC_DESCRIPTIVE_FIELDS; + + // pActivityGuid, pRelatedActivityGuid, Timestamp to be filled in by IIS + + HTTP_TRACE_EVENT_ITEM Items[1]; + Items[0].pszName = L"ContextId"; + Items[0].dwDataType = HTTP_TRACE_TYPE_LPCGUID; // mof type (object) + Items[0].pbData = (PBYTE)pContextId; + Items[0].cbData = 16; + Items[0].pszDataDescription = NULL; + Event.pEventItems = Items; + pHttpTraceContext->RaiseTraceEvent(&Event); + return S_OK; + }; + + static + BOOL + IsEnabled( + IHttpTraceContext * pHttpTraceContext) + // Check if tracing for this event is enabled + { + return WWWServerTraceProvider::CheckTracingEnabled( + pHttpTraceContext, + WWWServerTraceProvider::ANCM, + 4); //Verbosity + }; + }; + // + // Event: mof class name ANCMManagedRequestCompletion, + // Description: Indicate managed request complete + // EventTypeName: ANCM_INPROC_MANAGED_REQUEST_COMPLETION + // EventType: 12 + // EventLevel: 4 + // + + class ANCM_INPROC_MANAGED_REQUEST_COMPLETION + { + public: + static + HRESULT + RaiseEvent( + IHttpTraceContext * pHttpTraceContext, + LPCGUID pContextId + ) + // + // Raise ANCM_INPROC_MANAGED_REQUEST_COMPLETION Event + // + { + HTTP_TRACE_EVENT Event; + Event.pProviderGuid = WWWServerTraceProvider::GetProviderGuid(); + Event.dwArea = WWWServerTraceProvider::ANCM; + Event.pAreaGuid = ANCMEvents::GetAreaGuid(); + Event.dwEvent = 12; + Event.pszEventName = L"ANCM_INPROC_MANAGED_REQUEST_COMPLETION"; + Event.dwEventVersion = 1; + Event.dwVerbosity = 4; + Event.cEventItems = 1; + Event.pActivityGuid = NULL; + Event.pRelatedActivityGuid = NULL; + Event.dwTimeStamp = 0; + Event.dwFlags = HTTP_TRACE_EVENT_FLAG_STATIC_DESCRIPTIVE_FIELDS; + + // pActivityGuid, pRelatedActivityGuid, Timestamp to be filled in by IIS + + HTTP_TRACE_EVENT_ITEM Items[1]; + Items[0].pszName = L"ContextId"; + Items[0].dwDataType = HTTP_TRACE_TYPE_LPCGUID; // mof type (object) + Items[0].pbData = (PBYTE)pContextId; + Items[0].cbData = 16; + Items[0].pszDataDescription = NULL; + Event.pEventItems = Items; + pHttpTraceContext->RaiseTraceEvent(&Event); + return S_OK; + }; + + static + BOOL + IsEnabled( + IHttpTraceContext * pHttpTraceContext) + // Check if tracing for this event is enabled + { + return WWWServerTraceProvider::CheckTracingEnabled( + pHttpTraceContext, + WWWServerTraceProvider::ANCM, + 4); //Verbosity }; }; }; diff --git a/src/AspNetCoreModuleV2/InProcessRequestHandler/InProcessRhStaticHtml.htm b/src/AspNetCoreModuleV2/InProcessRequestHandler/InProcessRhStaticHtml.htm index 4675db7cdb..b558d83d5e 100644 --- a/src/AspNetCoreModuleV2/InProcessRequestHandler/InProcessRhStaticHtml.htm +++ b/src/AspNetCoreModuleV2/InProcessRequestHandler/InProcessRhStaticHtml.htm @@ -35,7 +35,7 @@

For more information visit: - https://go.microsoft.com/fwlink/?LinkID=808681 + https://go.microsoft.com/fwlink/?LinkID=808681

diff --git a/src/AspNetCoreModuleV2/InProcessRequestHandler/dllmain.cpp b/src/AspNetCoreModuleV2/InProcessRequestHandler/dllmain.cpp index 49f2142fd4..aafb2c799f 100644 --- a/src/AspNetCoreModuleV2/InProcessRequestHandler/dllmain.cpp +++ b/src/AspNetCoreModuleV2/InProcessRequestHandler/dllmain.cpp @@ -17,6 +17,7 @@ #include "WebConfigConfigurationSource.h" #include "ConfigurationLoadException.h" #include "StartupExceptionApplication.h" +#include "aspnetcore_event.h" DECLARE_DEBUG_PRINT_OBJECT("aspnetcorev2_inprocess.dll"); diff --git a/src/AspNetCoreModuleV2/InProcessRequestHandler/inprocesshandler.cpp b/src/AspNetCoreModuleV2/InProcessRequestHandler/inprocesshandler.cpp index c8fc89956e..75d555e053 100644 --- a/src/AspNetCoreModuleV2/InProcessRequestHandler/inprocesshandler.cpp +++ b/src/AspNetCoreModuleV2/InProcessRequestHandler/inprocesshandler.cpp @@ -3,10 +3,10 @@ #include "inprocesshandler.h" #include "inprocessapplication.h" -#include "aspnetcore_event.h" #include "IOutputManager.h" #include "ShuttingDownApplication.h" #include "ntassert.h" +#include "ModuleTracer.h" ALLOC_CACHE_HANDLER * IN_PROCESS_HANDLER::sm_pAlloc = NULL; @@ -25,7 +25,8 @@ IN_PROCESS_HANDLER::IN_PROCESS_HANDLER( m_pRequestHandler(pRequestHandler), m_pRequestHandlerContext(pRequestHandlerContext), m_pAsyncCompletionHandler(pAsyncCompletion), - m_pDisconnectHandler(pDisconnectHandler) + m_pDisconnectHandler(pDisconnectHandler), + m_moduleTracer(pW3Context->GetTraceContext()) { } @@ -34,32 +35,11 @@ REQUEST_NOTIFICATION_STATUS IN_PROCESS_HANDLER::OnExecuteRequestHandler() { // FREB log - - if (ANCMEvents::ANCM_START_APPLICATION_SUCCESS::IsEnabled(m_pW3Context->GetTraceContext())) - { - ANCMEvents::ANCM_START_APPLICATION_SUCCESS::RaiseEvent( - m_pW3Context->GetTraceContext(), - NULL, - L"InProcess Application"); - } + m_moduleTracer.ExecuteRequestStart(); if (m_pRequestHandler == NULL) { - // - // return error as the application did not register callback - // - if (ANCMEvents::ANCM_EXECUTE_REQUEST_FAIL::IsEnabled(m_pW3Context->GetTraceContext())) - { - ANCMEvents::ANCM_EXECUTE_REQUEST_FAIL::RaiseEvent(m_pW3Context->GetTraceContext(), - NULL, - (ULONG)E_APPLICATION_ACTIVATION_EXEC_FAILURE); - } - - m_pW3Context->GetResponse()->SetStatus(500, - "Internal Server Error", - 0, - (ULONG)E_APPLICATION_ACTIVATION_EXEC_FAILURE); - + m_moduleTracer.ExecuteRequestEnd(RQ_NOTIFICATION_FINISH_REQUEST); return RQ_NOTIFICATION_FINISH_REQUEST; } else if (m_pApplication->QueryBlockCallbacksIntoManaged()) @@ -67,7 +47,9 @@ IN_PROCESS_HANDLER::OnExecuteRequestHandler() return ServerShutdownMessage(); } - return m_pRequestHandler(this, m_pRequestHandlerContext); + auto status = m_pRequestHandler(this, m_pRequestHandlerContext); + m_moduleTracer.ExecuteRequestEnd(status); + return status; } __override @@ -77,10 +59,13 @@ IN_PROCESS_HANDLER::OnAsyncCompletion( HRESULT hrCompletionStatus ) { + m_moduleTracer.AsyncCompletionStart(); + if (m_fManagedRequestComplete) { // means PostCompletion has been called and this is the associated callback. - return m_requestNotificationStatus; + m_moduleTracer.AsyncCompletionEnd(m_requestNotificationStatus); + return m_requestNotificationStatus; } if (m_pApplication->QueryBlockCallbacksIntoManaged()) { @@ -92,11 +77,15 @@ IN_PROCESS_HANDLER::OnAsyncCompletion( assert(m_pManagedHttpContext != nullptr); // Call the managed handler for async completion. - return m_pAsyncCompletionHandler(m_pManagedHttpContext, hrCompletionStatus, cbCompletion); + + auto status = m_pAsyncCompletionHandler(m_pManagedHttpContext, hrCompletionStatus, cbCompletion); + m_moduleTracer.AsyncCompletionEnd(status); + return status; } -REQUEST_NOTIFICATION_STATUS IN_PROCESS_HANDLER::ServerShutdownMessage() const +REQUEST_NOTIFICATION_STATUS IN_PROCESS_HANDLER::ServerShutdownMessage() { + m_moduleTracer.RequestShutdown(); return ShuttingDownHandler::ServerShutdownMessage(m_pW3Context); } @@ -109,6 +98,8 @@ IN_PROCESS_HANDLER::NotifyDisconnect() return; } + m_moduleTracer.RequestDisconnect(); + assert(m_pManagedHttpContext != nullptr); m_pDisconnectHandler(m_pManagedHttpContext); } @@ -120,6 +111,7 @@ IN_PROCESS_HANDLER::IndicateManagedRequestComplete( { m_fManagedRequestComplete = TRUE; m_pManagedHttpContext = nullptr; + m_moduleTracer.ManagedCompletion(); } VOID diff --git a/src/AspNetCoreModuleV2/InProcessRequestHandler/inprocesshandler.h b/src/AspNetCoreModuleV2/InProcessRequestHandler/inprocesshandler.h index c1fae5dfc7..177c25e329 100644 --- a/src/AspNetCoreModuleV2/InProcessRequestHandler/inprocesshandler.h +++ b/src/AspNetCoreModuleV2/InProcessRequestHandler/inprocesshandler.h @@ -7,6 +7,7 @@ #include #include "iapplication.h" #include "inprocessapplication.h" +#include "ModuleTracer.h" class IN_PROCESS_APPLICATION; @@ -71,7 +72,7 @@ public: private: REQUEST_NOTIFICATION_STATUS - ServerShutdownMessage() const; + ServerShutdownMessage(); PVOID m_pManagedHttpContext; BOOL m_fManagedRequestComplete; @@ -83,4 +84,5 @@ private: PFN_ASYNC_COMPLETION_HANDLER m_pAsyncCompletionHandler; PFN_DISCONNECT_HANDLER m_pDisconnectHandler; static ALLOC_CACHE_HANDLER * sm_pAlloc; + ModuleTracer m_moduleTracer; }; diff --git a/src/Microsoft.AspNetCore.Server.IntegrationTesting.IIS/IISDeploymentParameterExtensions.cs b/src/Microsoft.AspNetCore.Server.IntegrationTesting.IIS/IISDeploymentParameterExtensions.cs index 594e373b08..61ab2a323f 100644 --- a/src/Microsoft.AspNetCore.Server.IntegrationTesting.IIS/IISDeploymentParameterExtensions.cs +++ b/src/Microsoft.AspNetCore.Server.IntegrationTesting.IIS/IISDeploymentParameterExtensions.cs @@ -61,6 +61,77 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS WebConfigHelpers.AddOrModifyAspNetCoreSection("stdoutLogFile", Path.Combine(path, "std"))); } + public static void EnableFreb(this IISDeploymentParameters deploymentParameters, string verbosity, string folderPath) + { + if (!deploymentParameters.PublishApplicationBeforeDeployment) + { + throw new InvalidOperationException("Testing freb requires site to be published."); + } + + deploymentParameters.EnableModule("FailedRequestsTracingModule", "%IIS_BIN%\\iisfreb.dll"); + + // Set the TraceFailedRequestsSection to listend to ANCM events + deploymentParameters.ServerConfigActionList.Add( + (element, _) => + { + var webServerElement = element + .RequiredElement("system.webServer"); + + var addElement = webServerElement + .GetOrAdd("tracing") + .GetOrAdd("traceFailedRequests") + .GetOrAdd("add"); + + addElement.SetAttributeValue("path", "*"); + + addElement.GetOrAdd("failureDefinitions") + .SetAttributeValue("statusCodes", "200-999"); + + var traceAreasElement = addElement + .GetOrAdd("traceAreas"); + var innerAddElement = traceAreasElement.GetOrAdd("add", "provider", "WWW Server"); + + innerAddElement.SetAttributeValue("areas", "ANCM"); + innerAddElement.SetAttributeValue("verbosity", verbosity); + }); + + // Set the ANCM traceProviderDefinition to 65536 + deploymentParameters.ServerConfigActionList.Add( + (element, _) => + { + var webServerElement = element + .RequiredElement("system.webServer"); + + var traceProviderDefinitionsElement = webServerElement + .GetOrAdd("tracing") + .GetOrAdd("traceProviderDefinitions"); + + var innerAddElement = traceProviderDefinitionsElement.GetOrAdd("add", "name", "WWW Server"); + + innerAddElement.SetAttributeValue("name", "WWW Server"); + innerAddElement.SetAttributeValue("guid", "{3a2a4e84-4c21-4981-ae10-3fda0d9b0f83}"); + + var areasElement = innerAddElement.GetOrAdd("areas"); + var iae = areasElement.GetOrAdd("add", "name", "ANCM"); + + iae.SetAttributeValue("value", "65536"); + }); + + // Set the freb directory to the published app directory. + deploymentParameters.ServerConfigActionList.Add( + (element, contentRoot) => + { + var traceFailedRequestsElement = element + .RequiredElement("system.applicationHost") + .Element("sites") + .Element("siteDefaults") + .Element("traceFailedRequestsLogging"); + traceFailedRequestsElement.SetAttributeValue("directory", folderPath); + traceFailedRequestsElement.SetAttributeValue("enabled", "true"); + traceFailedRequestsElement.SetAttributeValue("maxLogFileSizeKB", "1024"); + }); + } + public static void TransformPath(this IISDeploymentParameters parameters, Func transformation) { parameters.WebConfigActionList.Add( @@ -89,7 +160,8 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS } parameters.ServerConfigActionList.Add( - (element, _) => { + (element, _) => + { var webServerElement = element .RequiredElement("system.webServer"); diff --git a/test/Common.FunctionalTests/Inprocess/FrebTests.cs b/test/Common.FunctionalTests/Inprocess/FrebTests.cs new file mode 100644 index 0000000000..cf9d423ea1 --- /dev/null +++ b/test/Common.FunctionalTests/Inprocess/FrebTests.cs @@ -0,0 +1,118 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Xml.Linq; +using Microsoft.AspNetCore.Server.IIS.FunctionalTests.Utilities; +using Microsoft.AspNetCore.Server.IntegrationTesting; +using Microsoft.AspNetCore.Server.IntegrationTesting.IIS; +using Microsoft.AspNetCore.Testing.xunit; +using Microsoft.Extensions.Logging; +using Xunit; + +namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests +{ + [Collection(PublishedSitesCollection.Name)] + public class FrebTests : LogFileTestBase + { + private readonly PublishedSitesFixture _fixture; + public FrebTests(PublishedSitesFixture fixture) + { + _fixture = fixture; + } + + public static ISet FrebChecks() + { + var set = new HashSet(); + set.Add(new string[] { "ANCM_INPROC_EXECUTE_REQUEST_START" }); + set.Add(new string[] { "ANCM_INPROC_EXECUTE_REQUEST_COMPLETION", "1" }); + set.Add(new string[] { "ANCM_INPROC_ASYNC_COMPLETION_START" }); + set.Add(new string[] { "ANCM_INPROC_ASYNC_COMPLETION_COMPLETION", "0" }); + set.Add(new string[] { "ANCM_INPROC_MANAGED_REQUEST_COMPLETION" }); + return set; + } + + [ConditionalFact] + [RequiresIIS(IISCapability.FailedRequestTracingModule)] + public async Task CheckCommonFrebEvents() + { + var result = await SetupFrebApp(); + + await result.HttpClient.GetAsync("HelloWorld"); + + StopServer(); + + foreach (var data in FrebChecks()) + { + AssertFrebLogs(result, data); + } + } + + [ConditionalFact] + [RequiresIIS(IISCapability.FailedRequestTracingModule)] + public async Task CheckFailedRequestEvents() + { + var result = await SetupFrebApp(); + + await result.HttpClient.GetAsync("Throw"); + + StopServer(); + + AssertFrebLogs(result, "ANCM_INPROC_ASYNC_COMPLETION_COMPLETION", "2"); + } + + [ConditionalFact] + [RequiresIIS(IISCapability.FailedRequestTracingModule)] + public async Task CheckFrebDisconnect() + { + var result = await SetupFrebApp(); + + using (var connection = new TestConnection(result.HttpClient.BaseAddress.Port)) + { + await connection.Send( + "GET /WaitForAbort HTTP/1.1", + "Host: localhost", + "Connection: close", + "", + ""); + await result.HttpClient.RetryRequestAsync("/WaitingRequestCount", async message => await message.Content.ReadAsStringAsync() == "1"); + } + + StopServer(); + + AssertFrebLogs(result, "ANCM_INPROC_REQUEST_DISCONNECT"); + } + + private async Task SetupFrebApp() + { + var parameters = _fixture.GetBaseDeploymentParameters(publish: true); + parameters.EnableFreb("Verbose", _logFolderPath); + + Directory.CreateDirectory(_logFolderPath); + var result = await DeployAsync(parameters); + return result; + } + + private void AssertFrebLogs(IISDeploymentResult result, params string[] data) + { + var folderPath = Helpers.GetFrebFolder(_logFolderPath, result); + var fileString = Directory.GetFiles(folderPath).Where(f => f.EndsWith("xml")).OrderBy(x => x).Last(); + + var xDocument = XDocument.Load(fileString).Root; + var nameSpace = (XNamespace)"http://schemas.microsoft.com/win/2004/08/events/event"; + var elements = xDocument.Descendants(nameSpace + "Event"); + var element = elements.Where(el => el.Descendants(nameSpace + "RenderingInfo").Single().Descendants(nameSpace + "Opcode").Single().Value == data[0]); + + Assert.Single(element); + + if (data.Length > 1) + { + var requestStatus = element.Single().Element(nameSpace + "EventData").Descendants().Where(el => el.Attribute("Name").Value == "requestStatus").Single(); + Assert.Equal(data[1], requestStatus.Value); + } + } + } +} diff --git a/test/Common.FunctionalTests/Utilities/Helpers.cs b/test/Common.FunctionalTests/Utilities/Helpers.cs index 87cb5c5898..f3cf2ba70d 100644 --- a/test/Common.FunctionalTests/Utilities/Helpers.cs +++ b/test/Common.FunctionalTests/Utilities/Helpers.cs @@ -63,6 +63,18 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests await Task.WhenAll(tasks); } + public static string GetFrebFolder(string folder, IISDeploymentResult result) + { + if (result.DeploymentParameters.ServerType == ServerType.IISExpress) + { + return Path.Combine(folder, result.DeploymentParameters.SiteName); + } + else + { + return Path.Combine(folder, "W3SVC1"); + } + } + public static void CopyFiles(DirectoryInfo source, DirectoryInfo target, ILogger logger) { foreach (DirectoryInfo directoryInfo in source.GetDirectories()) @@ -113,6 +125,27 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests return response; } + public static async Task Retry(Func func, int attempts, int msDelay) + { + var exceptions = new List(); + + for (var attempt = 0; attempt < attempts; attempt++) + { + try + { + await func(); + return; + } + catch (Exception e) + { + exceptions.Add(e); + } + await Task.Delay(msDelay); + } + + throw new AggregateException(exceptions); + } + public static void AssertWorkerProcessStop(this IISDeploymentResult deploymentResult, int? timeout = null) { var hostProcess = deploymentResult.HostProcess; diff --git a/test/Common.FunctionalTests/Utilities/IISCapability.cs b/test/Common.FunctionalTests/Utilities/IISCapability.cs index 30c270fa77..750326cb5d 100644 --- a/test/Common.FunctionalTests/Utilities/IISCapability.cs +++ b/test/Common.FunctionalTests/Utilities/IISCapability.cs @@ -15,6 +15,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests ShutdownToken = 8, DynamicCompression = 16, ApplicationInitialization = 32, - TracingModule = 64 + TracingModule = 64, + FailedRequestTracingModule = 128 } } diff --git a/test/IIS.FunctionalTests/RequiresIISAttribute.cs b/test/IIS.FunctionalTests/RequiresIISAttribute.cs index f78de73d47..2aacfed0db 100644 --- a/test/IIS.FunctionalTests/RequiresIISAttribute.cs +++ b/test/IIS.FunctionalTests/RequiresIISAttribute.cs @@ -24,6 +24,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests private static readonly bool _dynamicCompressionAvailable; private static readonly bool _applicationInitializationModule; private static readonly bool _tracingModuleAvailable; + private static readonly bool _frebTracingModuleAvailable; static RequiresIISAttribute() { @@ -90,6 +91,9 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests _tracingModuleAvailable = File.Exists(Path.Combine(Environment.SystemDirectory, "inetsrv", "iisetw.dll")); + _frebTracingModuleAvailable = File.Exists(Path.Combine(Environment.SystemDirectory, "inetsrv", "iisfreb.dll")); + + var iisRegistryKey = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\InetStp", writable: false); if (iisRegistryKey == null) { @@ -161,12 +165,22 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests } } + if (capabilities.HasFlag(IISCapability.TracingModule)) { IsMet &= _tracingModuleAvailable; if (!_tracingModuleAvailable) { - SkipReason += "The machine does not have IIS TracingModule installed."; + SkipReason += "The machine does not have IIS Failed Request Tracing Module installed."; + } + } + + if (capabilities.HasFlag(IISCapability.FailedRequestTracingModule)) + { + IsMet &= _frebTracingModuleAvailable; + if (!_frebTracingModuleAvailable) + { + SkipReason += "The machine does not have IIS Failed Request Tracing Module installed."; } } } diff --git a/test/IISExpress.FunctionalTests/OutOfProcess/MultipleAppTests.cs b/test/IISExpress.FunctionalTests/OutOfProcess/MultipleAppTests.cs index cc270d9afa..349f72d7bf 100644 --- a/test/IISExpress.FunctionalTests/OutOfProcess/MultipleAppTests.cs +++ b/test/IISExpress.FunctionalTests/OutOfProcess/MultipleAppTests.cs @@ -38,7 +38,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests // ANCM v2 does retry on port collisions, so no retries should be required. var attempts = (ancmVersion == AncmVersion.AspNetCoreModule) ? 2 : 1; - return Retry(async () => + return Helpers.Retry(async () => { const int numApps = 10; @@ -75,27 +75,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests } } }, - attempts: attempts); - } - - private async Task Retry(Func func, int attempts) - { - var exceptions = new List(); - - for (var attempt = 0; attempt < attempts; attempt++) - { - try - { - await func(); - return; - } - catch (Exception e) - { - exceptions.Add(e); - } - } - - throw new AggregateException(exceptions); + attempts: attempts, msDelay: 0); } } }