Skip to content

Commit 97fbd00

Browse files
refactor: split main otel config into multiple connections, add tests (#186)
### Description OB-36266: Split main otel config into multiple connections. Use the agent config object as the source of truth instead of viper. Add tests. I also tested this with the new `observe-agent config --render-otel` command. I enabled all options in my agent config, and diffed the output between `main` and this branch and only these lines changed: ```diff 104c104 < - /usr/local/observe-agent/config/otel-collector.yaml --- > - /usr/local/observe-agent/connections/common/base.yaml.tmpl 123c123 < include: /usr/local/observe-agent/config/otel-collector.yaml --- > include: /usr/local/observe-agent/connections/common/base.yaml.tmpl ``` This is expected since the otel-collector.yaml file no longer exists. ### Checklist - [x] Created tests which fail without the change (if possible)
1 parent 784817b commit 97fbd00

File tree

65 files changed

+921
-395
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+921
-395
lines changed

.github/workflows/generate-changelog.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
# either 'goreleaser' (default) or 'goreleaser-pro'
2323
distribution: goreleaser-pro
2424
# 'latest', 'nightly', or a semver
25-
version: 2.7.0
25+
version: 2.8.2
2626
args: changelog
2727
env:
2828
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}

.github/workflows/release-build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
uses: goreleaser/goreleaser-action@v6
3333
with:
3434
distribution: goreleaser-pro
35-
version: 2.7.0
35+
version: 2.8.2
3636
args: release --prepare --clean --snapshot --verbose
3737
env:
3838
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}

.github/workflows/release-nightly.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
uses: goreleaser/goreleaser-action@v6
6666
with:
6767
distribution: goreleaser-pro
68-
version: 2.7.0
68+
version: 2.8.2
6969
args: release --clean --skip=validate --verbose --nightly --parallelism 6
7070
env:
7171
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
with:
6161
distribution: goreleaser-pro
6262
# 'latest', 'nightly', or a semver
63-
version: 2.7.0
63+
version: 2.8.2
6464
args: release --clean --skip=validate --verbose
6565
env:
6666
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/tests-integration.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
uses: goreleaser/goreleaser-action@v6
4242
with:
4343
distribution: goreleaser-pro
44-
version: 2.7.0
44+
version: 2.8.2
4545
args: release --prepare --clean --snapshot --verbose --parallelism 6
4646
env:
4747
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}

.github/workflows/vuln-check-full.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
uses: goreleaser/goreleaser-action@v6
4343
with:
4444
distribution: goreleaser-pro
45-
version: 2.7.0
45+
version: 2.8.2
4646
args: build --snapshot --id=default --skip=validate --single-target
4747
env:
4848
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}

.github/workflows/vuln-check-release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
uses: goreleaser/goreleaser-action@v6
4242
with:
4343
distribution: goreleaser-pro
44-
version: 2.7.0
44+
version: 2.8.2
4545
args: build --snapshot --id=default --skip=validate --single-target
4646
env:
4747
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}

.goreleaser.yaml

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ before:
1616
- go generate ./...
1717

1818
builds:
19-
- id: default
19+
- id: linux_build
2020
binary: observe-agent
2121
env:
2222
- CGO_ENABLED=0
@@ -44,10 +44,9 @@ builds:
4444
ldflags: -s -w -X github.com/observeinc/observe-agent/build.Version={{.Version}}
4545

4646
archives:
47-
- id: default
47+
- id: linux
4848
formats: ["tar.gz"]
49-
builds:
50-
- default
49+
ids: [linux_build]
5150
# this name template makes the OS and Arch compatible with the results of `uname`.
5251
name_template: >-
5352
{{ .ProjectName }}_
@@ -57,15 +56,15 @@ archives:
5756
{{- else }}{{ .Arch }}{{ end }}
5857
{{- if .Arm }}v{{ .Arm }}{{ end }}
5958
files:
60-
- src: "packaging/linux/etc/observe-agent/*"
61-
dst: "."
59+
# The default agent config file and the service file live in config.
6260
- src: "packaging/linux/config/*"
6361
dst: "."
62+
- src: "packaging/linux/connections/*"
63+
dst: "connections"
6464

6565
- id: windows
6666
formats: ["zip"]
67-
builds:
68-
- windows_build
67+
ids: [windows_build]
6968
name_template: >-
7069
{{ .ProjectName }}_
7170
{{- title .Os }}_
@@ -74,19 +73,14 @@ archives:
7473
{{- else }}{{ .Arch }}{{ end }}
7574
{{- if .Arm }}v{{ .Arm }}{{ end }}
7675
files:
77-
- src: "packaging/windows/config/otel-collector.yaml"
78-
dst: "otel-collector.yaml"
7976
- src: "packaging/windows/observe-agent.yaml"
8077
dst: "observe-agent.yaml"
81-
- src: "packaging/windows/connections/host_monitoring/*"
82-
dst: "connections/host_monitoring"
83-
- src: "packaging/windows/connections/self_monitoring/*"
84-
dst: "connections/self_monitoring"
78+
- src: "packaging/windows/connections/*"
79+
dst: "connections"
8580

8681
- id: macos
8782
formats: ["zip"]
88-
builds:
89-
- mac_build
83+
ids: [mac_build]
9084
name_template: >-
9185
{{ .ProjectName }}_
9286
{{- title .Os }}_
@@ -124,7 +118,7 @@ changelog:
124118
order: 999
125119

126120
nfpms:
127-
- id: default
121+
- id: linux
128122

129123
package_name: observe-agent
130124

@@ -168,8 +162,8 @@ nfpms:
168162
# Contents to add to the package.
169163
# GoReleaser will automatically add the binaries.
170164
contents:
171-
- src: packaging/linux/etc/
172-
dst: /etc
165+
- src: packaging/linux/connections
166+
dst: /etc/observe-agent/connections
173167
type: tree
174168

175169
- src: packaging/linux/config/observe-agent.yaml

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ go 1.23.7
55
require (
66
github.com/go-viper/mapstructure/v2 v2.2.1
77
github.com/jarcoal/httpmock v1.3.1
8+
github.com/mcuadros/go-defaults v1.2.0
89
github.com/observeinc/observe-agent/observecol v0.0.0-00010101000000-000000000000
910
github.com/prometheus/client_model v0.6.1
1011
github.com/prometheus/common v0.62.0

integration/scripts/install_windows.ps1

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ $temp_dir="C:\temp"
1818
#Create directories for temp & observe-agent installation ls
1919
New-Item -ItemType Directory -Force -Path $temp_dir
2020
New-Item -ItemType Directory -Force -Path $observeagent_install_dir
21-
New-Item -ItemType Directory -Force -Path $observeagent_install_dir\config
21+
New-Item -ItemType Directory -Force -Path $observeagent_install_dir\connections
2222
New-Item -ItemType Directory -Force -Path $program_data_filestorage
2323

2424
# Stop the observe agent if its running so that we can copy the new .exe
@@ -36,7 +36,5 @@ Expand-Archive -Force -LiteralPath $local_installer -DestinationPath "$temp_dir
3636
Write-Output "Copying files from $temp_dir\observe-agent_extract to $observeagent_install_dir"
3737
Copy-Item -Force -Path $temp_dir\observe-agent_extract\observe-agent.exe -Destination $observeagent_install_dir
3838
Copy-Item -Force -Path $temp_dir\observe-agent_extract\observe-agent.yaml -Destination $observeagent_install_dir
39-
Copy-Item -Force -Path $temp_dir\observe-agent_extract\otel-collector.yaml -Destination $observeagent_install_dir\config\otel-collector.yaml
40-
Copy-Item -Force -Path $temp_dir\observe-agent_extract\connections\ -Destination $observeagent_install_dir\connections -Recurse
41-
42-
39+
Copy-Item -Force -Path $temp_dir\observe-agent_extract\connections\* -Destination $observeagent_install_dir\connections -Recurse
40+
Get-ChildItem -Path $observeagent_install_dir -Recurse

0 commit comments

Comments
 (0)