xpoprofiler-10659-set-up-the-profiler.md
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.
By default, the XPO Profiler executable (XPOProfiler.exe) is installed to C:\Program Files (x86)\DevExpress 25.2\Components\Tools\Components. You can also invoke it using the DEVEXPRESS | All Platforms | Run XPO Profiler menu command in Visual Studio.
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.v25.2,
Version=25.2.5.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.
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 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 25.2\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.
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);
}
}
Imports System.ServiceModel
Imports DevExpress.Xpo.Logger
Imports DevExpress.Xpo.Logger.Transport
'...
<ServiceBehavior(InstanceContextMode := InstanceContextMode.Single)> _
Public Class MyLogService
Inherits LogService
Private Shared logger As New LoggerBase(50000)
Public Sub New()
MyBase.New(logger)
End Sub
Shared Sub New()
LogManager.SetTransport(logger)
End Sub
End Class
Open the Web.config file and modify the \ section as follows:
<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>
Use the fully qualified name of your service instead of MyWebApplication.MyLogService.
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.
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.
See Also