You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[tvOS] Test failures in System.Diagnostics.Tracing.Tests #56073
<failure exception-type="Xunit.Sdk.NotEqualException">
<message><![CDATA[Assert.NotEqual() Failure\nExpected: Not 00000000-0000-0000-0000-000000000000\nActual: 00000000-0000-0000-0000-000000000000]]></message>
<stack-trace><![CDATA[ at BasicEventSourceTests.ActivityTracking.ActivityFlowsAsync()
--- End of stack trace from previous location ---]]>
</stack-trace>
</failure>
<failure exception-type="Xunit.Sdk.EqualException">
<message><![CDATA[Assert.Equal() Failure\nExpected: ed27419e-317a-43a7-be88-6b793b146141\nActual: 00000000-0000-0000-0000-000000000000]]></message>
<stack-trace><![CDATA[ at BasicEventSourceTests.ActivityTracking.SetCurrentActivityIdBeforeEventFlowsAsync()
--- End of stack trace from previous location ---]]>
</stack-trace>
</failure>
<failure exception-type="Xunit.Sdk.EqualException">
<message><![CDATA[Assert.Equal() Failure\nExpected: 33f1669b-7f05-46a8-bf4c-f321de6083f6\nActual: 00000000-0000-0000-0000-000000000000]]></message>
<stack-trace><![CDATA[ at BasicEventSourceTests.ActivityTracking.SetCurrentActivityIdAfterEventDoesNotFlowAsync()
--- End of stack trace from previous location ---]]>
</stack-trace>
</failure>
Do we build with diagnostics tracing component support enabled when running tests on mobile, link or deploy needed components? I guess this tests will end up in ves_icall_System_Diagnostics_Tracing_EventPipeInternal_EventActivityIdControl and if we don't have component support loaded that will be a nop operation so won't set thread activity ID and that will trigger the assert in this test.
I'm trying to make this work on browser now.
And I'm not clear how this could work on Mono. I can't find what's calling ActivityTracker.Instance.Enable() on Mono
Right. I think what's happening is the test has a custom EventSource/EventListener that looks for TplEventSource being created to enable that provider. Then later in these tests SetCurrentActivityIdBeforeEventFlowsAsync and SetCurrentActivityIdAfterEventDoesNotFlowAsync, they call SetCurrentThreadActivityId which then instantiates TplEventSource.Log.
they call SetCurrentThreadActivityId which then instantiates TplEventSource.Log
That solves how it works in the unit test, but it would not make it work in production, unless user code also enables System.Threading.Tasks.TplEventSource in the OnEventSourceCreated. That sounds fishy.
It seems to me that CoreCLR does it always when FEATURE_EVENT_TRACE is enabled. That's always true, right ?
Yeah, I think you're right that CoreCLR will enable ActivityTracker by default, but I don't know if Mono also should. If Browser needs ActivityTracking, I think we could try turning it on in 10. @lateralusX, do you happen to know if ActivityTracker was not on by default on Mono for a particular reason?
The trigger in CoreCLR is when its raising FireEtwAssemblyLoadStart/FireEtwAssemblyLoadStop event pairs (and there is a listener registering for those events):
That will call into ActivityTracker start/stop that will end up in the managed call that will enable ActivityTracker.Instance.Enable(). The other option is to enable specific keyword on the TPLEventSource. Those are the only two scenarios actively supporting activity tracking and since activity tracking comes with some overhead it only gets enabled when really used.
Mono never ported the specific assembly start/stop events, probably since tools at that point didn't consume them, we just emit FireEtwModuleLoad/FireEtwModuleUnload and FireEtwAssemblyLoad/FireEtwAssemblyUnload. Since Mono don't support the assembly loader events that uses activity tracking, it will only enable it in the scenario that we support, when using TPLEventSource listener with TasksFlowActivityIds keyword.
If we decide to support FireEtwAssemblyLoadStart/FireEtwAssemblyLoadStop then we would enable it in similar way as CoreClr does.
So the question is when wasm/browser should enable activity tracking.
It seems to me that the "activity" is allocated any time when EventSource method with Start and Stop suffix is called.
The interesting example is class HttpTelemetry with RequestStart, RequestStop, RequestHeadersStart, RequestHeadersStop, RequestContentStart, RequestContentStop, ResponseHeadersStart, ResponseHeadersStop, ResponseContentStart and ResponseContentStop. There are more events for other OS where HTTP is on top of socket.
All of this works when DiagnosticsHandler is enabled. Via System.Net.Http.EnableActivityPropagation via HttpActivityPropagationSupport which is false for browser.
Also maybe MetricsHandler when is enabled ?
Which at the moment is not guarded, but I think it should be behind <MetricsSupport> & System.Diagnostics.Metrics.Meter.IsSupported. And that is false by default on browser.
since activity tracking comes with some overhead it only gets enabled when really used.
The HttpTelemetry nor MetricsHandler nor DiagnosticsHandler doesn't call the ActivityTracker.Instance.Enable() at the moment.
Should it do that ?
Activity
MaximLipnin commentedon Jul 21, 2021
Those tests have been added recently in #55625. They are skipped for WASM, I'm not sure if we want to do the same for Apple mobile platforms.
steveisok commentedon Jul 21, 2021
@MaximLipnin Can you check to see what the value is for
<EventSourceSupport>?MaximLipnin commentedon Jul 21, 2021
@steveisok Something close to the mobile targets is https://github.com/dotnet/runtime/blob/main/eng/testing/tests.mobile.targets#L26 but we don't set EAT for the staging lanes so perhaps
EventSourceSupportis not setlateralusX commentedon Jul 21, 2021
Do we build with diagnostics tracing component support enabled when running tests on mobile, link or deploy needed components? I guess this tests will end up in ves_icall_System_Diagnostics_Tracing_EventPipeInternal_EventActivityIdControl and if we don't have component support loaded that will be a nop operation so won't set thread activity ID and that will trigger the assert in this test.
steveisok commentedon Jul 21, 2021
I don't think we do. We probably should skip these for the time being.
8 remaining items
[iOS/tvOS/MacCatalyst] Disable some of the library tests due to failu…
pavelsavara commentedon Mar 13, 2025
I'm trying to make this work on browser now.
And I'm not clear how this could work on Mono. I can't find what's calling
ActivityTracker.Instance.Enable()on Monomdh1418 commentedon Mar 13, 2025
@pavelsavara If EventSource is being initialized, it enables an ActivityTracker instance, so whenever events are being written to EventPipe on Mono, OnStart could be called from WriteEventVarArgs or WriteEventWithRelatedActivityIdCore and that could be the things calling
ActivityTracker.Instance.Enable()pavelsavara commentedon Mar 13, 2025
Yes, but that's just instance, but not
Enable()andActivityTracker.OnStartwould enable it only if you haveTplEventSourceenabled, right ?runtime/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/ActivityTracker.cs
Lines 47 to 59 in 9c9178f
mdh1418 commentedon Mar 13, 2025
Right. I think what's happening is the test has a custom EventSource/EventListener that looks for TplEventSource being created to enable that provider. Then later in these tests
SetCurrentActivityIdBeforeEventFlowsAsyncandSetCurrentActivityIdAfterEventDoesNotFlowAsync, they callSetCurrentThreadActivityIdwhich then instantiatesTplEventSource.Log.pavelsavara commentedon Mar 13, 2025
Thanks
pavelsavara commentedon Mar 13, 2025
That solves how it works in the unit test, but it would not make it work in production, unless user code also enables
System.Threading.Tasks.TplEventSourcein theOnEventSourceCreated. That sounds fishy.It seems to me that CoreCLR does it always when
FEATURE_EVENT_TRACEis enabled. That's always true, right ?FireAssemblyLoadStart->ActivityTracker::Start->AssemblyLoadContext.StartAssemblyLoad->ActivityTracker.Instance.Enable()Should we do
ActivityTracker.Instance.Enable()fist time that anyEventListeneris created ?Or do something Mono specific when ? Maybe any time that we link
libmono-component-diagnostics_tracing-static.lib?cc @lewing
mdh1418 commentedon Mar 13, 2025
Yeah, I think you're right that CoreCLR will enable ActivityTracker by default, but I don't know if Mono also should. If Browser needs ActivityTracking, I think we could try turning it on in 10. @lateralusX, do you happen to know if ActivityTracker was not on by default on Mono for a particular reason?
lateralusX commentedon Mar 14, 2025
The trigger in CoreCLR is when its raising FireEtwAssemblyLoadStart/FireEtwAssemblyLoadStop event pairs (and there is a listener registering for those events):
runtime/src/coreclr/binder/bindertracing.cpp
Line 28 in a9b700a
That will call into ActivityTracker start/stop that will end up in the managed call that will enable ActivityTracker.Instance.Enable(). The other option is to enable specific keyword on the TPLEventSource. Those are the only two scenarios actively supporting activity tracking and since activity tracking comes with some overhead it only gets enabled when really used.
Mono never ported the specific assembly start/stop events, probably since tools at that point didn't consume them, we just emit FireEtwModuleLoad/FireEtwModuleUnload and FireEtwAssemblyLoad/FireEtwAssemblyUnload. Since Mono don't support the assembly loader events that uses activity tracking, it will only enable it in the scenario that we support, when using TPLEventSource listener with TasksFlowActivityIds keyword.
If we decide to support FireEtwAssemblyLoadStart/FireEtwAssemblyLoadStop then we would enable it in similar way as CoreClr does.
pavelsavara commentedon Apr 7, 2025
So the question is when wasm/browser should enable activity tracking.
It seems to me that the "activity" is allocated any time when
EventSourcemethod withStartandStopsuffix is called.The interesting example is
class HttpTelemetrywithRequestStart,RequestStop,RequestHeadersStart,RequestHeadersStop,RequestContentStart,RequestContentStop,ResponseHeadersStart,ResponseHeadersStop,ResponseContentStartandResponseContentStop. There are more events for other OS where HTTP is on top of socket.All of this works when
DiagnosticsHandleris enabled. ViaSystem.Net.Http.EnableActivityPropagationviaHttpActivityPropagationSupportwhich isfalsefor browser.Also maybe
MetricsHandlerwhen is enabled ?Which at the moment is not guarded, but I think it should be behind
<MetricsSupport>&System.Diagnostics.Metrics.Meter.IsSupported. And that isfalseby default on browser.The
HttpTelemetrynorMetricsHandlernorDiagnosticsHandlerdoesn't call theActivityTracker.Instance.Enable()at the moment.Should it do that ?
What other EventSources should ?