How to Profile Windows Services

  • Updated on 25 Jun 2018
  • 1 minute to read
  • Contributors 

By default Retrace only profiles applications hosted within IIS. If you want Retrace to capture transactions from an application running as a Windows service, please follow these directions.

Step 1. Install Retrace Windows Agent with the option for Windows Services with one of the below options:

Option 1. New install in interactive mode:

Upon installing check the box for Enabling the Retrace for .NET Core and Windows Services.

Option 2. New install via command line, for example:

"Stackify_[version].exe" /s /v"ACTIVATIONKEY=[your key here] ENVIRONMENT="[ENTER_ENVIRONMENT_HERE]" ENABLEPROFILER=1 

Replacing the [tokens] as necessary.

Note: set RestartIIS=1 if you wish to have Retrace automatically restart IIS to begin profiling of web apps.

Option 3. For an existing install of Stackify

  •    Modify \[Install Drive\]:Program Files (x86)\\Stackify\\Stackify.ini
    
  •    Add **AttachAll=1** to the \[FEATURES\] section
    
  •    Restart the ‚ÄúStackify Monitoring Service‚ÄĚ Windows Service
    

Step 2. Tell Retrace which services to profile with one of the below options

Option¬†1. ¬†By using the ‚Äú/EnableStackify‚ÄĚ switch For an existing service, double check what the existing path is via the UI or by the command line ‚Äúsc query‚ÄĚ commands. Copy this path so you can use it via command line to update it.

You can then update the path via command line and add our command line switch to it like so:

CMD> sc config ‚ÄúMy Service‚ÄĚ binPath=‚ÄĚc:pathapp.exe /EnableStackify‚ÄĚ

When you create your service, you may also provide this switch with the executable. For example, to install your service from a command prompt:

Option¬†2. ¬†By creating a ‚ÄúProfileProcess.txt‚ÄĚ file

This is a JSON formatted file that can define one or many EXEs to profile

[{
"exe":"MyService.exe"
},
{
"exe":"MyService1.exe"
},
{
"exe":"SuperDuperService.exe"
}]

You may save this file:

  • In the same folder as the .exe that is being profiled. This would allow you to easily ‚Äúbin deploy‚ÄĚ the file with your app.
  • Into [Install Drive]:Program Files (x86)\Stackify

Step 3. Restart your service

Step 4. Define a transaction for Retrace

At this point, Retrace will begin profiling your code, and capture some data such as exceptions and errors, but to track a transaction through the app, you must add some instrumentation to your app via our library. Depending on the type of application, there are multiple ways to do this.  To learn more and see examples, please see:  Defining Custom Transactions