필터 정의

공급자는 세션이 이벤트 데이터를 기반으로 이벤트를 필터링하는 데 사용하는 필터를 정의할 수 있습니다. ETW는 수준 및 키워드를 사용하여 이벤트가 로그에 기록되는지 여부를 결정합니다. 그러나 필터를 사용하면 공급자는 제어 세션이 전달하는 필터 데이터 조건을 사용하여( EnableCallback 함수 참조) 해당 세션에 이벤트를 쓰는지 여부를 결정합니다. 필터는 ETW 추적 세션에서 공급자를 사용하도록 설정하는 경우에만 적용됩니다.

일반적으로 공급자는 이벤트를 작성하고 세션은 수준 및 키워드를 사용하여 원하는 이벤트 유형을 식별합니다. 공급자가 이벤트 형식에 대한 데이터 필터를 정의한 경우 세션은 이를 사용하여 이벤트 데이터를 기반으로 해당 이벤트 형식에 대한 이벤트를 필터링할 수 있습니다(필터의 의미 체계는 공급자에 의해 정의됨). 예를 들어 공급자가 프로세스 이벤트를 생성하는 경우 프로세스 식별자를 기반으로 프로세스 이벤트를 필터링하는 데이터 필터를 정의할 수 있습니다. 그런 다음 세션은 프로세스 식별자를 필터 데이터로 공급자에 전달하고 해당 프로세스 식별자에 대한 프로세스 이벤트만 수신할 수 있습니다.

다음 예제에서는 필터 요소를 사용하여 필터 를 정의하는 방법을 보여줍니다. 필터의 이름 특성을 지정해야 합니다. 다른 특성은 선택 사항입니다. 필터에서 세션이 필터 데이터를 전달하도록 요구하는 경우 tid 특성이 필요합니다.

<instrumentationManifest
    xmlns="http://schemas.microsoft.com/win/2004/08/events" 
    xmlns:win="http://manifests.microsoft.com/win/2004/08/windows/events"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    >

    <instrumentation>
        <events>
            <provider name="Microsoft-Windows-SampleProvider"
                guid="{1db28f2e-8f80-4027-8c5a-a11f7f10f62d}"
                symbol="PROVIDER_GUID"
                resourceFileName="<path to the exe or dll that contains the metadata resources>"
                messageFileName="<path to the exe or dll that contains the string resources>"
                message="$(string.Provider.Name)">

                . . .

                <filters>
                    <filter name="Pid"
                            value="1"
                            tid="t1"
                            symbol="FILTER_PID"/>
                </filters>

                <templates>
                    <template tid="t1">
                        <data name="Pid" inType="win:UInt32"/>
                    </template>
                </templates>

                . . .

            </provider>
        </events>
    </instrumentation>

    <localization>
        <resources culture="en-US">
            <stringTable>
                <string id="Provider.Name" value="Sample Provider"/>
            </stringTable>
        </resources>
    </localization>

</instrumentationManifest>