Skip to content

Commit 52d87f8

Browse files
[cmd/opampsupervisor] Add OpAMP supervisor skeleton (open-telemetry#19143)
This is a direct copy of the [supervisor example implementation](https://github.com/open-telemetry/opamp-go/tree/main/internal/examples/supervisor) in the opamp-go repository. I've made some minor changes that are largely centered around linting and making it a little less of an example. Any existing or new TODOs have a linked issue that gives some context. **Link to tracking Issue:** Implements open-telemetry#18461 Co-authored-by: Matej Gera <[email protected]> --------- Co-authored-by: Evan Bradley <[email protected]> Co-authored-by: Matej Gera <[email protected]>
1 parent 31bfef7 commit 52d87f8

22 files changed

+1982
-5
lines changed

.github/CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
cmd/configschema/ @open-telemetry/collector-contrib-approvers @mx-psi @dmitryax @pmcollins
2424
cmd/mdatagen/ @open-telemetry/collector-contrib-approvers @dmitryax
25+
cmd/opampsupervisor/ @open-telemetry/collector-contrib-approvers @evan-bradley @atoulme @tigrannajaryan
2526
cmd/otelcontribcol/ @open-telemetry/collector-contrib-approvers
2627
cmd/oteltestbedcol/ @open-telemetry/collector-contrib-approvers
2728
cmd/telemetrygen/ @open-telemetry/collector-contrib-approvers @mx-psi @codeboten

.github/ISSUE_TEMPLATE/bug_report.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ body:
2020
# Start Collector components list
2121
- cmd/configschema
2222
- cmd/mdatagen
23+
- cmd/opampsupervisor
2324
- cmd/otelcontribcol
2425
- cmd/oteltestbedcol
2526
- cmd/telemetrygen

.github/ISSUE_TEMPLATE/feature_request.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ body:
1414
# Start Collector components list
1515
- cmd/configschema
1616
- cmd/mdatagen
17+
- cmd/opampsupervisor
1718
- cmd/otelcontribcol
1819
- cmd/oteltestbedcol
1920
- cmd/telemetrygen

.github/ISSUE_TEMPLATE/other.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ body:
1414
# Start Collector components list
1515
- cmd/configschema
1616
- cmd/mdatagen
17+
- cmd/opampsupervisor
1718
- cmd/otelcontribcol
1819
- cmd/oteltestbedcol
1920
- cmd/telemetrygen

.github/dependabot.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ updates:
1717
schedule:
1818
interval: "weekly"
1919
day: "wednesday"
20+
- package-ecosystem: "gomod"
21+
directory: "/cmd/opampsupervisor"
22+
schedule:
23+
interval: "weekly"
24+
day: "wednesday"
2025
- package-ecosystem: "gomod"
2126
directory: "/cmd/otelcontribcol"
2227
schedule:
@@ -1097,8 +1102,3 @@ updates:
10971102
schedule:
10981103
interval: "weekly"
10991104
day: "wednesday"
1100-
- package-ecosystem: "gomod"
1101-
directory: "/receiver/tcplogreceiver"
1102-
schedule:
1103-
interval: "weekly"
1104-
day: "wednesday"

cmd/opampsupervisor/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
effective.yaml
2+
agent.log

cmd/opampsupervisor/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include ../../Makefile.Common

cmd/opampsupervisor/README.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# OpAMP Supervisor for the OpenTelemetry Collector
2+
3+
This is an implementation of an OpAMP Supervisor that runs a Collector instance using configuration provided from an OpAMP server. This implementation
4+
is following a design specified [here](./specification/README.md).
5+
The design is still undergoing changes, and as such this implementation may change as well.
6+
7+
## Experimenting with the supervisor
8+
9+
The supervisor is currently undergoing heavy development and is not ready for any serious use. However, if you would like to test it, you can follow the steps below:
10+
11+
1. Download the [opamp-go](https://github.com/open-telemetry/opamp-go) repository, and run the OpAMP example server in the `internal/examples/server` directory.
12+
2. From the Collector contrib repository root, build the Collector:
13+
14+
```shell
15+
make otelcontribcol
16+
```
17+
18+
3. Run the supervisor, substituting `<OS>` for your platform:
19+
20+
```shell
21+
go run . --config testdata/supervisor_<OS>.yaml
22+
```
23+
24+
4. The supervisor should connect to the OpAMP server and start a Collector instance.

cmd/opampsupervisor/go.mod

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
module github.com/open-telemetry/opentelemetry-collector-contrib/cmd/opampsupervisor
2+
3+
go 1.19
4+
5+
require (
6+
github.com/cenkalti/backoff/v4 v4.2.0
7+
github.com/knadh/koanf v1.5.0
8+
github.com/oklog/ulid/v2 v2.1.0
9+
github.com/open-telemetry/opamp-go v0.6.0
10+
go.uber.org/zap v1.24.0
11+
)
12+
13+
require (
14+
github.com/davecgh/go-spew v1.1.1 // indirect
15+
github.com/fsnotify/fsnotify v1.6.0 // indirect
16+
github.com/gorilla/websocket v1.5.0 // indirect
17+
github.com/mitchellh/copystructure v1.2.0 // indirect
18+
github.com/mitchellh/mapstructure v1.5.0 // indirect
19+
github.com/mitchellh/reflectwalk v1.0.2 // indirect
20+
github.com/pmezard/go-difflib v1.0.0 // indirect
21+
github.com/stretchr/testify v1.8.2 // indirect
22+
go.uber.org/atomic v1.7.0 // indirect
23+
go.uber.org/multierr v1.6.0 // indirect
24+
golang.org/x/sys v0.5.0 // indirect
25+
google.golang.org/protobuf v1.28.1 // indirect
26+
gopkg.in/yaml.v3 v3.0.1 // indirect
27+
)

cmd/opampsupervisor/go.sum

+414
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/opampsupervisor/main.go

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package main
5+
6+
import (
7+
"flag"
8+
"os"
9+
"os/signal"
10+
11+
"go.uber.org/zap"
12+
13+
"github.com/open-telemetry/opentelemetry-collector-contrib/cmd/opampsupervisor/supervisor"
14+
)
15+
16+
func main() {
17+
configFlag := flag.String("config", "", "Path to a supervisor configuration file")
18+
flag.Parse()
19+
20+
logger, _ := zap.NewDevelopment()
21+
22+
supervisor, err := supervisor.NewSupervisor(logger, *configFlag)
23+
if err != nil {
24+
logger.Error(err.Error())
25+
os.Exit(-1)
26+
return
27+
}
28+
29+
interrupt := make(chan os.Signal, 1)
30+
signal.Notify(interrupt, os.Interrupt)
31+
<-interrupt
32+
supervisor.Shutdown()
33+
}

0 commit comments

Comments
 (0)