Connect a .Net application with OpenTelemetry to vFunction using PowerShell

The current instructions for .Net in the Learning page in vFunction do not cover power shell. To use powershell, write the following .ps1 script:

$env:OTEL_DOTNET_AUTO_TRACES_CONSOLE_EXPORTER_ENABLED="true"
$env:OTEL_EXPORTER_OTLP_PROTOCOL="http/protobuf"
$env:OTEL_EXPORTER_OTLP_ENDPOINT="<host>/api/unauth/otlp"
$env:OTEL_TRACES_EXPORTER="otlp"
$env:OTEL_METRICS_EXPORTER="none"
$env:OTEL_LOGS_EXPORTER="none"
$env:OTEL_EXPORTER_OTLP_HEADERS="X-VF-APP=<app_uuid>"
Register-OpenTelemetryForCurrentSession -OTelServiceName "<service name>"
dotnet run

<host> is the base url of the vFunction server (e.g., https://myserver.vfunction.com)

<app-uuid> is the application id you see in the URL in the vFunction server after /applications/ For example if you have a URL https:/myserver.vfunction.com/applications/48981fc5-bbbb-bbbb-bbbb-30672fedd74a/learning/b00b0822-aaaa-aaaa-aaaa-993da3691313 then the app-uuid is 48981fc5-bbbb-bbbb-bbbb-30672fedd74a

<service name> the display name of the service

Example:

$env:OTEL_DOTNET_AUTO_TRACES_CONSOLE_EXPORTER_ENABLED="true"
$env:OTEL_EXPORTER_OTLP_PROTOCOL="http/protobuf"
$env:OTEL_EXPORTER_OTLP_ENDPOINT="https://myserver.vfunction.com/api/unauth/otlp"
$env:OTEL_TRACES_EXPORTER="otlp"
$env:OTEL_METRICS_EXPORTER="none"
$env:OTEL_LOGS_EXPORTER="none"
$env:OTEL_EXPORTER_OTLP_HEADERS="X-VF-APP=48981fc5-bbbb-bbbb-bbbb-30672fedd74a"
Register-OpenTelemetryForCurrentSession -OTelServiceName "My Service"
dotnet run