-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Windows script to install Splunk distro for .NET instead of SFx.NET #4343
Changes from 3 commits
c2b432b
a54deb8
7e68e73
a283f82
47dd750
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -159,20 +159,20 @@ jobs: | |
name: msi-build | ||
path: ./tests/zeroconfig/windows/testdata/docker-setup/ | ||
|
||
- name: Get latest signalfx-dotnet-tracing release | ||
id: dotnet-tracing | ||
- name: Get latest splunk-otel-dotnet release | ||
id: dotnet-instrumentation | ||
uses: pozetroninc/[email protected] | ||
with: | ||
owner: signalfx | ||
repo: signalfx-dotnet-tracing | ||
repo: splunk-otel-dotnet | ||
excludes: prerelease, draft | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Set SIGNALFX_DOTNET_TRACING_VERSION | ||
- name: Set SPLUNK_OTEL_DOTNET_VERSION | ||
run: | | ||
version="${{ steps.dotnet-tracing.outputs.release }}" | ||
sed -i "s|SIGNALFX_DOTNET_TRACING_VERSION|${version#v}|" tests/zeroconfig/windows/testdata/resource_traces/aspnetcore.yaml | ||
sed -i "s|SIGNALFX_DOTNET_TRACING_VERSION|${version#v}|" tests/zeroconfig/windows/testdata/resource_traces/aspnetfx.yaml | ||
version="${{ steps.dotnet-instrumentation.outputs.release }}" | ||
sed -i "s|SPLUNK_OTEL_DOTNET_VERSION|${version#v}|" tests/zeroconfig/windows/testdata/resource_traces/aspnetcore.yaml | ||
sed -i "s|SPLUNK_OTEL_DOTNET_VERSION|${version#v}|" tests/zeroconfig/windows/testdata/resource_traces/aspnetfx.yaml | ||
shell: bash | ||
|
||
- name: Run the test script | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,7 +73,7 @@ | |
.EXAMPLE | ||
.\install.ps1 -access_token "ACCESSTOKEN" -with_dotnet_instrumentation $true | ||
.PARAMETER deployment_env | ||
(OPTIONAL) A system-wide SignalFx "environment" used by .NET instrumentation. Sets the SIGNALFX_ENV environment variable. Ignored if -with_dotnet_instrumentation is false. | ||
(OPTIONAL) A system-wide "deployment.environment" set via the environment variable 'OTEL_RESOURCE_ATTRIBUTES' for the whole machine. Ignored if -with_dotnet_instrumentation is false. | ||
.EXAMPLE | ||
.\install.ps1 -access_token "ACCESSTOKEN" -with_dotnet_instrumentation $true -deployment_env staging | ||
.PARAMETER bundle_dir | ||
|
@@ -414,7 +414,7 @@ function download_collector_package([string]$collector_version=$collector_versio | |
} | ||
|
||
# check registry for the agent msi package | ||
function msi_installed([string]$name="Splunk OpenTelemetry Collector") { | ||
function msi_installed([string]$name) { | ||
return (Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Where { $_.DisplayName -eq $name }) -ne $null | ||
} | ||
|
||
|
@@ -471,7 +471,7 @@ if (!(check_if_admin)) { | |
echo 'Checking execution policy' | ||
check_policy | ||
|
||
if (msi_installed) { | ||
if (msi_installed -name "Splunk OpenTelemetry Collector") { | ||
throw "The Splunk OpenTelemetry Collector is already installed. Remove or uninstall the Collector and rerun this script." | ||
} | ||
|
||
|
@@ -491,16 +491,16 @@ if ($with_fluentd -And (Test-Path -Path "$fluentd_base_dir\bin\fluentd")) { | |
$tempdir = create_temp_dir -tempdir $tempdir | ||
|
||
if ($with_dotnet_instrumentation) { | ||
echo "Installing SignalFx Instrumentation for .NET ..." | ||
$module_name = "Splunk.SignalFx.DotNet.psm1" | ||
$download = "https://github.com/signalfx/signalfx-dotnet-tracing/releases/latest/download/Splunk.SignalFx.DotNet.psm1" | ||
if ((msi_installed -name "SignalFx .NET Tracing 64-bit") -Or (msi_installed -name "SignalFx .NET Tracing 32-bit")) { | ||
throw "SignalFx .NET Instrumentation is already installed. Stop all instrumented applications and uninstall SignalFx Instrumentation for .NET before running this script again." | ||
} | ||
echo "Downloading Splunk Distribution of OpenTelemetry .NET ..." | ||
$module_name = "Splunk.OTel.DotNet.psm1" | ||
$download = "https://github.com/signalfx/splunk-otel-dotnet/releases/latest/download/$module_name" | ||
$dotnet_autoinstr_path = Join-Path $tempdir $module_name | ||
echo "Downloading .NET Instrumentation installer ..." | ||
Invoke-WebRequest -Uri $download -OutFile $dotnet_autoinstr_path -UseBasicParsing | ||
Import-Module $dotnet_autoinstr_path | ||
if (Get-IsSignalFxInstalled) { | ||
throw "SignalFx Instrumentation for .NET is already installed. Remove or uninstall SignalFx Instrumentation for .NET and rerun this script." | ||
} | ||
} | ||
|
||
if ($ingest_url -eq "") { | ||
|
@@ -689,28 +689,50 @@ restarted to apply the changes by restarting the system or running the following | |
echo "$message" | ||
} | ||
|
||
if ($with_dotnet_instrumentation) { | ||
echo "Installing SignalFx Dotnet Auto Instrumentation..." | ||
Install-SignalFxDotnet | ||
$otel_resource_attributes = "" | ||
if ($deployment_env -ne "") { | ||
echo "Setting deployment environment to $deployment_env" | ||
$otel_resource_attributes = "deployment.environment=$deployment_env" | ||
} else { | ||
echo "Deployment environment was not specified. Unless otherwise defined, will appear as 'unknown' in the UI." | ||
} | ||
|
||
$regkey = "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" | ||
if ($deployment_env -ne "") { | ||
echo "Setting SIGNALFX_ENV environment variable to $deployment_env ..." | ||
update_registry -path "$regkey" -name "SIGNALFX_ENV" -value "$deployment_env" | ||
if ($with_dotnet_instrumentation) { | ||
echo "Installing Splunk Distribution of OpenTelemetry .NET..." | ||
$currentInstallVersion = Get-OpenTelemetryInstallVersion | ||
if (-not $currentInstallVersion) { | ||
Install-OpenTelemetryCore | ||
} else { | ||
echo "SIGNALFX_ENV environment variable not set. Unless otherwise defined, will appear as 'unknown' in the UI." | ||
Update-OpenTelemetryCore | ||
} | ||
|
||
$installed_version = Get-OpenTelemetryInstallVersion | ||
if ($otel_resource_attributes -ne "") { | ||
$otel_resource_attributes += "," | ||
} | ||
$otel_resource_attributes += "splunk.zc.method=splunk-otel-dotnet-$installed_version" | ||
} | ||
|
||
if ($otel_resource_attributes -ne "") { | ||
# The OTEL_RESOURCE_ATTRIBUTES environment variable must be set before restarting IIS. | ||
$regkey = "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" | ||
try { | ||
$dotnet_version = (Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Where { $_.DisplayName -eq "SignalFx .NET Tracing 64-bit" }).DisplayVersion | ||
update_registry -path "$regkey" -name "SIGNALFX_GLOBAL_TAGS" "splunk.zc.method:signalfx-dotnet-tracing-${dotnet_version}" | ||
update_registry -path "$regkey" -name "OTEL_RESOURCE_ATTRIBUTES" -value "$otel_resource_attributes" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure what to do here, but There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't want to change this on this PR but the main thing here to me is that the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess the conflict is getting even bigger then? ... since envs don't stack by default and There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We will have to investigate this separately, likely also changing the value that we use for OTel resource attributes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After writing the answer to Aunsh I think it will make more sense to just bail out here: it will be consistent with what is done for the collector MSI: the script just bails out if there is already one version installed. We are also bailing out if SFx.NET is already installed. |
||
} catch { | ||
Write-Warning "Failed to set OTEL_RESOURCE_ATTRIBUTES environment variable." | ||
continue | ||
} | ||
} | ||
|
||
if ($with_dotnet_instrumentation) { | ||
if (service_installed -name "W3SVC") { | ||
echo "Registering OpenTelemetry for IIS..." | ||
Register-OpenTelemetryForIIS | ||
} | ||
|
||
$message = " | ||
SignalFx .NET Instrumentation has been installed and configured to forward traces to the Splunk OpenTelemetry Collector. | ||
By default, .NET Instrumentation will automatically generate traces for applications running on IIS. | ||
Splunk Distribution of OpenTelemetry for .NET has been installed and configured to forward traces to the Splunk OpenTelemetry Collector. | ||
By default, the .NET instrumentation will automatically generate telemetry only for .NET applications running on IIS. | ||
" | ||
echo "$message" | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is a risk of doing unwanted silent update?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. Most of the time the instrumented applications are running in IIS and the update will stop and recycle them which seems what the typical user wants. However, if there are instrumented .NET applications outside IIS then the update will fail when copying files which probably is not very helpful. Let me think a bit more about this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a283f82
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking maybe to fail with a specific message "... dotnet is already installed, run the install script again with -UpdateDotnet to update the agent'" 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The warning message is
Splunk Distribution of OpenTelemetry .NET is already installed. Updating to the latest version...
and will be displayed before any error so I think it gives enough context in case of an error updating.