This project is read-only.

Keywords.TransfersOnly is not defined publicly for Activity tracing

Topics: Using
Jan 31, 2015 at 6:33 PM
Edited Jan 31, 2015 at 6:35 PM
https://slab.codeplex.com/wikipage?title=ActivityTracingAndSampling Recommends using System.Threading.Tasks.TplEventSource to enable tracking contexts across threads. It also recommends using Keywords.TransfersOnly, but this const isn't defined publicly anywhere. It is defined here: http://referencesource.microsoft.com/#mscorlib/system/threading/Tasks/TPLETWProvider.cs

Can someone correct the docs or provide the recommended way of tracing activities across thread contexts? Thanks.

Workaround:
        Type tplEtwProviderType = typeof(string).Assembly.GetType("System.Threading.Tasks.TplEtwProvider");
        Type keywordsType = tplEtwProviderType.GetNestedType("Keywords");
        FieldInfo taskTranfer = keywordsType.GetField("TaskTransfer");
        var fieldValue = taskTranfer.GetValue(null);

        listener.EnableEvents(
            "System.Threading.Tasks.TplEventSource",
            EventLevel.Informational,
            (EventKeywords)fieldValue);                     

Other links that recommend Keywords.TransfersOnly:

https://msdn.microsoft.com/en-us/library/dn775009%28v=pandp.20%29.aspx