Skip to content

Commit

Permalink
Address PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-bradley committed Jun 13, 2023
1 parent 082bed1 commit 4fbeefc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
2 changes: 2 additions & 0 deletions cmd/opampsupervisor/supervisor/healthchecker/healthchecker.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"time"
)

// TODO: Support more settings
// https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/23344
type HTTPHealthChecker struct {
endpoint string
}
Expand Down
21 changes: 17 additions & 4 deletions cmd/opampsupervisor/supervisor/supervisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,14 @@ func NewSupervisor(logger *zap.Logger, configFile string) (*Supervisor, error) {

s.agentHealthCheckEndpoint = fmt.Sprintf("localhost:%d", port)

s.createInstanceID()
id, err := s.createInstanceID()

if err != nil {
return nil, err
}

s.instanceID = id

logger.Debug("Supervisor starting",
zap.String("id", s.instanceID.String()), zap.String("type", agentType), zap.String("version", s.agentVersion))

Expand Down Expand Up @@ -233,11 +240,17 @@ func (s *Supervisor) startOpAMP() error {
return nil
}

func (s *Supervisor) createInstanceID() {
// TODO: Persist instance ID. https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/21073
func (s *Supervisor) createInstanceID() (ulid.ULID, error) {
entropy := ulid.Monotonic(rand.New(rand.NewSource(0)), 0)
s.instanceID = ulid.MustNew(ulid.Timestamp(time.Now()), entropy)
id, err := ulid.New(ulid.Timestamp(time.Now()), entropy)

if err != nil {
return ulid.ULID{}, err
}

return id, nil

// TODO: Persist instance ID. https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/21073
}

func keyVal(key, val string) *protobufs.KeyValue {
Expand Down

0 comments on commit 4fbeefc

Please sign in to comment.