Set Up the Profiler
- 5 minutes to read
Before actually profiling an application, you need to appropriately configure the profiler, which must know where the application resides and how to connect to it. The configuration process involves specifying proper profiler settings as well as patching the application configuration file. In special cases, you may need to use additional tools or modify the application.
Run XPO Profiler
By default, the XPO Profiler executable (XPOProfiler.exe) is installed to C:\Program Files (x86)\DevExpress 24.1\Components\Tools\Components. You can also invoke it using the DEVEXPRESS | All Platforms | Run XPO Profiler menu command in Visual Studio.
Prepare Your Application
First of all you need to customize your application configuration file to specify profiling settings. For this purpose, run the XPO Profiler.
In the XPO Profiler window, invoke the File menu and click Update App.config.
Locate your application configuration file in the displayed dialog, select it and click Open.
You will be asked whether or not you wish to review and customize the modifications that have been made to the application configuration file. Click Yes.
This will open the modified application configuration file in your IDE. You will see that the profiler adds two XML elements to the configuration file. One of these elements is DevExpressXpoProfiler. It specifies configuration settings you may need to customize.
<DevExpressXpoProfiler
serverType="DevExpress.Xpo.Logger.Transport.LogServer"
serverAssembly="DevExpress.Xpo.v24.1,
Version=24.1.7.0,
Culture=neutral,
PublicKeyToken=b88d1754d700e49a"
categories="SQL;Session;DataCache"
port="52934" />
The element’s categories attribute specifies XPO events categories the profiler will track. There are three categories available.
- SQL - SQL queries.
- Session - Session events.
- DataCache - Data cache events.
The element’s port attribute specifies the number of the port that will be used by the profiler to connect to your application. The default port number is 52934. If this port number is used by another application, specify an unused port number. If you are profiling different applications hosted on the same machine, use different port numbers. Write down the port number you have specified in the configuration file, as you will need to specify it again when connecting the profiler to the application.
Note
- If you want to see the call stack in XPO Profiler, set the static LogManager.IncludeStackTrace property to true.
- If you are going to profile a remotely installed application via XPOProfilerProxy, you cannot use the 52927 port number as it is reserved for service communications.
Remotely Installed WinForms/ASP.NET Applications
If you need to profile a remotely installed application, then in addition to patching the application configuration file, you will need to use the XPOProfilerProxy utility. This utility is located in the C:\Program Files (x86)\DevExpress 24.1\Components\Tools\Components\ folder, by default. This utility must be run on the machine where your application is deployed. You can run the utility either as a console application or as a service, with the following command line options.
- /c - Start as a console application.
- /i - Install as a service.
- /u - Uninstall the service.
ASP.NET Applications Running in Medium Trust Environment
To profile an ASP.NET application running in a medium trust environment, you need to deploy a WCF service alongside the application. The profiler will use this service to receive messages from your ASP.NET application. To create the WCF service, right-click your application project in Visual Studio and choose Add > New Item.
Select the WCF Service template, type MyLogService.svc into the Name field and click Add.
The application’s Web.config configuration file will be patched and three files - IMyLogService.cs (IMyLogService.cs), MyLogService.svc, and MyLogService.svc.cs (MyLogService.svc.vb) will be added to the solution. Delete the IMyLogService.cs (IMyLogService.cs) file and modify the MyLogService.svc.cs (MyLogService.svc.vb) file as follows.
using System.ServiceModel;
using DevExpress.Xpo.Logger;
using DevExpress.Xpo.Logger.Transport;
//...
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
public class MyLogService : LogService {
static LoggerBase logger = new LoggerBase(50000);
public MyLogService() : base(logger) { }
static MyLogService() {
LogManager.SetTransport(logger);
}
}
Open the Web.config file and modify the <system.serviceModel> section as follows:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="false"/>
<services>
<service name="MyWebApplication.MyLogService">
<endpoint address="" binding="wsHttpBinding" contract="DevExpress.Xpo.Logger.Transport.ILogSource" />
</service>
</services>
</system.serviceModel>
Use the fully qualified name of your service instead of MyWebApplication.MyLogService.
Specify Connection Parameters
Invoke the File menu and click New...
Choose the binding type. This field defines transports and protocols the profiler should use when it interacts with your application.
- NetTcpBinding - Choose this binding type to profile Windows Forms applications or ASP.NET applications running in a Full Trust environment.
- WSHttpBinding, BasicHttpBinding - Choose these binding types to profile an ASP.NET application running in a Medium Trust environment.
- WebApi - Choose this binding type if your application exposes Web API for the XPO Profiler. For additional information, see Connect the XPO Profiler to an ASP.NET Core Application.
- NamedPipes - Choose this binding to profile any .NET Framework or .NET Core application. This binding type requires code modifications. For additional information, see Connect the XPO Profiler to an Application via Named Pipes.
Specify the name of the server where your application is deployed. By default, this field lists localhost. If you are profiling a locally deployed application, leave localhost as the field value. Otherwise, type in the required server name.
Provide the port number you have specified when patching your application configuration file. If you are profiling an ASP.NET application running in a medium trust environment, specify the port number used by the server hosting the application. Typical port number used by HTTP servers is 80.
For the WSHttpBinding or BasicHttpBinding binding type, provide the name of the WCF service you deployed with your application.
For the WebApi binding type, provide the path to the web application’s controller.
For the NamedPipes binding type, provide the name of a pipe the application uses to communicate with the XPO Profiler.
Click OK. Refer to Profile Your Application for the next steps.