-
Notifications
You must be signed in to change notification settings - Fork 6k
Small reorganization of docs to move logging up to its own topic, and… #35444
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
title: Performance tracing | ||
description: A guide to tracing in .NET | ||
ms.date: 05/19/2023 | ||
--- | ||
|
||
# Performance tracing overview | ||
|
||
Performance tracing is the ability to collect detailed diagnostic information about what is happening inside .NET processes, and includes telemetry information for the Runtime, GC, Libraries and application code. | ||
|
||
There are a number of aspects to performance tracing for .NET, including: | ||
|
||
## How events are sourced | ||
|
||
There are two main mechanisms within .NET for providing events for use with performance tracing: | ||
|
||
| Name | Description | | ||
| --- | --- | | ||
| [EventSource](./eventsource.md) | <xref:System.Diagnostics.Tracing.EventSource?displayProperty=nameWithType> is a fast structured logging solution built into the .NET runtime. On .NET Framework EventSource can send events to [Event Tracing for Windows (ETW)](/windows/win32/etw/event-tracing-portal) and <xref:System.Diagnostics.Tracing.EventListener?displayProperty=nameWithType>. On .NET Core EventSource additionally supports [EventPipe](./eventpipe.md), a cross-platform tracing option. Most often developers use EventSource logs for performance analysis, but EventSource can be used for any diagnostic tasks where logs are useful. The .NET runtime is already instrumented with [built-in events](./well-known-event-providers.md) and you can log your own custom events. | | ||
| [DiagnosticSource](./diagnosticsource-diagnosticlistener.md) | <xref:System.Diagnostics.DiagnosticSource?displayProperty=nameWithType> is a module that allows code to be instrumented for production-time logging of rich data payloads for consumption within the process that was instrumented. At run time, consumers can dynamically discover data sources and subscribe to the ones of interest. <xref:System.Diagnostics.DiagnosticSource?displayProperty=nameWithType> was designed to allow in-process tools to access rich data. DiagnosticSource data can also be egressed via EventPipe enabling rich diagnostic data to be collected by dedicated tools. | | ||
|
||
## How events are collected | ||
|
||
Events can be collected: | ||
|
||
| Mechanism | Description | | ||
| --- | --- | | ||
| In-Process | `EventSource` and `DiagnosticSource` can both be listened to in-process and used by tools such as [Open Telemetry](https://opentelemetry.io/docs/instrumentation/net/) to collect detailed events about features like ASP.NET or HttpClient and then produce metrics based on those events. For example Open Telemetry uses DiagnosticSource to create an [Instumentation Library for ASP.NET](https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/src/OpenTelemetry.Instrumentation.AspNetCore/README.md). | | ||
| Out-of-process | .NET supports rich collection of tracing data via [EventPipe](./eventpipe.md), which can be used by external tools to collect performance tracing data, then can the be analyzed by different tools. | | ||
|
||
## Collection tools | ||
|
||
The primary collection tools for performance data for .NET are: | ||
|
||
| Tool | OS | Description | | ||
| --- | --- | --- | | ||
| [dotnet-trace](./dotnet-trace.md) | All | `dotnet-trace` is a command line tool that will collect traces in the .nettrace format. It can also convert traces to the Chromium or Speedscope formats for viewing. | | ||
| [dotnet-monitor](./dotnet-monitor.md) | All | `dotnet-monitor` is an agent that can be instructed to collect a trace for .NET processes, either by making Web API calls, or by configuring trigger-based rules for CPU or Memory usage thresholds. | | ||
| [Visual Studio](https://learn.microsoft.com/visualstudio/profiling/events-viewer?view=vs-2022) | Windows | Microsoft Visual Studio supports collecting traces for .NET processes as part of the *Performance Profiler* feature. In addition to being able to collect traces, it also can open `.nettrace` traces collected with the other tools in this table. | | ||
| [PerfView](https://github.com/Microsoft/perfview) | Windows | PerfView is a tool for collecting and examining perfomance traces on Windows | | ||
| [PerfCollect](./trace-perfcollect-lttng.md) | Linux | Perfcollect is a collection of scripts that works with the Linux `LTTng` and `perf` tools to collect detailed performance traces for .NET Processes. The resulting traces can be analyzed with a variety of tools include PerfView. | | ||
| [Windows Performance Analyzer](https://learn.microsoft.com/windows-hardware/test/wpt/wpt-getting-started-portal) | Windows | WPA includes a performance recorder and viewer based on the Windows `ETW` event recorder system. It can record a trace of the complete system, including all processes and how they interact with the OS functionality for Networking, Disk IO etc. | | ||
|
||
## See also | ||
|
||
[Debug high CPU usage](./debug-highcpu.md) | ||
[Collect a performance trace in Linux with PerfCollect](./trace-perfcollect-lttng.md) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -640,6 +640,10 @@ items: | |
items: | ||
- name: Overview | ||
href: ../core/diagnostics/index.md | ||
- name: Logging and tracing | ||
href: ../core/diagnostics/logging-tracing.md | ||
- name: ILogger logging | ||
href: ../core/extensions/logging.md | ||
- name: Managed debuggers | ||
href: ../core/diagnostics/managed-debuggers.md | ||
- name: Diagnostic port | ||
|
@@ -653,11 +657,11 @@ items: | |
href: ../core/diagnostics/debug-linux-dumps.md | ||
- name: SOS debugger extension | ||
href: ../core/diagnostics/sos-debugging-extension.md | ||
- name: Logging and tracing | ||
- name: Performance tracing | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm fine with the idea that we'd give people some information specifically through a lense of performance tracing, but I don't like that we'd home all of the EventSource, DiagnosticSource, and EventPipe information there. Most DiagnosticSource usage is not performance tracing and EventSource/EventPipe have significant uses that are both performance and non-performance related. To me this organization seems more confusing than before. Is the goal to highlight ILogger better? What if we just made ILogger first under
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to move ILogger out as its the #1 thing that users will use. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If you want to make ILogger extra prominent how about:
I don't think making logger prominent requires anything else to be re-arranged.
If a customer asked me I'd answer: I think characterizing these tools as being primarily for "performance tracing" is simplified for EventSource (I acknowledge there are times where simple is good) and wrong for DiagnosticSource. Saying they are "for diagnosing performance" is a somewhat better fit, but that is a much broader characterization than "performance tracing" which would also include technologies like metrics and distributed tracing too. Over time I think we are going to see increasing scenario crossover between ILogger and EventSource, not less. For example I'd like to change dotnet-trace so that you can specify ILogger categories as providers and have options for text or binary formats. OpenTelemetry is trying to make EventSource be another API you can use to produce the logging signal. I expect creating a view where logging and performance tracing are treated as very different and APIs should only be thought of as doing one or the other will be an increasingly strained organizational principle over time. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the amount of direct customer usage of EventSource in their code, either emitting or consuming events is going to be minimal - it's going to pretty much be relegated to us as part of the framework/runtime. The interaction that customers will have with EventSource is via a trace, which is most likely to be performance related. |
||
items: | ||
- name: Overview | ||
displayName: logging tracing | ||
href: ../core/diagnostics/logging-tracing.md | ||
displayName: Performance tracing overview | ||
href: ../core/diagnostics/performance-tracing.md | ||
- name: Well-known event providers | ||
href: ../core/diagnostics/well-known-event-providers.md | ||
- name: Event Source | ||
|
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.
To the best of my knowledge DiagnosticSource is not often used for performance tracing. The main uses I've seen are APM tools and OpenTelemetry. Occasionally it gets used in combination with DiagnosticSourceEventSource for things like VS profiler database profiling.
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 think we need a better title than just tracing - Event Tracing or Performance & Diagnostics tracing are ideas I had.