• Print
  • Share
  • Dark
    Light

.NET Core Linux Profiler - Beta

  • Updated on 19 Dec 2018
  • 3 minutes to read
  • Contributors

BETA
Please note that this is a beta version of this product, which is still undergoing final testing and feature validation before its official release. This product should be used only in a non-production environment. This product is provided on an “as is” and “as available” basis. Stackify does not provide any warranties, whether express or implied, as to the suitability or usability of this product. Stackify will not be liable for any loss, whether such loss is direct, indirect, special or consequential, suffered by any party as a result of their use of this product. Should you encounter any bugs, lack of functionality or other problems with this product, please let us know immediately.
Linux Distributions
Ubuntu is currently the only supported distro. Other distros may be successfully used, but have not been validated.

ASP.NET Core


1. Install .NET

gcc
Gcc is currently required to support the profiler. If the distribution of linux you are using does not have gcc, please install it using the supported package manager. For example, on Ubuntu the command would be apt-get install gcc

You may already have .NET Core. We recommend using .NET Core Runtime version 2.1.

.NET Download

2. Install the Stackify Linux Agent

Install the latest Stackify Linux Agent on the device that will be executing the application.

Installation Instructions

3. Install the Stackify.Agent Nuget Package

Add the latest Stackify.Agent Nuget Package to the application to be profiled.

Stackify.Agent

4. Install the Stackify.Agent.Middleware Nuget Package

Add the latest Stackify.Agent.Middleware Nuget Package to the application to be profiled.

Note
An explicit call to Use this middleware is not required. It will be automatically invoked when Microsoft.AspNetCore.Builder.MvcApplicationBuilderExtensions.UseMvc is called.

Stackify.Agent.Middleware

5. Set the Environment Variables Required by the Profiler

The .NET CLR requires environment variables to be set in order to load a profiler into a process. Here are the environment variables required for the Stackify Profiler.

CORECLR_PROFILER - identify the specific profiler to be loaded when enabled
CORECLR_ENABLE_PROFILING - enable loading of the specified profiler
CORECLR_PROFILER_PATH - the location and name of the profiler to be loaded (the path and file are created by the Linux Agent in Step 1)

There are several ways to set these environment variables. Here is an example that only needs to be set once and will be available to each new process that loads without any additional steps.

  1. Open environment from the command-line
    sudo nano /etc/environment
    
  2. Add the environment variables
    CORECLR_PROFILER={cf0d821e-299b-5307-a3d8-b283c03916da}
    CORECLR_ENABLE_PROFILING=1
    CORECLR_PROFILER_PATH="/usr/local/stackify/stackify-dotnet-apm/StackifyProfiler.so"
    
  3. Save & Exit

6. Configure Your Application

Configuration must be added to your appSettings.json for proper coordination with Retrace. If these values are not present or are duplicated, it may prevent your data from displaying in Retrace.

  1. Stackify:AppName - this value determines the name of the app displayed in Retrace.
  2. Stackify:Environment - this value determines the name of the environment for the app displayed in Retrace.

Here's an example of a config file using json:

{
  "Logging": {
    "LogLevel": {
      "Default": "Warning"
    }
  },
  "Stackify": {
    "AppName": "MyApp",
    "Environment": "MyEnvironment"
  },
  "AllowedHosts": "*"
}

7. Deploy and Launch Your Application

Note
Applications profiled will only display under Other Apps in Retrace.

Trace data will be automatically processed by the Linux Agent and submitted to Retrace.


Current Profiler Support

Limited Features
Note, this product is not in feature-parity with the existing .NET Profiler. Only the libraries and frameworks listed below are currently profiled. They are not feature complete.

ASP .NET Core MVC

  • HttpClient
  • SqlClient
  • StackifyLib
  • WebClient

Troubleshooting

Profiler debug logging will be written here:

/usr/local/stackify/stackify-dotnet-apm/debug/

Stackify Linux Agent Logs can be found here:

/usr/local/stackify/stackify-agent/log/

Trace data will be written here:

/usr/local/stackify/stackify-dotnet-apm/log/
Was this article helpful?