Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow ETW to use thread's activity ID #286

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

helsaawy
Copy link
Contributor

This commit is contains several related changes that ultimately allow ETW events to set their activity ID to the current thread's value. By setting the thread's activity ID, win32 API calls from that thread will be able to access it and either continue using it or set it as the related activity ID, improving tracing on Windows.

Update mkwisyscall to import arbitrary other packages, so generated functions can types defined elsewhere.

Switch ETW functions to use guid.GUID instead of windows.GUID.

Add convenience IsEmpty function for GUIDs.

Add EventActivityIdControl function to manipulate the thread's activity ID, and related *ThreadActivityID functions to set the thread activity ID to a non-empty value.

Update writeEventRaw to only pass (related) activity ID to eventWriteTransfer if they are non-empty.

This is not a breaking change, since related activity ID will remain the same, and the activity ID will only be changed when not specified if InitializeThreadActivityID or SetThreadActivityID are called before-hand.

This commit is contains several related changes that ultimately allow
ETW events to set their activity ID to the current thread's value.
By setting the thread's activity ID, win32 API calls from that thread
will be able to access it and either continue using it or set it as the
related activity ID, improving tracing on Windows.

Update mkwisyscall to import arbitrary other packages, so generated
functions can types defined elsewhere.

Switch ETW functions to use `guid.GUID` instead of `windows.GUID`.

Add convenience `IsEmpty` function for GUIDs.

Add `EventActivityIdControl` function to manipulate the thread's
activity ID, and related `*ThreadActivityID` functions to set the
thread activity ID to a non-empty value.

Update `writeEventRaw` to only pass (related) activity ID to
`eventWriteTransfer` if they are non-empty.

This is not a breaking change, since related activity ID will remain
the same, and the activity ID will only be changed when not specified
if `InitializeThreadActivityID` or `SetThreadActivityID` are called
before-hand.

Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
@helsaawy helsaawy marked this pull request as ready for review April 27, 2023 15:49
@helsaawy helsaawy requested a review from a team as a code owner April 27, 2023 15:49
@kevpar
Copy link
Member

kevpar commented Apr 27, 2023

What is the motivation behind supporting thread activity ID? Our previous thinking has been this doesn't give much value given the nature of goroutines, and it makes more sense (and is more idiomatic Go) to just carry activity ID around in a context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants