OpenTelemetry Agent - .NET Windows Command Line Apps Installation



Installation Steps

Take the following steps to install the vFunction Distributed Agent and configure it to send traces to the vFunction Server:

  1. Gather the vFunction Server UI’s UUID for the vFunction Distributed Application
  1. Log into the vFunction Server UI
  2. In the top-left corner, click the dropdown
  3. Click Add Application from the dropdown menu
  4. Type a name for the Application in the Application Name text field
  5. Toggle the slider to Distributed
  6. Click the blue Create button
  7. In the dialog box that launches, toggle the tabs to .NET
  8. In the text box with OTEL Environment Variables, find the OTEL_EXPORT_OTLP_ENDPOINT and OTEL_EXPORTER_OTLP_HEADER. These will be used at a later stage of the installation
  1. Download the OpenTelemetry .NET AutoInstrumentation ZIP. Note that, as an alternative, PowerShell Modules can be downloaded to accomplish this same goal
  2. Extract the downloaded opentelemetry-dotnet-instrumentation-windows.zip to a location on the Application’s filesystem, such as C:\otel.
  3. Create a PowerShell script to start the Application from the Command Line while adding the OpenTelemetry Agent to the running process
############### VF Dist Values ###############
$HOST_URL              = "https://vfunction.mycompany.com"
$APP_UUID              = "APP-UUID-FROM-VFSERVER-UI"
$APP_NAME              = "My_APP"
$BASE_DIR              = "C:\home\otel"
$RUN_APP               = "C:\path\to\executable.exe"

##############################################

$env:CORECLR_PROFILER_PATH="${BASE_DIR}\win-x64\OpenTelemetry.AutoInstrumentation.Native.dll"
$env:CORECLR_ENABLE_PROFILING=1
$env:CORECLR_PROFILER="{918728DD-259F-4A6A-AC2B-B85E1B658318}"

$env:COR_PROFILER_PATH="${BASE_DIR}\win-x64\OpenTelemetry.AutoInstrumentation.Native.dll"
$env:COR_ENABLE_PROFILING=1
$env:COR_PROFILER="{918728DD-259F-4A6A-AC2B-B85E1B658318}"

$env:OTEL_DOTNET_AUTO_INSTALL_DIR="${BASE_DIR}"
$env:OTEL_DOTNET_AUTO_HOME="${BASE_DIR}"

$env:OTEL_EXPORTER_OTLP_ENDPOINT="${HOST_URL}/api/unauth/otlp"
$env:OTEL_EXPORTER_OTLP_HEADERS="X-VF-APP=${APP_UUID}"
$env:OTEL_EXPORTER_OTLP_PROTOCOL="http/protobuf"

$env:DOTNET_ADDITIONAL_DEPS="${BASE_DIR}\AdditionalDeps"
$env:DOTNET_SHARED_STORE="${BASE_DIR}\store"
$env:DOTNET_STARTUP_HOOKS="${BASE_DIR}\net\OpenTelemetry.AutoInstrumentation.StartupHook.dll"

$env:OTEL_TRACES_EXPORTER="otlp"
$env:OTEL_METRICS_EXPORTER="none"
$env:OTEL_LOGS_EXPORTER="none"
$env:OTEL_SERVICE_NAME="${APP_NAME}"
$env:OTEL_DOTNET_AUTO_SQLCLIENT_SET_DBSTATEMENT_FOR_TEXT "true"

.\${RUN_APP}