OpenObserve .NET Tracing Guide
Send distributed traces from .NET applications on Red Hat Enterprise Linux and Windows Server to OpenObserve through the OpenTelemetry Collector. No code changes are needed.
How to use this guide. Read Before you begin and fill in the table of values. Then follow Part A on Red Hat Enterprise Linux servers or Part B on Windows servers, one step at a time. Every value you must replace is shown in angle brackets, like
<SERVICE_NAME>, and the steps that contain one are marked with ✏️. Everything else can be copied as it is. Each part ends with a check that your traces arrived in OpenObserve.
Contents
- Before you begin
- Part A: Red Hat Enterprise Linux
- Part B: Windows Server
- Troubleshooting
- Tested versions
Before you begin
This guide sends distributed traces from a .NET application to OpenObserve. No code changes are needed: OpenTelemetry .NET automatic instrumentation traces ASP.NET Core, ASP.NET (.NET Framework), HttpClient, SqlClient, Entity Framework Core, gRPC and other common libraries.
The application sends traces to an OpenTelemetry Collector on the same server. The Collector batches them, retries on network errors, and forwards them to OpenObserve. Only the Collector holds your OpenObserve credentials.
Which part to follow
| Your server | Follow | Steps |
|---|---|---|
| Red Hat Enterprise Linux 8 or 9 | Part A | A1 Install the Collector → A2 Instrument the app → A3 Verify |
| Windows Server 2016 or later | Part B | B1 Install the Collector → B2 Instrument the app (Windows service or IIS) → B3 Verify |
Do all steps in order on each application server. Allow about 20 minutes per server.
Which instrumentation version to install
Check the application's .NET version first (dotnet --list-runtimes, or the TargetFramework in the project file). The newest instrumentation release no longer loads on .NET 8 or 9.
| Application runs on | Use <OTEL_DOTNET_VERSION> = |
|---|---|
| .NET 10 | v1.20.0 |
| .NET 8 or .NET 9 | v1.19.0 |
| .NET Framework 4.6.2 – 4.8.1 (Windows only) | v1.20.0 |
.NET 8 and .NET 9 reached end of support from Microsoft on 10 November 2026. With v1.19.0 they work, but the instrumentation logs an end-of-support warning. Plan an upgrade to .NET 10.
Values you need to provide
Throughout this guide, every value in angle brackets, like <SERVICE_NAME>, is a value you must replace with your own. Replace the angle brackets too. Copy everything else exactly as shown. Fill in this table before you start:
| Placeholder | What to enter | Where to find it | Example |
|---|---|---|---|
<OPENOBSERVE_URL> | Base URL of your OpenObserve, with no trailing / | OpenObserve Cloud: https://api.openobserve.ai. Self-hosted: the URL you use to open OpenObserve | https://o2.example.com |
<ORG_ID> | Your OpenObserve organization ID | OpenObserve → Data sources. It's part of the endpoint shown there | default |
<BASE64_CREDENTIALS> | Base64 of email:password-or-token for the ingestion user | OpenObserve → Data sources shows a ready-made Authorization: Basic ... value; use the part after Basic . To build it yourself, see the note below | dXNlcjpwYXNz |
<TRACE_STREAM> | Traces stream to write to | Your choice. It is created on first use | default |
<SERVICE_NAME> | Name this application will have in OpenObserve | Your choice. Lowercase, unique per application | checkout-api |
<ENVIRONMENT> | Environment label | Your choice | production |
<SERVICE_VERSION> | Application version label | Your release version | 2.3.1 |
<OTEL_DOTNET_VERSION> | Instrumentation release | The version table above | v1.20.0 |
<APP_UNIT> | systemd service name of the application (RHEL) | systemctl list-units --type=service | checkout |
<WINDOWS_SERVICE> | Windows service name of the application (Windows service only) | Get-Service | CheckoutApi |
<IIS_SITE_PATH> | Physical folder of the IIS site, which contains web.config (IIS only) | IIS Manager → site → Basic Settings | C:\inetpub\checkout |
<APP_URL> | A URL of the application for a test request | Your application | http://localhost:5000/health |
<O2_USER_EMAIL> / <O2_PASSWORD_OR_TOKEN> | An OpenObserve login, used only for the optional API check in step A3/B3 | OpenObserve | ingest@example.com |
To build <BASE64_CREDENTIALS> yourself:
- RHEL:
echo -n '<O2_USER_EMAIL>:<O2_PASSWORD_OR_TOKEN>' | base64 - Windows PowerShell:
[Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes('<O2_USER_EMAIL>:<O2_PASSWORD_OR_TOKEN>'))
Use a dedicated OpenObserve user or service account for ingestion, not a personal administrator login.
Prerequisites
- Administrator rights on the server:
sudoon RHEL, an elevated PowerShell on Windows. - The .NET runtime the application uses is already installed. For IIS, the matching ASP.NET Core Hosting Bundle is installed too.
- Outbound HTTPS (port 443) from the server to
<OPENOBSERVE_URL>. Self-hosted OpenObserve may use port 5080 instead. - Internet access to
github.com. Without it, download the files on another machine and copy them over. - A short restart window for the application, or for IIS. Instrumentation loads at startup.
Automatic instrumentation or eBPF?
On Red Hat Enterprise Linux, you can also trace .NET applications with eBPF instead of the automatic instrumentation in this guide. One OBI service per server traces every application on it from the kernel, with no change to the applications. See the companion OpenObserve eBPF Tracing Guide.
| Use | When |
|---|---|
| Automatic instrumentation (this guide) | You need complete traces for async code, framework detail (ASP.NET Core routes, SqlClient statements, exceptions, custom spans), the server runs Windows or IIS, or you can't run a root-level service |
| eBPF | You want broad coverage quickly, can't change how applications start, or also run services with no agent |
In testing, eBPF traced the .NET sample application, but linked it only partially. The outgoing call and the downstream request were linked; the incoming request was a separate trace, because eBPF can't follow .NET's async handoff between threads. For complete .NET traces, use this guide. Both methods can run on the same server. OBI automatically skips applications that use the automatic instrumentation.
Part A: Red Hat Enterprise Linux
Run every command as a user with sudo rights on the application server. Commands without placeholders can be copied as they are.
Step A1. Install and configure the OpenTelemetry Collector
A1.1 Download the Collector package and verify its checksum. On ARM servers, set ARCH=arm64.
OTEL_VERSION=0.166.0
ARCH=amd64
BASE=https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v${OTEL_VERSION}
cd /tmp
curl -LO ${BASE}/otelcol-contrib_${OTEL_VERSION}_linux_${ARCH}.rpm
curl -LO ${BASE}/otelcol-contrib_${OTEL_VERSION}_linux_${ARCH}.rpm.sha256
echo "$(cat otelcol-contrib_${OTEL_VERSION}_linux_${ARCH}.rpm.sha256) otelcol-contrib_${OTEL_VERSION}_linux_${ARCH}.rpm" | sha256sum -c -Expected output: otelcol-contrib_0.166.0_linux_amd64.rpm: OK
A1.2 Install the package. This creates the otelcol-contrib systemd service and the /etc/otelcol-contrib/ folder.
sudo dnf install -y ./otelcol-contrib_${OTEL_VERSION}_linux_${ARCH}.rpmA1.3 Write the Collector configuration. This file contains no values of yours; they come from the next step. Copy the whole block as it is.
sudo cp /etc/otelcol-contrib/config.yaml /etc/otelcol-contrib/config.yaml.orig
sudo tee /etc/otelcol-contrib/config.yaml >/dev/null <<'EOF'
extensions:
health_check:
endpoint: 127.0.0.1:13133
receivers:
otlp:
protocols:
grpc:
endpoint: 127.0.0.1:4317
http:
endpoint: 127.0.0.1:4318
processors:
memory_limiter:
check_interval: 1s
limit_percentage: 80
spike_limit_percentage: 25
resource_detection:
detectors: [env, system]
system:
hostname_sources: [os]
batch:
send_batch_size: 1024
timeout: 5s
exporters:
otlp_http/openobserve:
endpoint: ${env:O2_OTLP_ENDPOINT}
headers:
Authorization: "Basic ${env:O2_AUTH_TOKEN}"
stream-name: ${env:O2_TRACE_STREAM}
compression: gzip
retry_on_failure:
enabled: true
sending_queue:
enabled: true
queue_size: 5000
service:
extensions: [health_check]
pipelines:
traces:
receivers: [otlp]
processors: [memory_limiter, resource_detection, batch]
exporters: [otlp_http/openobserve]
EOFThe Collector listens only on 127.0.0.1, so only applications on this server can send to it. To accept traces from other servers too, change the two receiver endpoints to 0.0.0.0:4317 and 0.0.0.0:4318, and open those ports in the firewall (A1.6).
A1.4 Enter your OpenObserve values. ✏️ Replace the three placeholders, then run:
sudo tee -a /etc/otelcol-contrib/otelcol-contrib.conf >/dev/null <<'EOF'
O2_OTLP_ENDPOINT=<OPENOBSERVE_URL>/api/<ORG_ID>
O2_AUTH_TOKEN=<BASE64_CREDENTIALS>
O2_TRACE_STREAM=<TRACE_STREAM>
EOF
sudo chown root:otelcol-contrib /etc/otelcol-contrib/otelcol-contrib.conf
sudo chmod 640 /etc/otelcol-contrib/otelcol-contrib.confFilled in, the three lines look like this:
O2_OTLP_ENDPOINT=https://o2.example.com/api/default
O2_AUTH_TOKEN=dXNlcjpwYXNz
O2_TRACE_STREAM=defaultDon't add /v1/traces to the endpoint; the Collector adds it. Don't add Basic to the token; the configuration adds it.
A1.5 Check the configuration, then start the Collector:
sudo bash -c 'set -a; . /etc/otelcol-contrib/otelcol-contrib.conf; otelcol-contrib validate --config=/etc/otelcol-contrib/config.yaml' && echo CONFIG OK
sudo systemctl enable otelcol-contrib
sudo systemctl restart otelcol-contrib
sudo systemctl status otelcol-contrib --no-pager
curl -s http://127.0.0.1:13133Expected: CONFIG OK, status active (running), and {"status":"Server available",...}.
A1.6 (Only if other servers send to this Collector) Open the firewall:
sudo firewall-cmd --permanent --add-port=4317/tcp --add-port=4318/tcp
sudo firewall-cmd --reloadA1.7 Send a test trace from the Collector to OpenObserve. This confirms the connection and credentials before you touch the application.
NOW=$(date +%s); TID=$(openssl rand -hex 16); SID=$(openssl rand -hex 8)
curl -s -w ' HTTP %{http_code}\n' -X POST http://127.0.0.1:4318/v1/traces -H 'Content-Type: application/json' -d '{"resourceSpans":[{"resource":{"attributes":[{"key":"service.name","value":{"stringValue":"collector-smoke-test"}}]},"scopeSpans":[{"spans":[{"traceId":"'$TID'","spanId":"'$SID'","name":"smoke-test","kind":1,"startTimeUnixNano":"'${NOW}000000000'","endTimeUnixNano":"'${NOW}500000000'"}]}]}]}'Expected: {"partialSuccess":{}} HTTP 200. Within about 10 seconds, a service named collector-smoke-test appears under Traces in OpenObserve. If it doesn't, check sudo journalctl -u otelcol-contrib -n 50 --no-pager and see Troubleshooting.
Step A2. Instrument the .NET application
A2.1 Download the instrumentation and verify its checksum. ✏️ Replace <OTEL_DOTNET_VERSION> (see "Which instrumentation version to install"):
sudo dnf install -y unzip
OTEL_DOTNET_VERSION=<OTEL_DOTNET_VERSION>
DN_ARCH=$(uname -m | sed 's/x86_64/x64/;s/aarch64/arm64/')
ZIP=opentelemetry-dotnet-instrumentation-linux-glibc-${DN_ARCH}.zip
BASE=https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/releases/download/${OTEL_DOTNET_VERSION}
mkdir -p /tmp/otel-dotnet && cd /tmp/otel-dotnet
curl -sSfLO ${BASE}/otel-dotnet-auto-install.sh
curl -sSfLO ${BASE}/checksums.txt
curl -sSfLO ${BASE}/${ZIP}
grep " ${ZIP}" checksums.txt | sha256sum -c -Expected output: opentelemetry-dotnet-instrumentation-linux-glibc-x64.zip: OK
A2.2 Install it to /opt/otel-dotnet-auto. Run this in the same shell as A2.1:
sudo OTEL_DOTNET_AUTO_HOME=/opt/otel-dotnet-auto VERSION=${OTEL_DOTNET_VERSION} \
LOCAL_PATH=/tmp/otel-dotnet/${ZIP} SKIP_RELEASE_VERIFICATION=true \
sh /tmp/otel-dotnet/otel-dotnet-auto-install.sh
sudo install -d -m 1777 /var/log/opentelemetry/dotnet
ls /opt/otel-dotnet-autoSKIP_RELEASE_VERIFICATION=true is needed because the installer otherwise requires the GitHub CLI (gh). You already verified the file's checksum in A2.1.
The install -d line creates the instrumentation's log folder. Applications that run as a non-root user can't create it themselves, and without it A2.5 shows no log.
A2.3 Create the tracing settings file for the application. ✏️ Replace <APP_UNIT>, <SERVICE_NAME>, <ENVIRONMENT> and <SERVICE_VERSION>. Run it in the same shell as A2.1, so that DN_ARCH is set.
sudo tee /etc/sysconfig/<APP_UNIT>-otel >/dev/null <<EOF
OTEL_DOTNET_AUTO_HOME=/opt/otel-dotnet-auto
CORECLR_ENABLE_PROFILING=1
CORECLR_PROFILER={918728DD-259F-4A6A-AC2B-B85E1B658318}
CORECLR_PROFILER_PATH=/opt/otel-dotnet-auto/linux-${DN_ARCH}/OpenTelemetry.AutoInstrumentation.Native.so
DOTNET_STARTUP_HOOKS=/opt/otel-dotnet-auto/net/OpenTelemetry.AutoInstrumentation.StartupHook.dll
OTEL_SERVICE_NAME=<SERVICE_NAME>
OTEL_RESOURCE_ATTRIBUTES=deployment.environment.name=<ENVIRONMENT>,service.version=<SERVICE_VERSION>
OTEL_TRACES_EXPORTER=otlp
OTEL_METRICS_EXPORTER=none
OTEL_LOGS_EXPORTER=none
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:4318
EOF
cat /etc/sysconfig/<APP_UNIT>-otelCheck that the CORECLR_PROFILER_PATH line shows linux-x64 (or linux-arm64 on ARM servers).
A2.4 Attach the settings to the application's service. ✏️ Replace <APP_UNIT> in both places:
sudo mkdir -p /etc/systemd/system/<APP_UNIT>.service.d
sudo tee /etc/systemd/system/<APP_UNIT>.service.d/otel.conf >/dev/null <<'EOF'
[Service]
EnvironmentFile=/etc/sysconfig/<APP_UNIT>-otel
EOFIf the application isn't a systemd service, run . /opt/otel-dotnet-auto/instrument.sh in its start script before the dotnet command, and export the OTEL_* lines from A2.3 there.
A2.5 Restart the application and confirm the instrumentation loaded. ✏️ Replace <APP_UNIT> and <APP_URL>:
sudo systemctl daemon-reload
sudo systemctl restart <APP_UNIT>
curl -s <APP_URL> > /dev/null
sudo grep -h 'Rule Engine' /var/log/opentelemetry/dotnet/*StartupHook*.log | tail -3Expected: Rule Engine: MinSupportedFrameworkRule evaluation success. If you see Not supported .NET version instead, you installed the wrong version for the application's runtime; repeat A2.1–A2.2 with the correct <OTEL_DOTNET_VERSION>.
Step A3. Verify traces in OpenObserve
- Send a few requests to the application, or wait for normal traffic.
- In OpenObserve, open Traces, select the
<TRACE_STREAM>stream and the Last 15 minutes time range. - Filter on
service_name = '<SERVICE_NAME>'. Your requests appear within about 10 seconds. - Open a trace. It shows the incoming request (for example
GET /orders) with child spans for database queries and outgoing HTTP calls. Calls to other instrumented services appear in the same trace.
Optional check from the command line. ✏️ Replace the placeholders:
END=$(($(date +%s)*1000000)); START=$((END-3600*1000000))
cat > /tmp/q.json <<EOF
{"query":{"sql":"SELECT service_name, count(*) AS spans FROM \"<TRACE_STREAM>\" GROUP BY service_name","start_time":$START,"end_time":$END}}
EOF
curl -s -u '<O2_USER_EMAIL>:<O2_PASSWORD_OR_TOKEN>' -H 'Content-Type: application/json' \
"<OPENOBSERVE_URL>/api/<ORG_ID>/_search?type=traces" -d @/tmp/q.jsonExpected: a hits list that includes <SERVICE_NAME> with a span count above 0.
Repeat Part A on every RHEL application server. Use a different <SERVICE_NAME> for each application, but the same name for every server that runs the same application.
Part B: Windows Server
Run every command in PowerShell as Administrator on the application server. Commands without placeholders can be copied as they are.
Step B1. Install and configure the OpenTelemetry Collector
B1.1 Download the Collector installer and verify its checksum:
$v = '0.166.0'
$base = "https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v$v"
$msi = "otelcol-contrib_${v}_windows_x64.msi"
New-Item -ItemType Directory -Force C:\temp | Out-Null; Set-Location C:\temp
Invoke-WebRequest "$base/$msi" -OutFile $msi
Invoke-WebRequest "$base/$msi.sha256" -OutFile "$msi.sha256"
$expected = (Get-Content "$msi.sha256" -Raw).Trim().Split(' ')[0]
if ((Get-FileHash $msi -Algorithm SHA256).Hash -ne $expected.ToUpper()) { throw 'Checksum mismatch - do not install' } else { 'Checksum OK' }B1.2 Install the Collector. This creates the Windows service otelcol-contrib (automatic start) and the folder C:\Program Files\OpenTelemetry Collector\.
Start-Process msiexec.exe -Wait -ArgumentList "/i `"C:\temp\$msi`" /qn /l*v C:\temp\otelcol-install.log"
Get-Service otelcol-contribB1.3 Write the Collector configuration. This file contains no values of yours; they come from the next step. Copy the whole block as it is.
$dir = 'C:\Program Files\OpenTelemetry Collector'
Copy-Item "$dir\config.yaml" "$dir\config.yaml.orig" -Force
@'
extensions:
health_check:
endpoint: 127.0.0.1:13133
receivers:
otlp:
protocols:
grpc:
endpoint: 127.0.0.1:4317
http:
endpoint: 127.0.0.1:4318
processors:
memory_limiter:
check_interval: 1s
limit_percentage: 80
spike_limit_percentage: 25
resource_detection:
detectors: [env, system]
system:
hostname_sources: [os]
batch:
send_batch_size: 1024
timeout: 5s
exporters:
otlp_http/openobserve:
endpoint: ${env:O2_OTLP_ENDPOINT}
headers:
Authorization: "Basic ${env:O2_AUTH_TOKEN}"
stream-name: ${env:O2_TRACE_STREAM}
compression: gzip
retry_on_failure:
enabled: true
sending_queue:
enabled: true
queue_size: 5000
service:
extensions: [health_check]
pipelines:
traces:
receivers: [otlp]
processors: [memory_limiter, resource_detection, batch]
exporters: [otlp_http/openobserve]
'@ | Set-Content -Path "$dir\config.yaml" -Encoding asciiTo accept traces from other servers too, change the two receiver endpoints to 0.0.0.0:4317 and 0.0.0.0:4318, and open the firewall (B1.6).
B1.4 Enter your OpenObserve values. ✏️ Replace the three placeholders, then run. The values are stored on the Collector service only; other programs can't see them.
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\otelcol-contrib' -Name Environment -Type MultiString -Value @(
'O2_OTLP_ENDPOINT=<OPENOBSERVE_URL>/api/<ORG_ID>',
'O2_AUTH_TOKEN=<BASE64_CREDENTIALS>',
'O2_TRACE_STREAM=<TRACE_STREAM>'
)Filled in, the first line looks like 'O2_OTLP_ENDPOINT=https://o2.example.com/api/default',. Don't add /v1/traces or Basic .
B1.5 Check the configuration, then restart the Collector. ✏️ Use the same three values as in B1.4:
$env:O2_OTLP_ENDPOINT = '<OPENOBSERVE_URL>/api/<ORG_ID>'; $env:O2_AUTH_TOKEN = '<BASE64_CREDENTIALS>'; $env:O2_TRACE_STREAM = '<TRACE_STREAM>'
& 'C:\Program Files\OpenTelemetry Collector\otelcol-contrib.exe' validate --config 'C:\Program Files\OpenTelemetry Collector\config.yaml'; if ($LASTEXITCODE -eq 0) { 'CONFIG OK' }
Restart-Service otelcol-contrib
Get-Service otelcol-contrib
(Invoke-WebRequest http://127.0.0.1:13133 -UseBasicParsing).ContentExpected: CONFIG OK, status Running, and {"status":"Server available",...}.
B1.6 (Only if other servers send to this Collector) Open the firewall:
New-NetFirewallRule -DisplayName 'OpenTelemetry Collector OTLP' -Direction Inbound -Protocol TCP -LocalPort 4317,4318 -Action AllowB1.7 Send a test trace from the Collector to OpenObserve:
$now = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds()
$tid = -join ((1..32) | % { '{0:x}' -f (Get-Random -Max 16) }); $sid = -join ((1..16) | % { '{0:x}' -f (Get-Random -Max 16) })
$body = '{"resourceSpans":[{"resource":{"attributes":[{"key":"service.name","value":{"stringValue":"collector-smoke-test"}}]},"scopeSpans":[{"spans":[{"traceId":"' + $tid + '","spanId":"' + $sid + '","name":"smoke-test","kind":1,"startTimeUnixNano":"' + ($now*1000000) + '","endTimeUnixNano":"' + (($now+500)*1000000) + '"}]}]}]}'
$r = Invoke-WebRequest -Uri http://127.0.0.1:4318/v1/traces -Method Post -ContentType 'application/json' -Body $body -UseBasicParsing
"HTTP $($r.StatusCode) $($r.Content)"Expected: HTTP 200 {"partialSuccess":{}}. Within about 10 seconds, the service collector-smoke-test appears under Traces in OpenObserve. Collector messages are in Event Viewer → Windows Logs → Application; filter on source otelcol-contrib.
Step B2. Instrument the .NET application
B2.1 Download the instrumentation and verify its checksum. ✏️ Replace <OTEL_DOTNET_VERSION> (see "Which instrumentation version to install"):
$ver = '<OTEL_DOTNET_VERSION>'
$base = "https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/releases/download/$ver"
Set-Location C:\temp
Invoke-WebRequest "$base/OpenTelemetry.DotNet.Auto.psm1" -OutFile C:\temp\OpenTelemetry.DotNet.Auto.psm1
Invoke-WebRequest "$base/opentelemetry-dotnet-instrumentation-windows.zip" -OutFile C:\temp\opentelemetry-dotnet-instrumentation-windows.zip
Invoke-WebRequest "$base/checksums.txt" -OutFile C:\temp\checksums.txt
$expected = ((Get-Content C:\temp\checksums.txt) -match ' opentelemetry-dotnet-instrumentation-windows.zip$').Split(' ')[0]
if ((Get-FileHash C:\temp\opentelemetry-dotnet-instrumentation-windows.zip -Algorithm SHA256).Hash -ne $expected.ToUpper()) { throw 'Checksum mismatch - do not install' } else { 'Checksum OK' }B2.2 Install it. It goes to C:\Program Files\OpenTelemetry .NET AutoInstrumentation:
Import-Module C:\temp\OpenTelemetry.DotNet.Auto.psm1
Install-OpenTelemetryCore -LocalPath C:\temp\opentelemetry-dotnet-instrumentation-windows.zip -SkipReleaseVerification
Get-OpenTelemetryInstallVersion-SkipReleaseVerification is needed because the module otherwise requires the GitHub CLI (gh). You already verified the checksum in B2.1. A warning that verification is skipped is expected.
B2.3 Turn on tracing for the application. Follow one of the two options: a Windows service (option 1) or IIS (option 2).
Option 1 – the application runs as a Windows service. ✏️ Replace <WINDOWS_SERVICE>, <SERVICE_NAME>, <ENVIRONMENT> and <SERVICE_VERSION>:
Import-Module C:\temp\OpenTelemetry.DotNet.Auto.psm1
$svc = '<WINDOWS_SERVICE>'
Register-OpenTelemetryForWindowsService -WindowsServiceName $svc -OTelServiceName '<SERVICE_NAME>'
$key = "HKLM:\SYSTEM\CurrentControlSet\Services\$svc"
$current = @((Get-ItemProperty $key -Name Environment).Environment | Where-Object { $_ })
$otel = @(
'OTEL_RESOURCE_ATTRIBUTES=deployment.environment.name=<ENVIRONMENT>,service.version=<SERVICE_VERSION>',
'OTEL_TRACES_EXPORTER=otlp',
'OTEL_METRICS_EXPORTER=none',
'OTEL_LOGS_EXPORTER=none',
'OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf',
'OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:4318'
)
Set-ItemProperty $key -Name Environment -Type MultiString -Value ($current + $otel)
Restart-Service $svc
(Get-ItemProperty $key).EnvironmentThe last command lists the service's settings. They include the CORECLR_* / COR_* lines added by Register-OpenTelemetryForWindowsService, OTEL_SERVICE_NAME=<SERVICE_NAME>, and the six lines above.
Option 2 – the application runs in IIS.
- Register the instrumentation with IIS. This restarts IIS (
iisreset), so do it in a maintenance window. Every application pool on the server loads the instrumentation afterwards; settings in step 2 decide what is sent and under which name.
Import-Module C:\temp\OpenTelemetry.DotNet.Auto.psm1
Register-OpenTelemetryForIIS- Give the site its name and settings. ✏️ Open
<IIS_SITE_PATH>\web.configand add an<environmentVariables>block inside the existing<aspNetCore ...>element, replacing<SERVICE_NAME>,<ENVIRONMENT>and<SERVICE_VERSION>. Keep your existingprocessPath,argumentsand other attributes.
<aspNetCore processPath="dotnet" arguments=".\YourApp.dll" hostingModel="inprocess">
<environmentVariables>
<environmentVariable name="OTEL_SERVICE_NAME" value="<SERVICE_NAME>" />
<environmentVariable name="OTEL_RESOURCE_ATTRIBUTES" value="deployment.environment.name=<ENVIRONMENT>,service.version=<SERVICE_VERSION>" />
<environmentVariable name="OTEL_TRACES_EXPORTER" value="otlp" />
<environmentVariable name="OTEL_METRICS_EXPORTER" value="none" />
<environmentVariable name="OTEL_LOGS_EXPORTER" value="none" />
<environmentVariable name="OTEL_EXPORTER_OTLP_PROTOCOL" value="http/protobuf" />
<environmentVariable name="OTEL_EXPORTER_OTLP_ENDPOINT" value="http://127.0.0.1:4318" />
</environmentVariables>
</aspNetCore>For a .NET Framework (classic ASP.NET) site, which has no <aspNetCore> element, add the same names and values as keys under <appSettings> in web.config: <add key="OTEL_SERVICE_NAME" value="<SERVICE_NAME>" />, and so on.
- Recycle the site's application pool. Saving
web.configusually does this automatically, or runRestart-WebAppPool '<app pool name>'.
B2.4 Send a request and confirm the instrumentation loaded. ✏️ Replace <APP_URL>:
Invoke-WebRequest '<APP_URL>' -UseBasicParsing | Out-Null
Get-ChildItem "$env:ProgramData\OpenTelemetry .NET AutoInstrumentation\logs" | Sort-Object LastWriteTime | Select-Object -Last 3 Name, LastWriteTimeThe instrumentation logs are in %ProgramData%\OpenTelemetry .NET AutoInstrumentation\logs. A log whose name contains StartupHook with evaluation success lines means tracing is active. A line with Not supported .NET version means you installed the wrong version for the runtime; uninstall it with Uninstall-OpenTelemetryCore, then repeat B2.1–B2.2 with the correct <OTEL_DOTNET_VERSION>.
Step B3. Verify traces in OpenObserve
- Send a few requests to the application, or wait for normal traffic.
- In OpenObserve, open Traces, select the
<TRACE_STREAM>stream and the Last 15 minutes time range. - Filter on
service_name = '<SERVICE_NAME>'. Your requests appear within about 10 seconds. - Open a trace. It shows the incoming request with child spans for database queries and outgoing HTTP calls.
Optional check from PowerShell. ✏️ Replace the placeholders:
$end = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds() * 1000; $start = $end - 3600000000
$body = @{ query = @{ sql = 'SELECT service_name, count(*) AS spans FROM "<TRACE_STREAM>" GROUP BY service_name'; start_time = $start; end_time = $end } } | ConvertTo-Json
$auth = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes('<O2_USER_EMAIL>:<O2_PASSWORD_OR_TOKEN>'))
(Invoke-RestMethod -Method Post -Uri '<OPENOBSERVE_URL>/api/<ORG_ID>/_search?type=traces' -Headers @{ Authorization = "Basic $auth" } -ContentType 'application/json' -Body $body).hitsExpected: a row for <SERVICE_NAME> with a span count above 0.
Repeat Part B on every Windows application server.
Troubleshooting
Start with the Collector test trace (A1.7 / B1.7). If collector-smoke-test reaches OpenObserve, the connection to OpenObserve is fine, and the problem is between the application and the Collector. If it doesn't arrive, fix the Collector first.
Where to look:
- Collector log. RHEL:
sudo journalctl -u otelcol-contrib -n 100 --no-pager. Windows: Event Viewer → Windows Logs → Application, sourceotelcol-contrib. - Instrumentation logs. RHEL:
/var/log/opentelemetry/dotnet/. Windows:%ProgramData%\OpenTelemetry .NET AutoInstrumentation\logs\.
| Symptom | Cause | Fix |
|---|---|---|
Instrumentation log shows Not supported .NET version (lower than 10.0) or Rule 'Minimum Supported Framework Version Validator' failed | v1.20.0 installed for a .NET 8 or .NET 9 application | Install v1.19.0 instead, or upgrade the application to .NET 10 |
Instrumentation log warns .NET8 reached End Of Support | v1.19.0 on .NET 8 | Tracing works. Plan the upgrade to .NET 10 |
Installer stops with The GitHub CLI ('gh') is required to verify release assets | The release-verification option was left out | Use the commands exactly as in A2.2 / B2.2 |
Collector log shows 401 or 403 | Wrong <BASE64_CREDENTIALS>, or the user has no access to <ORG_ID> | Rebuild the Base64 value from email:password-or-token and check the org ID. Restart the Collector |
Collector log shows 404 | Wrong endpoint path | O2_OTLP_ENDPOINT must be <OPENOBSERVE_URL>/api/<ORG_ID>, without /v1/traces |
Collector log shows connection refused, a timeout, or a TLS error | No network route or a proxy in between | Test with curl -I <OPENOBSERVE_URL>. If you need a proxy, add HTTPS_PROXY=http://<proxy-host>:<port> next to the other O2_* values |
| No instrumentation log, and no traces (RHEL) | The settings aren't attached to the service | systemctl cat <APP_UNIT> must show otel.conf. The CORECLR_PROFILER_PATH file in A2.3 must exist |
| No traces from a Windows service | Exporter settings were not added, or the service's Environment list was overwritten | Run Option 1 of B2.3 again; it keeps the existing entries and adds the missing ones |
| No traces from IIS | Register-OpenTelemetryForIIS not run, or web.config values missing | Run it again (it restarts IIS), and check the <environmentVariables> block |
| Application logs errors exporting metrics or logs | OTEL_METRICS_EXPORTER / OTEL_LOGS_EXPORTER missing | Set both to none; this setup collects traces only |
| Calls between services show as separate traces | A proxy or API gateway removes the traceparent header | Configure it to forward the traceparent and tracestate headers |
| Too much trace volume | Every request is traced | Add OTEL_TRACES_SAMPLER=parentbased_traceidratio and OTEL_TRACES_SAMPLER_ARG=0.1 (10%) to the application settings |
For more detail, add OTEL_LOG_LEVEL=debug to the application settings for a short time.
To remove tracing:
- RHEL: delete the files from A2.3 and A2.4, then restart the application.
- Windows service: run
Unregister-OpenTelemetryForWindowsService -WindowsServiceName '<WINDOWS_SERVICE>', remove theOTEL_*entries from B2.3, then restart the service. - IIS: run
Unregister-OpenTelemetryForIIS, which restarts IIS. - Uninstall completely (Windows): run
Uninstall-OpenTelemetryCoreafter the steps above.
Tested versions
This procedure was tested end to end on Red Hat Enterprise Linux 9.9 and Windows Server 2022 with the versions below. On Windows it was tested as a console application, as a Windows service, and under IIS. Other versions usually work. Before upgrading a component, check its release notes for removed settings.
| Component | Version |
|---|---|
| OpenTelemetry Collector Contrib | 0.166.0 |
| OpenTelemetry .NET automatic instrumentation | v1.20.0 (.NET 10) and v1.19.0 (.NET 8) |
| .NET | 10.0.15 (RHEL and Windows), 8.0 (RHEL) |
| ASP.NET Core Hosting Bundle (IIS) | 10.0.15 |
| OpenObserve | v1.2.0 |
For the full list of auto-instrumented libraries, see OpenTelemetry .NET automatic instrumentation.