Skip to content

Commit ab87d83

Browse files
feat: add all bundled otel config to the observe-agent binary instead of relying on files on disk
1 parent 316589e commit ab87d83

File tree

67 files changed

+311
-797
lines changed

Some content is hidden

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

67 files changed

+311
-797
lines changed

.github/workflows/release-build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
- name: Install qemu
3030
uses: docker/setup-qemu-action@v3
3131
- name: Run GoReleaser
32-
timeout-minutes: 18
32+
timeout-minutes: 25
3333
uses: goreleaser/goreleaser-action@v6
3434
with:
3535
distribution: goreleaser-pro

.github/workflows/release-nightly.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
uses: aws-actions/amazon-ecr-login@v2
6262

6363
- name: Run GoReleaser
64-
timeout-minutes: 18
64+
timeout-minutes: 25
6565
uses: goreleaser/goreleaser-action@v6
6666
with:
6767
distribution: goreleaser-pro

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
uses: aws-actions/amazon-ecr-login@v2
5757

5858
- name: Run GoReleaser
59-
timeout-minutes: 18
59+
timeout-minutes: 25
6060
uses: goreleaser/goreleaser-action@v6
6161
with:
6262
distribution: goreleaser-pro

.github/workflows/tests-integration.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
- name: Install qemu
3838
uses: docker/setup-qemu-action@v3
3939
- name: Run GoReleaser
40-
timeout-minutes: 18
40+
timeout-minutes: 25
4141
uses: goreleaser/goreleaser-action@v6
4242
with:
4343
distribution: goreleaser-pro

.goreleaser.yaml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ builds:
2424
- linux
2525
ldflags: -s -w -X github.com/observeinc/observe-agent/build.Version={{.Version}}
2626

27+
- id: docker_build
28+
binary: observe-agent
29+
env:
30+
- CGO_ENABLED=0
31+
goos:
32+
- linux
33+
flags:
34+
- -tags=docker
35+
ldflags: -s -w -X github.com/observeinc/observe-agent/build.Version={{.Version}}
36+
2737
- id: mac_build
2838
binary: observe-agent
2939
env:
@@ -59,8 +69,6 @@ archives:
5969
# The default agent config file and the service file live in config.
6070
- src: "packaging/linux/config/*"
6171
dst: "."
62-
- src: "packaging/linux/connections/*"
63-
dst: "connections"
6472

6573
- id: windows
6674
formats: ["zip"]
@@ -75,8 +83,6 @@ archives:
7583
files:
7684
- src: "packaging/windows/observe-agent.yaml"
7785
dst: "observe-agent.yaml"
78-
- src: "packaging/windows/connections/*"
79-
dst: "connections"
8086

8187
- id: macos
8288
formats: ["zip"]
@@ -120,6 +126,8 @@ changelog:
120126
nfpms:
121127
- id: linux
122128

129+
ids: [linux_build]
130+
123131
package_name: observe-agent
124132

125133
# You can change the file name of the package.
@@ -162,10 +170,6 @@ nfpms:
162170
# Contents to add to the package.
163171
# GoReleaser will automatically add the binaries.
164172
contents:
165-
- src: packaging/linux/connections
166-
dst: /etc/observe-agent/connections
167-
type: tree
168-
169173
- src: packaging/linux/config/observe-agent.yaml
170174
dst: /etc/observe-agent/observe-agent.yaml
171175
type: config|noreplace
@@ -200,6 +204,7 @@ dockers:
200204
use: buildx
201205
goos: linux
202206
goarch: amd64
207+
ids: [docker_build]
203208
build_flag_templates:
204209
- "--platform=linux/amd64"
205210
extra_files:
@@ -211,6 +216,7 @@ dockers:
211216
use: buildx
212217
goos: linux
213218
goarch: arm64
219+
ids: [docker_build]
214220
build_flag_templates:
215221
- "--platform=linux/arm64/v8"
216222
extra_files:

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ build:
3131
go build ./...
3232

3333
docker-image:
34-
env GOOS=linux GOARCH=arm64 go build -o observe-agent
34+
env GOOS=linux GOARCH=arm64 go build -tags docker -o observe-agent
3535
docker build -f packaging/docker/Dockerfile -t observe-agent:dev .
3636

3737
## test: Runs Go tests across all packages

integration/scripts/install_windows.ps1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,4 @@ 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\connections\* -Destination $observeagent_install_dir\connections -Recurse
4039
Get-ChildItem -Path $observeagent_install_dir -Recurse

internal/commands/config/config_test.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package config
66
import (
77
"bytes"
88
"context"
9+
"embed"
910
"os"
1011
"path"
1112
"path/filepath"
@@ -15,6 +16,7 @@ import (
1516

1617
"github.com/observeinc/observe-agent/internal/commands/util/logger"
1718
"github.com/observeinc/observe-agent/internal/connections"
19+
"github.com/observeinc/observe-agent/internal/connections/bundledconfig"
1820
"github.com/observeinc/observe-agent/internal/root"
1921
"github.com/observeinc/observe-agent/observecol"
2022
"github.com/spf13/pflag"
@@ -109,7 +111,7 @@ func runSnapshotTest(t *testing.T, test snapshotTest) {
109111

110112
// Set the template base dir for all connections
111113
for _, conn := range connections.AllConnectionTypes {
112-
conn.ApplyOptions(connections.WithConfigFolderPath(getPackagingPath(t, test.packageType, curPath)))
114+
conn.ApplyOptions(connections.WithConfigTemplateOverrides(getTemplateOverrides(t, test.packageType, curPath)))
113115
}
114116

115117
// Set config flags
@@ -132,16 +134,19 @@ func runSnapshotTest(t *testing.T, test snapshotTest) {
132134
assert.Equal(t, strings.TrimSpace(string(expected)), strings.TrimSpace(output.String()))
133135
}
134136

135-
func getPackagingPath(t *testing.T, packageType PackageType, curPath string) string {
136-
const packagingPath = "../../../packaging"
137+
func getTemplateOverrides(t *testing.T, packageType PackageType, curPath string) map[string]embed.FS {
137138
switch packageType {
138-
case MacOS, Linux, Windows:
139-
return filepath.Join(curPath, packagingPath, string(packageType), "connections")
139+
case MacOS:
140+
return bundledconfig.MacOSTemplateFS
141+
case Linux:
142+
return bundledconfig.LinuxTemplateFS
143+
case Windows:
144+
return bundledconfig.WindowsTemplateFS
140145
case Docker:
141-
return filepath.Join(curPath, packagingPath, "docker/observe-agent/connections")
146+
return bundledconfig.DockerTemplateFS
142147
default:
143148
t.Errorf("Unknown package type: %s", packageType)
144-
return ""
149+
return nil
145150
}
146151
}
147152

internal/commands/status/status.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func getStatusFromTemplate(v *viper.Viper) error {
4949
return err
5050
}
5151
t := template.Must(template.New(statusTemplate).
52-
Funcs(connections.GetTemplateFuncMap()).
52+
Funcs(connections.TemplateFuncMap).
5353
ParseFS(statusTemplateFS, statusTemplate))
5454
if err := t.ExecuteTemplate(os.Stdout, statusTemplate, data); err != nil {
5555
return err

internal/connections/allconnectiontypes.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var CommonConnectionType = MakeConnectionType(
1515
func(_ *config.AgentConfig) bool {
1616
return true
1717
},
18-
[]CollectorConfigFragment{
18+
[]BundledConfigFragment{
1919
{
2020
enabledCheck: func(_ *config.AgentConfig) bool {
2121
// Always include the base connection.
@@ -55,7 +55,7 @@ var HostMonitoringConnectionType = MakeConnectionType(
5555
func(agentConfig *config.AgentConfig) bool {
5656
return agentConfig.HostMonitoring.Enabled
5757
},
58-
[]CollectorConfigFragment{
58+
[]BundledConfigFragment{
5959
{
6060
enabledCheck: func(agentConfig *config.AgentConfig) bool {
6161
// TODO remove this deprecated template
@@ -89,7 +89,7 @@ var SelfMonitoringConnectionType = MakeConnectionType(
8989
func(agentConfig *config.AgentConfig) bool {
9090
return agentConfig.SelfMonitoring.Enabled
9191
},
92-
[]CollectorConfigFragment{
92+
[]BundledConfigFragment{
9393
{
9494
enabledCheck: func(agentConfig *config.AgentConfig) bool {
9595
return agentConfig.SelfMonitoring.Enabled

0 commit comments

Comments
 (0)