etw

package
v0.78.0-rc.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 25, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Rendered for windows/amd64

Overview

Package etw provides utilities for Event Tracing for Windows (ETW): - StopETWSession: stop an ETW trace session by name - ProcessETLFile: read and process events from an ETL trace file - Event property parsing via GetEventPropertyString

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetEventPropertyString

func GetEventPropertyString(e *Event, name string) string

GetEventPropertyString returns the string value of a named property. GetPropertyString on Event provides the same functionality as a method.

func MustParseGUID

func MustParseGUID(s string) windows.GUID

MustParseGUID parses a GUID string (e.g. "{22FB2CD6-0E7B-422B-A0C7-2FAD1FD0E716}"). Panics if the string is invalid.

func ProcessETLFile

func ProcessETLFile(etlPath string, callback EventCallback, opts ...ProcessOption) error

ProcessETLFile reads an ETL file and invokes the callback for each event. Blocks until the file is fully processed or an error occurs.

func StopETWSession

func StopETWSession(sessionName string) error

StopETWSession stops an ETW trace session by name (e.g. an autologger session). Uses ControlTraceW with EVENT_TRACE_CONTROL_STOP.

Types

type Event

type Event struct {
	ProviderID windows.GUID
	EventID    uint16
	Timestamp  time.Time
	// contains filtered or unexported fields
}

Event represents a parsed ETW event from an ETL file. ProviderID, EventID, and Timestamp are available directly. Use EventProperties or GetEventPropertyString for event-specific data. The Event is only valid during the ProcessETLFile callback; do not use it after the callback returns.

func (*Event) EventProperties

func (e *Event) EventProperties() (map[string]interface{}, error)

EventProperties returns a map of property names to values for this event. Uses TDH (Trace Data Helper) to parse the event schema and user data.

func (*Event) GetEventID

func (e *Event) GetEventID() uint16

GetEventID returns the event's ID.

func (*Event) GetPropertyByName

func (e *Event) GetPropertyByName(name string) (string, error)

GetPropertyByName retrieves a single property by name using TdhGetProperty. Unlike GetPropertyString (which parses all properties sequentially), this directly looks up the named property and is resilient to schema mismatches in other properties within the same event.

func (*Event) GetPropertyString

func (e *Event) GetPropertyString(name string) string

GetPropertyString returns the string value of a named property. Implements the interface used by logonduration for event property access.

func (*Event) GetProviderID

func (e *Event) GetProviderID() windows.GUID

GetProviderID returns the event's provider GUID.

func (*Event) GetTimestamp

func (e *Event) GetTimestamp() time.Time

GetTimestamp returns the event's timestamp.

type EventCallback

type EventCallback func(event *Event)

EventCallback is called for each event that passes the filter (or all events if no filter).

type EventRecordFilter

type EventRecordFilter func(providerID windows.GUID, eventID uint16) bool

EventRecordFilter is an optional filter called for each raw event before parsing. Return true to process the event (call EventCallback), false to skip. Use for fast filtering by ProviderID and EventID to avoid parsing unwanted events.

type ProcessOption

type ProcessOption func(*ProcessOptions)

ProcessOption configures ProcessETLFile.

func WithEventRecordFilter

func WithEventRecordFilter(f EventRecordFilter) ProcessOption

WithEventRecordFilter sets a filter to skip events before parsing.

type ProcessOptions

type ProcessOptions struct {
	Filter EventRecordFilter
}

ProcessOptions configures ETL file processing.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL