Skip to content

Commit

Permalink
[cmd/opampsupervisor] Add OpAMP supervisor skeleton (open-telemetry#1…
Browse files Browse the repository at this point in the history
…9143)


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 <38492574+matej-g@users.noreply.github.com>

---------

Co-authored-by: Evan Bradley <evan-bradley@users.noreply.github.com>
Co-authored-by: Matej Gera <38492574+matej-g@users.noreply.github.com>
  • Loading branch information
3 people authored Jun 14, 2023
1 parent 31bfef7 commit 52d87f8
Show file tree
Hide file tree
Showing 22 changed files with 1,982 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

cmd/configschema/ @open-telemetry/collector-contrib-approvers @mx-psi @dmitryax @pmcollins
cmd/mdatagen/ @open-telemetry/collector-contrib-approvers @dmitryax
cmd/opampsupervisor/ @open-telemetry/collector-contrib-approvers @evan-bradley @atoulme @tigrannajaryan
cmd/otelcontribcol/ @open-telemetry/collector-contrib-approvers
cmd/oteltestbedcol/ @open-telemetry/collector-contrib-approvers
cmd/telemetrygen/ @open-telemetry/collector-contrib-approvers @mx-psi @codeboten
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ body:
# Start Collector components list
- cmd/configschema
- cmd/mdatagen
- cmd/opampsupervisor
- cmd/otelcontribcol
- cmd/oteltestbedcol
- cmd/telemetrygen
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ body:
# Start Collector components list
- cmd/configschema
- cmd/mdatagen
- cmd/opampsupervisor
- cmd/otelcontribcol
- cmd/oteltestbedcol
- cmd/telemetrygen
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/other.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ body:
# Start Collector components list
- cmd/configschema
- cmd/mdatagen
- cmd/opampsupervisor
- cmd/otelcontribcol
- cmd/oteltestbedcol
- cmd/telemetrygen
Expand Down
10 changes: 5 additions & 5 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ updates:
schedule:
interval: "weekly"
day: "wednesday"
- package-ecosystem: "gomod"
directory: "/cmd/opampsupervisor"
schedule:
interval: "weekly"
day: "wednesday"
- package-ecosystem: "gomod"
directory: "/cmd/otelcontribcol"
schedule:
Expand Down Expand Up @@ -1097,8 +1102,3 @@ updates:
schedule:
interval: "weekly"
day: "wednesday"
- package-ecosystem: "gomod"
directory: "/receiver/tcplogreceiver"
schedule:
interval: "weekly"
day: "wednesday"
2 changes: 2 additions & 0 deletions cmd/opampsupervisor/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
effective.yaml
agent.log
1 change: 1 addition & 0 deletions cmd/opampsupervisor/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../../Makefile.Common
24 changes: 24 additions & 0 deletions cmd/opampsupervisor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# OpAMP Supervisor for the OpenTelemetry Collector

This is an implementation of an OpAMP Supervisor that runs a Collector instance using configuration provided from an OpAMP server. This implementation
is following a design specified [here](./specification/README.md).
The design is still undergoing changes, and as such this implementation may change as well.

## Experimenting with the supervisor

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:

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.
2. From the Collector contrib repository root, build the Collector:

```shell
make otelcontribcol
```

3. Run the supervisor, substituting `<OS>` for your platform:

```shell
go run . --config testdata/supervisor_<OS>.yaml
```

4. The supervisor should connect to the OpAMP server and start a Collector instance.
27 changes: 27 additions & 0 deletions cmd/opampsupervisor/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module github.com/open-telemetry/opentelemetry-collector-contrib/cmd/opampsupervisor

go 1.19

require (
github.com/cenkalti/backoff/v4 v4.2.0
github.com/knadh/koanf v1.5.0
github.com/oklog/ulid/v2 v2.1.0
github.com/open-telemetry/opamp-go v0.6.0
go.uber.org/zap v1.24.0
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/testify v1.8.2 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/sys v0.5.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
414 changes: 414 additions & 0 deletions cmd/opampsupervisor/go.sum

Large diffs are not rendered by default.

33 changes: 33 additions & 0 deletions cmd/opampsupervisor/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package main

import (
"flag"
"os"
"os/signal"

"go.uber.org/zap"

"github.com/open-telemetry/opentelemetry-collector-contrib/cmd/opampsupervisor/supervisor"
)

func main() {
configFlag := flag.String("config", "", "Path to a supervisor configuration file")
flag.Parse()

logger, _ := zap.NewDevelopment()

supervisor, err := supervisor.NewSupervisor(logger, *configFlag)
if err != nil {
logger.Error(err.Error())
os.Exit(-1)
return
}

interrupt := make(chan os.Signal, 1)
signal.Notify(interrupt, os.Interrupt)
<-interrupt
supervisor.Shutdown()
}
Loading

0 comments on commit 52d87f8

Please sign in to comment.