Skip to content
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

Set env vars for service instead of machine #3930

Merged
merged 78 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from 75 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
e6a4634
Set env vars for service instead of machine
pjanotti Nov 17, 2023
8dd68c7
Fix copy and pasted typo
pjanotti Nov 17, 2023
810e4f0
Remove unused variable
pjanotti Nov 17, 2023
e5858d6
Update chocolatey to use env vars at the service scope
pjanotti Nov 17, 2023
d50a9c5
Fix check for "SPLUNK_ACCESS_TOKEN"
pjanotti Nov 17, 2023
640e405
Handle upgrade in chocolatey
pjanotti Nov 17, 2023
50a8cb5
Get-Package not available on all Windows versions
pjanotti Nov 18, 2023
aecc559
Add messages to track stage on chocolatey install
pjanotti Nov 18, 2023
bf7f0a4
Adding more messages to chocolatey script
pjanotti Nov 18, 2023
da12a5b
Fix service on the registry but no env
pjanotti Nov 18, 2023
fe6a0ce
Restore $regKey on install.ps1
pjanotti Nov 18, 2023
e091ad7
Add helper allow running the collector manually on Windows
pjanotti Nov 27, 2023
5282d07
Add breaking change to CHANGELOG.md
pjanotti Nov 27, 2023
43f49f1
Add -config_path switch to install.ps1
pjanotti Dec 1, 2023
224ab0b
Fix pipeline collector for Windows ZC IIS test
pjanotti Dec 1, 2023
51ed501
MSI to set SPLUNK_CONFIG at the service scope
pjanotti Dec 4, 2023
9a5310a
Merge branch 'main' into move-windows-env-vars-to-service
pjanotti Dec 4, 2023
75638da
Minor doc updates
pjanotti Dec 6, 2023
a82a0bf
Update ansible tests for Windows env vars
pjanotti Dec 7, 2023
bb0cce6
Merge branch 'main' into move-windows-env-vars-to-service
pjanotti Dec 7, 2023
802a505
Correct type of *_ENABLE_PROFILING value
pjanotti Dec 8, 2023
32e46d1
Merge branch 'move-windows-env-vars-to-service' of github.com:pjanott…
pjanotti Dec 8, 2023
96b256a
ansible: Windows deployment updates
pjanotti Dec 8, 2023
35c6573
Merge branch 'main' into move-windows-env-vars-to-service
pjanotti Dec 8, 2023
5b7ab83
fix yamllint issues
pjanotti Dec 8, 2023
3c5c1ab
Merge branch 'move-windows-env-vars-to-service' of github.com:pjanott…
pjanotti Dec 8, 2023
831c6d0
fix yamllint
pjanotti Dec 8, 2023
d3435b8
Merge branch 'main' into move-windows-env-vars-to-service
pjanotti Dec 11, 2023
1ca8eac
Output vagrant.err in case of failure
pjanotti Dec 11, 2023
f51de23
Fix splunk_trace_url check
pjanotti Dec 11, 2023
21944bb
Always try to display the vagrant errors
pjanotti Dec 11, 2023
0d543e5
Check if event log has some info about failure
pjanotti Dec 12, 2023
d51b65a
Merge branch 'main' into move-windows-env-vars-to-service
pjanotti Dec 12, 2023
c399f39
Remove event log steps: running on mac not Windows
pjanotti Dec 12, 2023
c61b1a7
Launch vagrant
pjanotti Dec 13, 2023
82b7846
Init vagrant
pjanotti Dec 13, 2023
44c04f0
Drop launch vagrant step
pjanotti Dec 13, 2023
ffcb73e
Fix ansible Windows
pjanotti Dec 16, 2023
8c8e1bb
Fix yamllint issues
pjanotti Dec 16, 2023
e34afce
Remove vagrant init
pjanotti Jan 2, 2024
9c77ee1
Merge branch 'main' into move-windows-env-vars-to-service
pjanotti Jan 2, 2024
237bc45
Updates to pass local run of molecule tests
pjanotti Jan 4, 2024
94602d8
Merge branch 'main' into move-windows-env-vars-to-service
pjanotti Jan 10, 2024
3658946
Update chef deployment
pjanotti Jan 10, 2024
0719a1e
Merge branch 'main' into move-windows-env-vars-to-service
pjanotti Jan 10, 2024
bf9d767
Proper data type for multi_string registry entry
pjanotti Jan 10, 2024
3c50447
Fix var name typo
pjanotti Jan 10, 2024
d00b8e6
Fix order of collector environment variables
pjanotti Jan 11, 2024
6388b90
Experiment custom_vars test
pjanotti Jan 11, 2024
4ff26c6
Pay attention to conditional variables
pjanotti Jan 11, 2024
069ee45
First try with Puppet
pjanotti Jan 12, 2024
cbaf5d4
Fix syntax for Puppet
pjanotti Jan 13, 2024
1578caa
Back to curly brackets
pjanotti Jan 13, 2024
4f18580
Try extension fixes
pjanotti Jan 13, 2024
50f9c0f
Fix conditional
pjanotti Jan 13, 2024
782aae0
Remove to_s
pjanotti Jan 13, 2024
4d8465e
Use empty instead of is_empty
pjanotti Jan 13, 2024
6bbc178
Fix re-declaration of registry_key
pjanotti Jan 13, 2024
b7dcb09
Fix puppet lint issue
pjanotti Jan 13, 2024
2c3af09
Do not re-use registry_key
pjanotti Jan 13, 2024
e87063b
Use array instead of multi_string
pjanotti Jan 13, 2024
e1cf478
Ensure side effects
pjanotti Jan 13, 2024
2f6ecf4
Update test to use REG_MULTI_SZ
pjanotti Jan 13, 2024
d193f50
Immutability?
pjanotti Jan 13, 2024
faca2ce
Fix lint error
pjanotti Jan 13, 2024
e1ca7c3
Fix test
pjanotti Jan 13, 2024
52a6ebf
Removing name re-use
pjanotti Jan 13, 2024
1b1007f
Update CHANGELOG and README for Puppet
pjanotti Jan 13, 2024
5edf011
Updates to mass deployments docs
pjanotti Jan 13, 2024
eb38784
Update last version deploying with machine wide env vars
pjanotti Jan 16, 2024
b140644
Sort service environment variables set via PowerShell
pjanotti Jan 16, 2024
34925c2
Improve handling of collector restart in Ansible
pjanotti Jan 16, 2024
b8b7005
Remove extra double-quotes in SPLUNK_CONFIG for Ansible
pjanotti Jan 16, 2024
8287246
Fix Ansible verify SPLUNK_CONFIG strings
pjanotti Jan 17, 2024
7b076c6
Fix Windows testing checking for legacy versions of the collector
pjanotti Jan 17, 2024
bc206a2
Update CHANGELOG.md
pjanotti Jan 19, 2024
3ca07b7
Update last version still setting machine wide env vars
pjanotti Jan 19, 2024
33534ea
Merge branch 'main' into move-windows-env-vars-to-service
pjanotti Jan 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
45 changes: 31 additions & 14 deletions .github/workflows/scripts/win-test-services.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,25 @@ param (
$ErrorActionPreference = 'Stop'
Set-PSDebug -Trace 1

function check_regkey([string]$name, [string]$value) {
$actual = Get-ItemPropertyValue -PATH "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -name "$name"
if ( "$value" -ne "$actual" ) {
throw "Environment variable $name is not properly set. Found: '$actual', Expected '$value'"
function check_collector_svc_environment([hashtable]$expected_env_vars) {
$actual_env_vars = @{}
try {
$env_array = Get-ItemPropertyValue -Path "HKLM:\SYSTEM\CurrentControlSet\Services\splunk-otel-collector" -Name "Environment"
foreach ($entry in $env_array) {
$key, $value = $entry.Split("=", 2)
$actual_env_vars.Add($key, $value)
}
} catch {
Write-Host "Assuming an old version of the collector with environment variables at the machine scope"
$actual_env_vars = [Environment]::GetEnvironmentVariables("Machine")<#Do this if a terminating exception happens#>
}

foreach ($key in $expected_env_vars.Keys) {
$expected_value = $expected_env_vars[$key]
$actual_value = $actual_env_vars[$key]
if ($expected_value -ne $actual_value) {
throw "Environment variable $key is not properly set. Found: '$actual_value', Expected '$expected_value'"
}
}
}

Expand All @@ -24,16 +39,18 @@ function service_running([string]$name) {
$api_url = "https://api.${realm}.signalfx.com"
$ingest_url = "https://ingest.${realm}.signalfx.com"

check_regkey -name "SPLUNK_CONFIG" -value "${env:PROGRAMDATA}\Splunk\OpenTelemetry Collector\${mode}_config.yaml"
check_regkey -name "SPLUNK_ACCESS_TOKEN" -value "$access_token"
check_regkey -name "SPLUNK_REALM" -value "$realm"
check_regkey -name "SPLUNK_API_URL" -value "$api_url"
check_regkey -name "SPLUNK_INGEST_URL" -value "$ingest_url"
check_regkey -name "SPLUNK_TRACE_URL" -value "${ingest_url}/v2/trace"
check_regkey -name "SPLUNK_HEC_URL" -value "${ingest_url}/v1/log"
check_regkey -name "SPLUNK_HEC_TOKEN" -value "$access_token"
check_regkey -name "SPLUNK_BUNDLE_DIR" -value "${env:PROGRAMFILES}\Splunk\OpenTelemetry Collector\agent-bundle"
check_regkey -name "SPLUNK_MEMORY_TOTAL_MIB" -value "$memory"
check_collector_svc_environment @{
"SPLUNK_CONFIG" = "${env:PROGRAMDATA}\Splunk\OpenTelemetry Collector\${mode}_config.yaml";
"SPLUNK_ACCESS_TOKEN" = "$access_token";
"SPLUNK_REALM" = "$realm";
"SPLUNK_API_URL" = "$api_url";
"SPLUNK_INGEST_URL" = "$ingest_url";
"SPLUNK_TRACE_URL" = "${ingest_url}/v2/trace";
"SPLUNK_HEC_URL" = "${ingest_url}/v1/log";
"SPLUNK_HEC_TOKEN" = "$access_token";
"SPLUNK_BUNDLE_DIR" = "${env:PROGRAMFILES}\Splunk\OpenTelemetry Collector\agent-bundle";
"SPLUNK_MEMORY_TOTAL_MIB" = "$memory";
}

if ((service_running -name "splunk-otel-collector")) {
write-host "splunk-otel-collector service is running."
Expand Down
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@

## Unreleased

### 🛑 Breaking changes 🛑

- (Splunk) On Windows the `SPLUNK_*` environment variables were moved from the machine scope to the collector service scope.
It is possible that some instrumentations are relying on the machine-wide environment variables set by the installation. ([#3930](https://github.com/signalfx/splunk-otel-collector/pull/3930))
pjanotti marked this conversation as resolved.
Show resolved Hide resolved

## v0.91.3
- (Splunk) Properly sign and associate changelog to release. This should be otherwise identical to v0.91.2


## v0.91.2

### 🛑 Breaking changes 🛑
Expand All @@ -30,7 +36,6 @@
- (Splunk) Adopt `awss3` exporter ([#4117](https://github.com/signalfx/splunk-otel-collector/pull/4117))
- (Splunk) Convert loglevel to verbosity on logging exporter ([#4097](https://github.com/signalfx/splunk-otel-collector/pull/4097))


## v0.91.1

### 💡 Enhancements 💡
Expand Down Expand Up @@ -218,7 +223,6 @@ This Splunk OpenTelemetry Collector release includes changes from the [opentelem
- (Contrib) `zipkinreceiver`: Return BadRequest in case of permanent errors ([#4335](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/4335))
- (Core) `exporterhelper`: fix bug with queue size and capacity metrics ([#8682](https://github.com/open-telemetry/opentelemetry-collector/issues/8682))


## v0.88.0

This Splunk OpenTelemetry Collector release includes changes from the [opentelemetry-collector v0.88.0](https://github.com/open-telemetry/opentelemetry-collector/releases/tag/v0.88.0) and the [opentelemetry-collector-contrib v0.88.0](https://github.com/open-telemetry/opentelemetry-collector-contrib/releases/tag/v0.88.0) releases where appropriate.
Expand Down
3 changes: 3 additions & 0 deletions deployments/ansible/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## unreleased

- On Windows the `SPLUNK_*` environment variables were moved from the machine scope to the collector service scope.
It is possible that some instrumentations are relying on the machine-wide environment variables set by the installation. ([#3930](https://github.com/signalfx/splunk-otel-collector/pull/3930))

## ansible-v0.24.0

### 🚩 Deprecations 🚩
Expand Down
4 changes: 4 additions & 0 deletions deployments/ansible/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ Currently, the following Windows versions are supported:
- Windows Server 2019 64-bit
- Windows Server 2022 64-bit

On Windows, the collector is installed as a Windows service and its environment
variables are set at the service scope, i.e.: they are only available to the
collector service and not to the entire machine.

Ansible requires PowerShell 3.0 or newer and at least .NET 4.0 to be installed on Windows host.
A WinRM listener should be created and activeted.
For setting up Windows Host refer [Ansible Docs](https://docs.ansible.com/ansible/latest/user_guide/windows_setup.html).
Expand Down
30 changes: 19 additions & 11 deletions deployments/ansible/molecule/custom_vars/windows-verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
gather_facts: true
become: no
vars:
reg_values:
collector_reg_values:
SPLUNK_CONFIG: '{{ ansible_env.ProgramData }}\Splunk\OpenTelemetry Collector\custom_config.yml'
SPLUNK_INGEST_URL: https://fake-splunk-ingest.com
SPLUNK_API_URL: https://fake-splunk-api.com
Expand All @@ -15,11 +15,10 @@
SPLUNK_BALLAST_SIZE_MIB: "100"
MY_CUSTOM_VAR1: value1
MY_CUSTOM_VAR2: value2
SIGNALFX_DOTNET_TRACER_HOME: '{{ ansible_env.ProgramFiles }}\SignalFx\.NET Tracing\'
dotnet_reg_values:
COR_ENABLE_PROFILING: "true"
iis_reg_values:
COR_ENABLE_PROFILING: "1"
COR_PROFILER: "{B4C89B0F-9908-4F73-9F59-0D77C5A06874}"
CORECLR_ENABLE_PROFILING: "true"
CORECLR_ENABLE_PROFILING: "1"
CORECLR_PROFILER: "{B4C89B0F-9908-4F73-9F59-0D77C5A06874}"
SIGNALFX_ENV: test-environment
SIGNALFX_SERVICE_NAME: test-service-name
Expand All @@ -28,6 +27,8 @@
SIGNALFX_GLOBAL_TAGS: splunk.zc.method:signalfx-dotnet-tracing-1.0.0,dotnet-tag:dotnet-tag-value
SIGNALFX_DOTNET_VAR1: dotnet-value1
SIGNALFX_DOTNET_VAR2: dotnet-value2
machine_reg_values:
SIGNALFX_DOTNET_TRACER_HOME: '{{ ansible_env.ProgramFiles }}\SignalFx\.NET Tracing\'
tasks:
- name: Check splunk-otel-collector service
ansible.windows.win_service:
Expand All @@ -36,10 +37,6 @@
check_mode: yes
register: service_status

- name: Assert splunk-otel-collector service status
assert:
that: not service_status.changed

Comment on lines -39 to -42
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this removal related to the env var changes? Wonder if there should be a new var to dictate if expected.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was failing consistently for me because the status had changed to "started" - I confess that I don't understand how it was working before.

- name: Check fluentdwinsvc service
ansible.windows.win_service:
name: fluentdwinsvc
Expand Down Expand Up @@ -124,12 +121,23 @@
- name: Verify IIS env vars
assert:
that: (item.key + '=' + item.value) in iis_env.value
loop: "{{ dotnet_reg_values | dict2items }}"
loop: "{{ iis_reg_values | dict2items }}"

- name: Get splunk-otel-collector service env vars
ansible.windows.win_reg_stat:
path: HKLM:\SYSTEM\CurrentControlSet\Services\splunk-otel-collector
name: Environment
register: collector_env

- name: Verify splunk-otel-collector service env vars
assert:
that: (item.key + '=' + item.value) in collector_env.value
loop: "{{ collector_reg_values | dict2items }}"

- name: Verify env vars
include_tasks: ../shared/verify_registry_key.yml
vars:
path: HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
name: "{{ item.key }}"
value: "{{ item.value }}"
loop: "{{ reg_values | combine(dotnet_reg_values) | dict2items }}"
loop: "{{ machine_reg_values | dict2items }}"
23 changes: 11 additions & 12 deletions deployments/ansible/molecule/default/windows-verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
gather_facts: true
become: no
vars:
reg_values:
collector_reg_values:
SPLUNK_CONFIG: '{{ ansible_env.ProgramData }}\Splunk\OpenTelemetry Collector\agent_config.yaml'
SPLUNK_ACCESS_TOKEN: fake-token
SPLUNK_REALM: fake-realm
Expand All @@ -21,10 +21,6 @@
check_mode: yes
register: service_status

- name: Assert splunk-otel-collector service status
assert:
that: not service_status.changed

- name: Check fluentdwinsvc service
ansible.windows.win_service:
name: fluentdwinsvc
Expand All @@ -36,10 +32,13 @@
assert:
that: not service_status.exists

- name: Verify env vars
include_tasks: ../shared/verify_registry_key.yml
vars:
path: HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
name: "{{ item.key }}"
value: "{{ item.value }}"
loop: "{{ reg_values | dict2items }}"
- name: Get splunk-otel-collector service env vars
ansible.windows.win_reg_stat:
path: HKLM:\SYSTEM\CurrentControlSet\Services\splunk-otel-collector
name: Environment
register: collector_env

- name: Verify splunk-otel-collector service env vars
assert:
that: (item.key + '=' + item.value) in collector_env.value
loop: "{{ collector_reg_values | dict2items }}"
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
gather_facts: true
become: no
vars:
reg_values:
collector_reg_values:
SPLUNK_CONFIG: '{{ ansible_env.ProgramData }}\Splunk\OpenTelemetry Collector\agent_config.yaml'
SPLUNK_ACCESS_TOKEN: fake-token
SPLUNK_REALM: fake-realm
Expand All @@ -13,16 +13,17 @@
SPLUNK_HEC_URL: https://ingest.fake-realm.signalfx.com/v1/log
SPLUNK_INGEST_URL: https://ingest.fake-realm.signalfx.com
SPLUNK_TRACE_URL: https://ingest.fake-realm.signalfx.com/v2/trace
SIGNALFX_DOTNET_TRACER_HOME: '{{ ansible_env.ProgramFiles }}\SignalFx\.NET Tracing\'
dotnet_reg_values:
COR_ENABLE_PROFILING: "true"
iis_reg_values:
COR_ENABLE_PROFILING: "1"
COR_PROFILER: "{B4C89B0F-9908-4F73-9F59-0D77C5A06874}"
CORECLR_ENABLE_PROFILING: "true"
CORECLR_ENABLE_PROFILING: "1"
CORECLR_PROFILER: "{B4C89B0F-9908-4F73-9F59-0D77C5A06874}"
SIGNALFX_ENV: ""
SIGNALFX_SERVICE_NAME: ""
SIGNALFX_PROFILER_ENABLED: "false"
SIGNALFX_PROFILER_MEMORY_ENABLED: "false"
machine_reg_values:
SIGNALFX_DOTNET_TRACER_HOME: '{{ ansible_env.ProgramFiles }}\SignalFx\.NET Tracing\'
tasks:
- name: Check splunk-otel-collector service
ansible.windows.win_service:
Expand All @@ -31,10 +32,6 @@
check_mode: yes
register: service_status

- name: Assert splunk-otel-collector service status
assert:
that: not service_status.changed

- name: Get installed signalfx-dotnet-tracing MSI version
ansible.windows.win_shell: |
$msi_version = ""
Expand All @@ -44,19 +41,11 @@
echo $msi_version
register: msi_version

- name: Add SIGNALFX_GLOBAL_TAGS to dotnet_reg_values
- name: Add SIGNALFX_GLOBAL_TAGS to iis_reg_values
set_fact:
dotnet_reg_values: |-
iis_reg_values: |-
{%- set tags = "splunk.zc.method:signalfx-dotnet-tracing-" + (msi_version.stdout | trim) -%}
{{ dotnet_reg_values | combine({"SIGNALFX_GLOBAL_TAGS": tags}) }}

- name: Verify collector env vars
include_tasks: ../shared/verify_registry_key.yml
vars:
path: HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
name: "{{ item.key }}"
value: "{{ item.value }}"
loop: "{{ reg_values | dict2items }}"
{{ iis_reg_values | combine({"SIGNALFX_GLOBAL_TAGS": tags}) }}

- name: Get IIS env vars
ansible.windows.win_reg_stat:
Expand All @@ -67,12 +56,31 @@
- name: Verify IIS env vars
assert:
that: (item.key + '=' + item.value) in iis_env.value
loop: "{{ dotnet_reg_values | dict2items }}"
loop: "{{ iis_reg_values | dict2items }}"

- name: Get splunk-otel-collector service env vars
ansible.windows.win_reg_stat:
path: HKLM:\SYSTEM\CurrentControlSet\Services\splunk-otel-collector
name: Environment
register: collector_env

- name: Verify splunk-otel-collector service env vars
assert:
that: (item.key + '=' + item.value) in collector_env.value
loop: "{{ collector_reg_values | dict2items }}"

- name: Verify .NET tracing env vars were not added to the system
include_tasks: ../shared/verify_registry_key.yml
vars:
path: HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
name: "{{ item.key }}"
exists: false
loop: "{{ dotnet_reg_values | dict2items }}"
loop: "{{ iis_reg_values | dict2items }}"

- name: Verify .NET tracing MSI env vars were added to the system
include_tasks: ../shared/verify_registry_key.yml
vars:
path: HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
name: "{{ item.key }}"
value: "{{ item.value }}"
loop: "{{ machine_reg_values | dict2items }}"
4 changes: 2 additions & 2 deletions deployments/ansible/roles/collector/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,9 @@ For proxy options, see the [Windows Proxy](#windows-proxy) section.
`signalfx_dotnet_auto_instrumentation_additional_options` option to
enable/configure auto instrumentation for ***only*** IIS applications:
```yaml
COR_ENABLE_PROFILING: true # Required
COR_ENABLE_PROFILING: "1" # Required
COR_PROFILER: "{B4C89B0F-9908-4F73-9F59-0D77C5A06874}" # Required
CORECLR_ENABLE_PROFILING: true # Required
CORECLR_ENABLE_PROFILING: "1" # Required
CORECLR_PROFILER: "{B4C89B0F-9908-4F73-9F59-0D77C5A06874}" # Required
SIGNALFX_ENV: "{{ signalfx_dotnet_auto_instrumentation_environment }}"
SIGNALFX_GLOBAL_TAGS: "{{ signalfx_dotnet_auto_instrumentation_global_tags }}"
Expand Down
21 changes: 18 additions & 3 deletions deployments/ansible/roles/collector/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,24 @@
- (start_service | default(true) | bool)

- name: Restart Splunk OpenTelemetry Collector for windows
ansible.windows.win_service:
name: splunk-otel-collector
state: restarted
ansible.windows.win_shell: |
Try {
Restart-Service splunk-otel-collector
} Catch {
# Try to get some more helpful information given that the error message is not very helpful
Write-Host "Error restarting splunk-otel-collector service: $_"

Write-Host "Splunk OpenTelemetry Collector service registry entry:"
Get-Item HKLM:\SYSTEM\CurrentControlSet\Services\splunk-otel-collector

Write-Host "Last 15 Application log events:"
Get-WinEvent -Log Application -MaxEvents 15 | Format-List TimeCreated, ProviderName, Message

Write-Host "Last 15 System log events:"
Get-WinEvent -Log System -MaxEvents 15 | Format-List TimeCreated, ProviderName, Message

Throw $_
}
listen: "restart windows splunk-otel-collector"
when:
- (start_service | default(true) | bool)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
ansible.windows.win_package:
path: "{{otel_msi_package.dest}}"
state: present
notify: "restart windows splunk-otel-collector"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these removals related and necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the restart should only happen after the environment variables are set for the service.


- name: Merge custom config into the default config
ansible.builtin.import_tasks: config_override.yml
Expand All @@ -48,11 +47,9 @@
content: '{{ updated_config | to_nice_yaml (indent=2) }}'
dest: "{{ splunk_otel_collector_config }}"
when: splunk_config_override != ''
notify: "restart windows splunk-otel-collector"

- name: Push Custom Config file for splunk-otel-collector, If provided
ansible.windows.win_template:
src: "{{splunk_otel_collector_config_source}}"
dest: "{{splunk_otel_collector_config}}"
when: splunk_otel_collector_config_source != ""
notify: "restart windows splunk-otel-collector"