HTTP_TRACE_EVENT Structure
Contains tracing information returned from trace providers.
Syntax
struct HTTP_TRACE_EVENT{
LPCGUID pProviderGuid;
DWORD dwArea;
LPCGUID pAreaGuid;
DWORD dwEvent;
LPCWSTR pszEventName;
DWORD dwEventVersion;
DWORD dwVerbosity;
LPCGUID pActivityGuid;
LPCGUID pRelatedActivityGuid;
DWORD dwTimeStamp;
DWORD dwFlags;
DWORD cEventItems;
__field_ecount(cEventItems) HTTP_TRACE_EVENT_ITEM * pEventItems;
};
Members
Member name | Description |
---|---|
pProviderGuid |
An LPCGUID that contains the identifier of the provider. Possible values include, but are not limited to, the values in the Tracing GUIDs section defined in Tracing Constants. |
dwArea |
A DWORD that contains the area of interest for the event. The area value should be a positive integer. |
pAreaGuid |
A LPCGUID that indicates the area of interest. |
dwEvent |
A DWORD that contains the unique identifier of the event for the event provider. |
pszEventName |
A LPCWSTR that contains the name of the event. This value is set by the event provider to give a description of the event type. |
dwEventVersion |
A DWORD that contains the event version. Usually 0 or 1, but can contain any nonnegative integer value. |
dwVerbosity |
A DWORD that maps numerical values to their verbose counterparts (the values 0 through 5 map to General, FatalError, Error, Warning, Info, and Verbose). |
pActivityGuid |
A LPCGUID that contains the unique request identifier. |
pRelatedActivityGuid |
A LPCGUID that contains a value for associating related activities. Most providers set this value to NULL and then allow IIS to populate the value before sending the event to event listeners. |
dwTimeStamp |
A DWORD that contains the optional time stamp, represented by an internal tick count. |
dwFlags |
A DWORD that contains additional flags. Most providers set this value to HTTP_TRACE_EVENT_FLAG_STATIC_DESCRIPTIVE_FIELDS, described in the Tracing Constants section defined in Tracing Constants. |
cEventItems |
A DWORD that contains the number of elements in the pEventItems array. |
pEventItems |
An array of HTTP_TRACE_EVENT_ITEM Structure structures of length cEventItems . |
Remarks
Most of the members of the HTTP_TRACE_EVENT
structure map directly to Event Tracing for Windows (ETW) events. The dwArea
and pAreaGuid
members are unique to IIS.
CGlobalModule derived classes that register for GL_TRACE_EVENT event types receive an IGlobalTraceEventProvider pointer as a parameter on the CGlobalModule::OnGlobalTraceEvent pure virtual
method. You can then retrieve an HTTP_TRACE_EVENT
pointer by calling the IGlobalTraceEventProvider::GetTraceEvent method, for which you supply a pointer to the address of a NULL HTTP_TRACE_EVENT
structure.
For more information, see Tracing Constants.
The dwArea
and pAreaGuid
members contain two different constants for the area of interest for an event.
Example
The following example populates the HTTP_TRACE_EVENT
structure and calls the IHttpTraceContext::RaiseTraceEvent method.
REQUEST_NOTIFICATION_STATUS
CMyHttpModule::OnBeginRequest(
IHttpContext* pHttpContext,
IHttpEventProvider* pProvider
)
{
HRESULT hr;
static long cnt;
InterlockedIncrement(&cnt); // keep track of how many times we are called
cnt++;
IHttpRequest *pRequest = pHttpContext->GetRequest();
PCWSTR url = pRequest->GetRawHttpRequest()->CookedUrl.pAbsPath;
OutputDebugStringW(url);
// return unless requesting a HTML file
if (!wcsstr(url, L".htm"))
return RQ_NOTIFICATION_CONTINUE;
IHttpResponse * pHttpResponse = pHttpContext->GetResponse();
// Return most times so we can still view content
if ((cnt % 5) || pHttpResponse == NULL)
return RQ_NOTIFICATION_CONTINUE;
TRC_MSG_FULL("HTML cnt = " << cnt);
static int insertPosCnt;
int insertPos = ++insertPosCnt % 2 - 1; // toggle between 0 and -1
// Use ostringstream to create some dynamic content
std::ostringstream os;
os << "<p /> first chunk callback count = " << cnt
<< " insertPos = " << insertPos << "<br />";
//
// WECbyRefChunk does all the work of inserting data into the response
//
hr = WECbyRefChunk(os, pHttpContext, pProvider, insertPos);
if (FAILED(hr))
return RQ_NOTIFICATION_FINISH_REQUEST;
os << "<br /> <b> Adding 2nd chunk in Bold </b> File insertPos = " << insertPos;
hr = WECbyRefChunk(os, pHttpContext, pProvider, insertPos);
if (FAILED(hr))
return RQ_NOTIFICATION_FINISH_REQUEST;
os << " <p /> Last (3rd) Chunk added with default append chunk GetCurrentThreadId = "
<< GetCurrentThreadId();
// any errors will be logged/handled in WECbyRefChunk
WECbyRefChunk(os, pHttpContext, pProvider);
// End additional processing, not because of error, but so another request
// (from a GIF or .css style sheet on the same HTML page)
// doesn't wipe out our WriteEntityChunkByReference. We can also get the
// WriteEntityChunkByReference prepended to our normal HTML page.
return RQ_NOTIFICATION_FINISH_REQUEST;
}
class My_Events
{
public:
static LPCGUID GetAreaGuid( VOID ){ // GUID for the event class
static const GUID AreaGuid =
{0xacade3b2,0xb7d7,0x4339,{0x95,0x6c,0x81,0x1b,0x4e,0xdb,0x1b,0x24}};
return &AreaGuid;
};
static LPCGUID GetProviderGuid( VOID ){ // GUID for the event Provider
static const GUID PrvderGuid =
// {EB881638-214A-4f2a-9B39-933770822D18}
{ 0xeb881638, 0x214a, 0x4f2a, { 0x9b, 0x39, 0x93, 0x37, 0x70, 0x82, 0x2d, 0x18 } };
;
return &PrvderGuid;
};
class My_COMPLETION
{
public:
static HRESULT RaiseEvent(
IHttpTraceContext * pHttpTraceContext,
LONG InsertPosition
)
//
// Raise Cmy_COMPLETION Event
//
{
HTTP_TRACE_EVENT Event;
Event.pProviderGuid = My_Events::GetProviderGuid();
Event.dwArea = 1;
Event.pAreaGuid = My_Events::GetAreaGuid();
Event.dwEvent = 1;
Event.pszEventName = L"NOTIFY_MY_CSTM_WECBR_EVNT";
Event.dwEventVersion = 2;
Event.dwVerbosity = 1;
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"InsertPosition";
Items[ 0 ].dwDataType = HTTP_TRACE_TYPE_LONG; // mof type (object)
#pragma warning (disable:4312)
Items[ 0 ].pbData = (PBYTE) InsertPosition;
Items[ 0 ].cbData = 4;
Items[ 0 ].pszDataDescription = L"Insert Position";
Event.pEventItems = Items;
return pHttpTraceContext->RaiseTraceEvent( &Event );
};
};
};
If failed-request tracing is properly configured, you will see the NOTIFY_MODULE_START
and NOTIFY_MODULE_END
events in the trace log. For more information about logging failed requests, see Configuring Tracing for Failed Requests in IIS 7.0. The XML below is the NOTIFY_MODULE_START
portion of the Failed Request Tracing log. Most of the data is system dependent and will not match the event below.
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="WWW Server" Guid="{3A2A4E84-4C21-4981-AE10-3FDA0D9B0F83}"/>
<EventID>0</EventID>
<Version>1</Version>
<Level>5</Level>
<Opcode>1</Opcode>
<Keywords>0x100</Keywords>
<TimeCreated SystemTime="2007-08-27T21:10:30.186Z"/>
<Correlation ActivityID="{00000000-0000-0000-9800-0080000000FA}"/>
<Execution ProcessID="1308" ThreadID="3608"/>
<Computer>N2-IIS</Computer>
</System>
<EventData>
<Data Name="ContextId">{00000000-0000-0000-9800-0080000000FA}</Data>
<Data Name="ModuleName">A_raizeEvent</Data>
<Data Name="Notification">1</Data>
<Data Name="fIsPostNotification">false</Data>
<Data Name="fIsCompletion">false</Data>
</EventData>
<RenderingInfo Culture="en-US">
<Opcode>NOTIFY_MODULE_START</Opcode>
<Keywords>
<Keyword>RequestNotifications</Keyword>
</Keywords>
<freb:Description Data="Notification">BEGIN_REQUEST</freb:Description>
</RenderingInfo>
<ExtendedTracingInfo xmlns="http://schemas.microsoft.com/win/2004/08/events/trace">
<EventGuid>{002E91E3-E7AE-44AB-8E07-99230FFA6ADE}</EventGuid>
</ExtendedTracingInfo>
</Event>
Requirements
Type | Description |
---|---|
Client | - IIS 7.0 on Windows Vista - IIS 7.5 on Windows 7 - IIS 8.0 on Windows 8 - IIS 10.0 on Windows 10 |
Server | - IIS 7.0 on Windows Server 2008 - IIS 7.5 on Windows Server 2008 R2 - IIS 8.0 on Windows Server 2012 - IIS 8.5 on Windows Server 2012 R2 - IIS 10.0 on Windows Server 2016 |
Product | - IIS 7.0, IIS 7.5, IIS 8.0, IIS 8.5, IIS 10.0 - IIS Express 7.5, IIS Express 8.0, IIS Express 10.0 |
Header | Httptrace.h |