How to install the vFunction .NET Agent in parallel with Datadog


Overview

By default, Microsoft allows only one Agent to be installed on .NET Applications. The steps below allow vFunction to be added to the configuration of the Datadog Agent to allow both Agents to run side-by-side without impacting one another.


Installation Steps

  1. Download and extract the vFunction .NET Agent on the Server where the Application runs
  2. Open the installation.yaml to modify the required configurable settings
  1. Edit the installation.yaml to enable vFunction in-parallel to Datadog
### Default Settings
agent:
#  enable_rejit: true

### After Change
agent:
  enable_rejit: true
  1. Run the Installation Script
Linux - Sudo
sudo bash /opt/vfunction/controller-installation/install.sh -i default-dotnet
Linux - Sudoless
### Find-and-replace REPLACE_BASE_DIR with the location the vFunction Installation Package was extracted

bash /REPLACE_BASE_DIR/vfunction/opt/vfunction/controller-installation/install.sh -i default-dotnet
Windows - Admin
### Find-and-replace REPLACE_BASE_DIR with the location the vFunction Installation Package was extracted

powershell -NoProfile -ExecutionPolicy unrestricted -Command "REPLACE_BASE_DIR\vfunction\controller-installation\install.ps1 -instance default-dotnet"
Windows - No Admin
### Find-and-replace REPLACE_BASE_DIR with the location the vFunction Installation Package was extracted

powershell -NoProfile -ExecutionPolicy unrestricted -Command "REPLACE_BASE_DIR\vfunction\controller-installation\install.ps1 -instance default-dotnet -runAsServices false" 
  1. Set vFunction Environment Variables
Linux - Sudo
  1. In a text editor from the same location where the application runs, create vf.sh with the following content
#!/usr/bin/env sh

set -x
echo "Adding vFunction environmental variables"

export VF_AGENT_CONF_LOCATION=/etc/sysconfig/vfunction/agent/instances/default-dotnet/conf.json
export DOTNET_TailCallOpt=0

echo "Starting Application"

###### Replace RUN_APP with the workflow for starting the application

RUN_APP 
Linux - Sudoless
  1. In a text editor from the same location where the application runs, create vf.sh with the following content
#!/usr/bin/env sh

set -x
echo "Adding vFunction environmental variables"

### Find-and-replace the REPLACE_BASE_DIR below with the actual values, such as /tmp/vfunction/

export VF_AGENT_CONF_LOCATION=/REPLACE_BASE_DIR/etc/sysconfig/vfunction/agent/instances/default-dotnet/conf.json
export DOTNET_TailCallOpt=0

echo "Starting Application"

### Replace RUN_APP with the workflow for starting the application

RUN_APP 
Windows - Command Line Apps
  1. In a text editor from the same location where the application runs, create vf.ps1 with the following content
### Find-and-replace the REPLACE_BASE_DIR below with the actual values, such as C:\vfunction\ 
### Find-and-replace RunApp with the name and path to the Application to be profiled 

$env:VF_AGENT_CONF_LOCATION='REPLACE_BASE_DIR\config\agent\instances\default-dotnet\conf.json'
$env:DOTNET_TailCallOpt = 0
& 'RunApp.exe'
Windows - IIS Apps
  1. In a text editor, open the C:\Windows\System32\inetsrv\config\applicationHost.config
  2. Search for the term applicationPools in the applicationHost.config file
  3. Modify the XML entry for the Application Pool used by the Application
### Find-and-replace the REPLACE_BASE_DIR below with the actual values, such as C:\vfunction\ 

<add name="DefaultAppPool" autoStart="true">
    <environmentVariables>
        <add name="VF_AGENT_CONF_LOCATION" value="REPLACE_BASE_DIR\config\agent\instances\default-dotnet\conf.json" />
        <add name="DOTNET_TailCallOpt" value="0"/>
    </environmentVariables>
</add>
Windows - Services Apps
  1. Open the Windows Server’s Registry Editor
  1. Open the Start Menu
  2. Search for regedit
  3. Launch the Registry Editor
  1. In the left-hand sidebar, expand the folders to get to the Application
### Replace the SERVICE_NAME below with the name of the Windows Service for the Application

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SERVICE_NAME 
  1. Right-click in the white space below the list of Registry Keys for the Service
  2. Select New > Multi-String Value
  3. Replace New Value #1 with Environment
  4. Double-click the new Environment variable to add Value Data entries
### Find-and-replace the REPLACE_BASE_DIR below with the actual values, such as C:\vfunction\ 

Value Name:
  Environment

Value Data:
  VF_AGENT_CONF_LOCATION=REPLACE_BASE_DIR\config\agent\instances\default-dotnet\conf.json
  DOTNET_TailCallOpt=0
  1. Modify the DataDog loader.conf in the DataDog Root Directory
Linux - Sudo
### Before the Change
#Custom

### After the Change
#Custom
CUSTOM;{cd7d4b53-96c8-4552-9c11-6e41df8eab8a};linux-x64;/opt/vfunction/agent/libvfagent.net.so 
Linux - Sudoless
### Find-and-replace REPLACE_BASE_DIR with the location the vFunction Installation Package was extracted

### Before the Change
#Custom

### After the Change
#Custom
CUSTOM;{cd7d4b53-96c8-4552-9c11-6e41df8eab8a};linux-x64;/REPLACE_BASE_DIR/vfunction/opt/vfunction/agent/libvfagent.net.so 
Windows
### Find-and-replace REPLACE_BASE_DIR with the location the vFunction Installation Package was extracted

### Before the Change
#Custom

### After the Change
#Custom
CUSTOM;{cd7d4b53-96c8-4552-9c11-6e41df8eab8a};win-x64;REPLACE_BASE_DIR\agent\vfagent.net.dll
CUSTOM;{cd7d4b53-96c8-4552-9c11-6e41df8eab8a};win-x86;REPLACE_BASE_DIR\agent\vfagent.net.x86.dll
  1. Restart the Application so that the Datadog and vFunction Agents both profile the .NET Application