Skip to content

Commit

Permalink
entrypoint: support hot reloading of configs (#6)
Browse files Browse the repository at this point in the history
* entrypoint: support hot reloading of configs

This change does the following:
- Watches the user config file for changes and updates the collector
  config if detected
- The collector uses the same port throughout the lifetime of an
  instance

To test this change do the following:
- Run `./create-sa-and-ar.sh`
- Run `gcloud builds submit . --config=cloudbuild.yaml --region=<SOME
  REGION>`. Now you have a sample app and a sidecar running.
- Run `gcloud secrets versions add run-gmp-config --data-file=<NEW
  CONFIG FILE>` to update the secret, where the config is stored.
- Look at metrics and logs, collector should be using updated config.

Change-Id: I2f15ae2d94e0f94ffe57d9ffb03f883341301ca5
Signed-off-by: Ridwan Sharif <[email protected]>

* confgenerator: use new port for self metrics on reload

Change-Id: I923f9f19b238c5f00ad3c9e644a6026fff79d743
Signed-off-by: Ridwan Sharif <[email protected]>

* dnm: debug

Change-Id: I5d7873fa70c33a42bfc73216b0afd5e8cf208f42

* Revert "dnm: debug"

This reverts commit 7542f65.

* collector: update to v0.94.0

Change-Id: I59bfe1d8023dc1aaa2fef0482df8327decfcae7e

* entrypoint: use same self metrics port for a single instance

Change-Id: I2de4d85d9181e5b42341f1b5b4a5b1ef0e2efb9c

* entrypoint: only reload when theres a change since last stat

Change-Id: Id2b26ac156ecf97561c8b7597ae60edac9c5db34
Signed-off-by: Ridwan Sharif <[email protected]>

* collector: update mdatagen

Change-Id: I32941dbd9db49a195ba9b13d03857d7e8b863d01
Signed-off-by: Ridwan Sharif <[email protected]>

* entrypoint: log the used user config

Change-Id: I9a0e8d831e92cb10c21e60958b7c3488ca372e78
Signed-off-by: Ridwan Sharif <[email protected]>

* entrypoint: deduplicate logic acound checking for the user config

Change-Id: I3421e3800600d484fbbef5666277968d87715898

* entrypoint: use raw string compare of config files instead of FileInfo

The `gen1` execution environment doesn't support mod time changes being
picked up correctly.

Change-Id: I4d39b9ca81aa0d16399dfa7fa84e3d70673a6e52
Signed-off-by: Ridwan Sharif <[email protected]>

* entrypoint: reword comment

Change-Id: I8c6a2386a17a7112d45abcd624d71717b7e369cb

---------

Signed-off-by: Ridwan Sharif <[email protected]>
  • Loading branch information
ridwanmsharif authored Feb 21, 2024
1 parent d3ade14 commit 8257258
Show file tree
Hide file tree
Showing 10 changed files with 403 additions and 361 deletions.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ BUILD_X2 := -X $(BUILD_INFO_IMPORT_PATH).Version=$(PKG_VERSION)
BUILD_X3 := -X $(ENTRYPOINT_BUILD_INFO_IMPORT_PATH).Version=$(PKG_VERSION)
LD_FLAGS := -ldflags "${BUILD_X1} ${BUILD_X2} ${BUILD_X3}"

TOOLS_DIR := internal/tools
TOOLS_DIR := collector/internal/tools

.EXPORT_ALL_VARIABLES:

Expand Down Expand Up @@ -43,6 +43,8 @@ update-components:
grep "^github.com/open-telemetry/opentelemetry-collector-contrib" | \
xargs -t -I '{}' go get {}@$(OTEL_VER)
go mod tidy
cd $(TOOLS_DIR) && go get -u github.com/open-telemetry/opentelemetry-collector-contrib/cmd/mdatagen
cd $(TOOLS_DIR) && go mod tidy

# We can bring this target back when https://github.com/open-telemetry/opentelemetry-collector/issues/8063 is resolved.
update-opentelemetry:
Expand Down
40 changes: 19 additions & 21 deletions collector/internal/tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/client9/misspell v0.3.4
github.com/golangci/golangci-lint v1.52.1
github.com/google/addlicense v1.1.1
github.com/open-telemetry/opentelemetry-collector-contrib/cmd/mdatagen v0.81.0
github.com/open-telemetry/opentelemetry-collector-contrib/cmd/mdatagen v0.94.0
)

require (
Expand Down Expand Up @@ -54,6 +54,7 @@ require (
github.com/go-toolsmith/astp v1.1.0 // indirect
github.com/go-toolsmith/strparse v1.1.0 // indirect
github.com/go-toolsmith/typep v1.1.0 // indirect
github.com/go-viper/mapstructure/v2 v2.0.0-alpha.1 // indirect
github.com/go-xmlfmt/xmlfmt v1.1.2 // indirect
github.com/gobwas/glob v0.2.3 // indirect
github.com/gofrs/flock v0.8.1 // indirect
Expand All @@ -68,7 +69,7 @@ require (
github.com/golangci/misspell v0.4.0 // indirect
github.com/golangci/revgrep v0.0.0-20220804021717-745bb2f7c2e6 // indirect
github.com/golangci/unconvert v0.0.0-20180507085042-28b1c447d1f4 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/gordonklaus/ineffassign v0.0.0-20230107090616-13ace0543b28 // indirect
github.com/gostaticanalysis/analysisutil v0.7.1 // indirect
github.com/gostaticanalysis/comment v1.4.2 // indirect
Expand All @@ -90,7 +91,7 @@ require (
github.com/kisielk/gotool v1.0.0 // indirect
github.com/kkHAIKE/contextcheck v1.1.4 // indirect
github.com/knadh/koanf v1.5.0 // indirect
github.com/knadh/koanf/v2 v2.0.1 // indirect
github.com/knadh/koanf/v2 v2.1.0 // indirect
github.com/kulti/thelper v0.6.3 // indirect
github.com/kunwardeep/paralleltest v1.0.6 // indirect
github.com/kyoh86/exportloopref v0.1.11 // indirect
Expand All @@ -105,12 +106,11 @@ require (
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.18 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mbilski/exhaustivestruct v1.2.0 // indirect
github.com/mgechev/revive v1.3.1 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.1-0.20220423185008-bf980b35cac4 // indirect
github.com/mitchellh/mapstructure v1.5.1-0.20231216201459-8508981c8b6c // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
Expand All @@ -124,10 +124,10 @@ require (
github.com/pelletier/go-toml/v2 v2.0.7 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/polyfloyd/go-errorlint v1.4.0 // indirect
github.com/prometheus/client_golang v1.14.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/prometheus/client_golang v1.18.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.46.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/quasilyte/go-ruleguard v0.3.19 // indirect
github.com/quasilyte/gogrep v0.5.0 // indirect
github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727 // indirect
Expand Down Expand Up @@ -170,23 +170,21 @@ require (
github.com/yagipy/maintidx v1.0.0 // indirect
github.com/yeya24/promlinter v0.2.0 // indirect
gitlab.com/bosi/decorder v0.2.3 // indirect
go.opentelemetry.io/collector/confmap v0.81.0 // indirect
go.opentelemetry.io/collector/featuregate v1.0.0-rcv0013 // indirect
go.opentelemetry.io/collector/pdata v1.0.0-rcv0013 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.opentelemetry.io/collector/confmap v0.94.1 // indirect
go.opentelemetry.io/collector/pdata v1.1.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.24.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect
golang.org/x/exp/typeparams v0.0.0-20230321023759-10a507213a29 // indirect
golang.org/x/mod v0.9.0 // indirect
golang.org/x/net v0.12.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.10.0 // indirect
golang.org/x/text v0.11.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.7.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect
google.golang.org/grpc v1.56.2 // indirect
google.golang.org/protobuf v1.31.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240213162025-012b6fc9bca9 // indirect
google.golang.org/grpc v1.61.0 // indirect
google.golang.org/protobuf v1.32.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
Loading

0 comments on commit 8257258

Please sign in to comment.