DiagnosticSourceEventSource fixes/improvements for distributed tracing (dotnet/corefx...
authorNoah Falk <noahfalk@users.noreply.github.com>
Thu, 24 Oct 2019 19:29:54 +0000 (12:29 -0700)
committerGitHub <noreply@github.com>
Thu, 24 Oct 2019 19:29:54 +0000 (12:29 -0700)
commit13b9d5412c6f0ee4f1882cfa4986d9d5652a95e9
tree2924d450b37c6adb90a803084621bb643989750a
parent2bdbf50d2418a473f2cc9169fddd4aa74ec05914
DiagnosticSourceEventSource fixes/improvements for distributed tracing (dotnet/corefx#41943)

* DiagnosticSourceEventSource fixes for distributed tracing

1) There is no existing mechanism for DiagnosticSourceEventSource to fetch the current activity object. By convention it is not passed as an event argument, but rather stored in the async-local property Activity.Current. This was fixed by adding a well-known "*Activity" property that returns the result of Activity.Current regardless what object it is applied to.

2) DiagnosticSourceEventSource fails to evaluate properties on value types, such as DateTime.Ticks. Calling MethodInfo.CreateDelegate
needs to use a different signature for ref and value type properties and previously the code always used the ref-style signature. Fixed by adding ValueTypedFetchProperty that does the proper CreateDelegate and delegate invocation for structs.

3) There is no mechanism for DiagnosticSourceEventSource to enumerate the tags on an activity. This change adds the *Enumerate well-known property which will iterate any IEnumerable`1, invoke ToString() on each element, then join it as a string.

Commit migrated from https://github.com/dotnet/corefx/commit/ef563159787f3976ab47b9f304d58a7505828591
src/libraries/System.Diagnostics.DiagnosticSource/src/ILLinkTrim.xml
src/libraries/System.Diagnostics.DiagnosticSource/src/System.Diagnostics.DiagnosticSource.csproj
src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/DiagnosticSourceEventSource.cs
src/libraries/System.Diagnostics.DiagnosticSource/tests/DiagnosticSourceEventSourceBridgeTests.cs