Skip to content

Commit 0f5d87a

Browse files
committed
Refactored module names and directory layout
Moved cmd/collector to observecol, because the cmd subdirectory is reserved for packages that are executables, while our observe-agent executable is actually defined by the root directory of the repo. Renamed/moved directory cmd to internal. All of the packages under the former cmd directory are really internal packages, not executables. Changed the module name of the observe-agent module from "observe-agent" to "github.com/observeinc/observe-agent". Changed the module name of the observecol module (the one generated by ocb) from "observecol" to "github.com/observeinc/observe-agent/observecol". Ran `go mod tidy` in all our modules (including observek8sattributesprocessor) and sorted out all the replacement and versioning issues. Everything is squeaky clean now. Updated a bunch of dependencies as a byproduct of `go mod tidy`. build-ocb now also works under Linux (after setting the OCB variable in the Makefile correctly).
1 parent 94fbb4f commit 0f5d87a

Some content is hidden

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

41 files changed

+399
-3198
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ agent.exe
77
agent.exe~
88
.DS_Store
99
ocb-build/
10+
go.sum
11+
go.work.sum
12+
observecol/go.sum
13+
components/processors/observek8sattributesprocessor/go.sum
1014

1115
#integration
1216
*.pem

.goreleaser.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ builds:
2323
goos:
2424
- linux
2525
- darwin
26-
ldflags: -s -w -X observe-agent/build.Version={{.Version}}
26+
ldflags: -s -w -X github.com/observeinc/observe-agent/build.Version={{.Version}}
2727

2828
- id: windows_build
2929
binary: observe-agent
@@ -34,7 +34,7 @@ builds:
3434
goarch:
3535
- amd64
3636
- '386'
37-
ldflags: -s -w -X observe-agent/build.Version={{.Version}}
37+
ldflags: -s -w -X github.com/observeinc/observe-agent/build.Version={{.Version}}
3838

3939
archives:
4040
- id: default

Makefile

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,25 @@
1-
## go-test: Runs Go tests across all packages
2-
go-test:
3-
go work vendor
1+
# Uncomment to use OTEL Collector Builder installed by `install-ocb`
2+
OCB=$(HOME)/bin/ocb
3+
4+
# Uncomment to use OTEL Collector Builder installed by
5+
# `go install go.opentelemetry.io/collector/cmd/[email protected]`
6+
#OCB=builder
7+
8+
all: go-test
9+
10+
## vendor: Vendors Go modules
11+
vendor:
12+
go mod tidy && go work vendor
13+
cd observecol && go mod tidy && go work vendor
14+
cd components/processors/observek8sattributesprocessor && go mod tidy && go work vendor
15+
go mod tidy && go work vendor
16+
17+
## build: Build all Go packages
18+
build:
419
go build ./...
20+
21+
## test: Runs Go tests across all packages
22+
go-test: build
523
go list -f '{{.Dir}}' -m | xargs go test -v ./...
624

725
## release: Releases current tag through goreleaser
@@ -15,15 +33,18 @@ install-ocb:
1533

1634
## build-ocb: Builds project using ocb
1735
build-ocb:
18-
$(HOME)/bin/ocb --skip-compilation --config=builder-config.yaml
19-
sed -i -e 's/package main/package observeotel/g' ocb-build/components.go
20-
sed -i -e 's/\/Users\/.*observe-agent\//..\/..\//g' ocb-build/go.mod
21-
cp ./ocb-build/components.go ./cmd/collector/components.go
22-
cp ./ocb-build/go.mod ./cmd/collector/go.mod
23-
cp ./ocb-build/go.sum ./cmd/collector/go.sum
24-
go mod tidy && go work vendor
25-
cd ./cmd/collector && go mod tidy && go work vendor
36+
$(OCB) --skip-compilation --config=builder-config.yaml
37+
sed -i -e 's/package main/package observecol/g' ocb-build/components.go
38+
sed -i -e 's/\/Users\/.*observe-agent\//..\//g' ocb-build/go.mod
39+
sed -i -e 's/\/home\/.*observe-agent\//..\//g' ocb-build/go.mod
40+
sed -i -e 's/observek8sattributesprocessor v0.0.0-00010101000000-000000000000 =>/observek8sattributesprocessor =>/g' ocb-build/go.mod
41+
cp ./ocb-build/components.go ./observecol/components.go
42+
cp ./ocb-build/go.mod ./observecol/go.mod
43+
cp ./ocb-build/go.sum ./observecol/go.sum
44+
go mod tidy && go work vendor
45+
cd ./observecol && go mod tidy && go work vendor
2646

2747
install-tools:
2848
cd ./internal/tools && go install go.opentelemetry.io/collector/cmd/mdatagen
29-
49+
50+
.PHONY: all vendor build go-test release install-ocb build-ocb install-tools

builder-config.yaml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
dist:
2-
name: observeotel
3-
module: observe/otelcol
2+
name: observecol
3+
module: github.com/observeinc/observe-agent/observecol
44
description: Observe Distribution of OTEL Collector
55
output_path: ./ocb-build
66
otelcol_version: 0.110.0
@@ -61,7 +61,6 @@ connectors:
6161
- gomod: go.opentelemetry.io/collector/connector/forwardconnector v0.110.0
6262

6363
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/connector/countconnector v0.110.0
64-
# replaces:
65-
# - k8s.io/api => k8s.io/api v0.29.3
66-
# - k8s.io/apimachinery => k8s.io/apimachinery v0.29.3
67-
# - k8s.io/client-go => k8s.io/client-go v0.29.3
64+
65+
replaces:
66+
- github.com/observeinc/observe-agent => ../

cmd/collector/go.sum

Lines changed: 0 additions & 1495 deletions
This file was deleted.

components/processors/observek8sattributesprocessor/go.mod

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,26 @@ require (
66
github.com/jmespath/go-jmespath v0.4.0
77
github.com/stretchr/testify v1.9.0
88
go.opentelemetry.io/collector/component v0.110.0
9-
go.opentelemetry.io/collector/confmap v0.107.0
9+
go.opentelemetry.io/collector/confmap v1.17.0
1010
go.opentelemetry.io/collector/consumer v0.110.0
1111
go.opentelemetry.io/collector/consumer/consumertest v0.110.0
1212
go.opentelemetry.io/collector/pdata v1.16.0
1313
go.opentelemetry.io/collector/processor v0.110.0
1414
go.uber.org/goleak v1.3.0
1515
go.uber.org/zap v1.27.0
16-
k8s.io/api v0.31.1
17-
k8s.io/apimachinery v0.31.1
16+
k8s.io/api v0.31.0
17+
k8s.io/apimachinery v0.31.0
1818
)
1919

2020
require (
2121
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
2222
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
2323
github.com/go-logr/logr v1.4.2 // indirect
2424
github.com/go-logr/stdr v1.2.2 // indirect
25-
github.com/go-viper/mapstructure/v2 v2.0.0 // indirect
25+
github.com/go-viper/mapstructure/v2 v2.1.0 // indirect
2626
github.com/gogo/protobuf v1.3.2 // indirect
2727
github.com/google/gofuzz v1.2.0 // indirect
2828
github.com/google/uuid v1.6.0 // indirect
29-
github.com/hashicorp/go-version v1.7.0 // indirect
3029
github.com/json-iterator/go v1.1.12 // indirect
3130
github.com/knadh/koanf/maps v0.1.1 // indirect
3231
github.com/knadh/koanf/providers/confmap v0.1.0 // indirect
@@ -40,8 +39,6 @@ require (
4039
go.opentelemetry.io/collector/component/componentstatus v0.110.0 // indirect
4140
go.opentelemetry.io/collector/config/configtelemetry v0.110.0 // indirect
4241
go.opentelemetry.io/collector/consumer/consumerprofiles v0.110.0 // indirect
43-
go.opentelemetry.io/collector/featuregate v1.13.0 // indirect
44-
go.opentelemetry.io/collector/internal/globalgates v0.107.0 // indirect
4542
go.opentelemetry.io/collector/internal/globalsignal v0.110.0 // indirect
4643
go.opentelemetry.io/collector/pdata/pprofile v0.110.0 // indirect
4744
go.opentelemetry.io/collector/pdata/testdata v0.110.0 // indirect

0 commit comments

Comments
 (0)