Skip to content

Commit 6cf8d1b

Browse files
Merge pull request #31613 from David-Engel/perfcollect
Add PerfCollect instructions for Linux
2 parents da9da69 + 3e3d0d1 commit 6cf8d1b

1 file changed

Lines changed: 45 additions & 9 deletions

File tree

docs/connect/ado-net/enable-eventsource-tracing.md

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ title: Enable event tracing in SqlClient
33
description: Describes how to enable event tracing or logging in SqlClient by implementing an event listener and how to access the event data.
44
author: David-Engel
55
ms.author: davidengel
6-
ms.reviewer: v-davidengel
7-
ms.date: 03/15/2023
6+
ms.reviewer: davidengel
7+
ms.date: 08/21/2024
88
ms.service: sql
99
ms.subservice: connectivity
1010
ms.topic: conceptual
@@ -103,33 +103,33 @@ class Program
103103
}
104104
```
105105

106-
### Use Xperf to collect trace log
106+
## Use Xperf to collect traces
107107

108108
1. Start tracing using the following command.
109109

110-
```
110+
```powershell
111111
xperf -start trace -f myTrace.etl -on *Microsoft.Data.SqlClient.EventSource
112112
```
113113

114114
2. Run the native SNI tracing example to connect to SQL Server.
115115

116116
3. Stop tracing using the following command line.
117117

118-
```
118+
```powershell
119119
xperf -stop trace
120120
```
121121

122-
4. Use PerfView to open the myTrace.etl file specified in Step 1. The SNI tracing log can be found with `Microsoft.Data.SqlClient.EventSource/SNIScope` and `Microsoft.Data.SqlClient.EventSource/SNITrace` event names.
122+
4. Use [PerfView](https://github.com/microsoft/perfview) to open the myTrace.etl file specified in Step 1. The SNI tracing log can be found with `Microsoft.Data.SqlClient.EventSource/SNIScope` and `Microsoft.Data.SqlClient.EventSource/SNITrace` event names.
123123

124124
![Use PerfView to view SNI trace file](media/view-event-trace-native-sni.png)
125125

126-
### Use PerfView to collect trace log
126+
## Use PerfView to collect traces
127127

128-
1. Start PerfView and run `Collect > Collect` from the menu bar.
128+
1. Start [PerfView](https://github.com/microsoft/perfview) and run `Collect > Collect` from the menu bar.
129129

130130
2. Configure the trace file name, output path, and provider name.
131131

132-
![Configure Prefview before collection](media/collect-event-trace-native-sni.png)
132+
![Configure Perfview before collection](media/collect-event-trace-native-sni.png)
133133

134134
3. Start collection.
135135

@@ -139,6 +139,42 @@ class Program
139139

140140
6. Open the `etl` file in PerfView. The SNI tracing log can be found with `Microsoft.Data.SqlClient.EventSource/SNIScope` and `Microsoft.Data.SqlClient.EventSource/SNITrace` event names.
141141

142+
## Use PerfCollect to collect traces
143+
144+
On Linux, PerfCollect can be used to capture traces. PerfCollect is a bash script that uses .NET tools to collect traces for .NET applications. For more information about PerfCollect, see [Performance Tracing on Linux](https://github.com/dotnet/coreclr/blob/master/Documentation/project-docs/linux-performance-tracing.md) The traces created by PerfCollect can be viewed in [PerfView](https://github.com/microsoft/perfview).
145+
146+
1. If not already installed, install curl (Ubuntu commands are provided):
147+
148+
```bash
149+
sudo apt-get update
150+
sudo apt-get install curl
151+
```
152+
153+
1. Install PerfCollect:
154+
155+
```bash
156+
sudo curl –OL http://aka.ms/perfcollect
157+
sudo chmod +x perfcollect
158+
sudo ./perfcollect install
159+
```
160+
161+
1. Define environment variables for PerfCollect:
162+
163+
```bash
164+
export COMPles_perfMapEnab;ed=1
165+
export COMPlus_EnableEventLog=1
166+
```
167+
168+
1. Collect logs:
169+
170+
```bash
171+
sudo ./perfcollect collect <trace file name>
172+
```
173+
174+
Run the application separately and let it run as long as needed to reproduce the issue. If it's a high CPU issue, 5-10 seconds is usually enough. Press CTRL+C to stop tracing.
175+
176+
Copy the trace file to another system and view it in [PerfView](https://github.com/microsoft/perfview).
177+
142178
## External resources
143179

144180
For another set of examples on how to trace Microsoft.Data.SqlClient cross-platform, see the [CSS SQL Networking Tools wiki](https://github.com/microsoft/CSS_SQL_Networking_Tools/wiki/Collect-a-.NET-Core-SQL-Driver-Trace).

0 commit comments

Comments
 (0)