-
Notifications
You must be signed in to change notification settings - Fork 765
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
OpenTelemetrySdkEventSource updates for activity tracking #5387
Conversation
Renamed ActivityStarted/Stopped to ActivityStart/Stop Add tests Prevent concurrent execution of EventSource tests
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5387 +/- ##
==========================================
- Coverage 83.38% 83.22% -0.16%
==========================================
Files 297 279 -18
Lines 12531 11961 -570
==========================================
- Hits 10449 9955 -494
+ Misses 2082 2006 -76
Flags with carried forward coverage won't be shown. Click here to find out more.
|
@pharring Can you elaborate on the end goals? The eventsource is purely an internal logging mechanism for the OTel SDK(and other components), and do you plan to rely on that for a particular scenario? If you want to rely on something to get notified on Activity start/stop, then the OTel way would be to author an |
Hi @cijothomas, the end goal is to be able to light up the "with Activities" views in PerfView when viewing a trace collected from an OpenTelemetry app using an EventPipe profiler like dotnet-trace, or an ETW profiler like PerfView or Visual Studio. Note that these are out-of-proc profilers, so we cannot modify the user's application by adding an ActivityProcessor. The OpenTelemetrySdkEventSource already emits ActivityStarted/ActivityStopped events at the right place with spanIDs. Unfortunately, because they are mis-named, they don't trigger ActivityTracking. ActivityTracking is what enables the "with Activities" views in PerfView. It is possible to work around OpenTelemetrySdkEventSource's deficiency by using the DiagnosticSourceEventSource provider instead. It supports ActivitySource tracking. However, the events are verbose (they include all event attributes) if all you need are activity tracking and the spanIds -- this is the case for adding OpenTelemetry support for Application Insights Profiler. Having had the weekend to think about this, we might be able to improve on this PR without breaking back-compat: |
@pharring Thanks for the explanation. I am not that concerned about the back-compat issue, as there was no explicit guarantee about the shape of internal logs. I am more concerned that you want to take a dependency on this particular naming style, but the SDK does not guarantee to maintain that either. Worst case, there is no guarantee that we won't move away completely from EventSource itself (like in favor of ILogger). I believe this can be solved elsewhere. For example, dotnet-monitor tool is already able to listen to Metrics, without any OTel component involved. Maybe a similar approach could be used for traces as well, so there is no need of taking a undesired dependency on OTEL SDK internal behavior. |
You might have misunderstood. This isn't something I invented. ActivityTracking via the -Start/-Stop convention and OpCode.Start/Stop is built into the framework and documented. https://learn.microsoft.com/dotnet/core/diagnostics/eventsource-instrumentation#best-practices
That would be -- unfortunate. I'm glad you brought it up. There's a unit test in this PR. Is that sufficient to ensure the EventSource's survival? Since the EventSource behavior is not expressible in PublicAPI.Shipped.txt, perhaps I can add a scary comment in the unit test to discourage removal.
It's sort of similar for dotnet-trace. You enable EventSources via EventPipe or ETW with keywords and levels. dotnet-trace works fine for OpenTelemetry apps if you're interested in is app-wide bottlenecks. The problem is if you want to do activity-based (request-based) profiling -- the kind where you look at the timeline of a single request. The viewer needs to collate events and callstacks by activity and, if the app isn't emitting accurate Activity IDs, then everything collapses to a single root activity. |
Wait, are you saying that OpenTelemetrySdkEventSource is not for public consumption? If so, I can respect that. Would you support introducing a new EventSource that is public? Perhaps one that only contains the new ActivityStart/Stop events from this PR? At the same time, perhaps we could rename it to "OpenTelemetry-Sdk-Internal" to make that clear. |
It was only intended for internal troubleshooting, and will be replaced with ILogger #3881 (EventSource was used since ILogger wasn't ready at that time).
I don't support introducing new EventSource. I support getting rid of all EventSources from OpenTelemetry.
💯 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't feel this is the right direction #5387 (comment).
@pharring why not make this request to the runtime itself? This could be baked into Activity, so you are not dependent on tracing being done with OTel. |
Thank you for the feedback and the suggestion. We'll use DiagnosticSourceEventSource (Microsoft-Diagnostics-DiagnosticSource) for activity tracking instead. |
Changes
This change addresses issues with the OpenTelemetrySdkEventSource discovered during testing of profiler support for .NET applications. For example, we use dotnet-trace to profile an OpenTelemetry application. To enable activity tracking, we enable the OpenTelemetrySdkEventSource like this:
In the resulting trace, however, we observe the following problem:
This is because of two problems:
To address these two issues:
Merge requirement checklist
CHANGELOG.md
files updated for non-trivial changes