Skip to content

Commit

Permalink
PR feedback - change name + add ticker stop method
Browse files Browse the repository at this point in the history
  • Loading branch information
dineshg13 committed Oct 22, 2023
1 parent fa996bd commit 74ecf77
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion instrumentation.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func NewInstrumentation(opts ...InstrumentationOption) (*Instrumentation, error)
log.Logger.Error(err, "unable to connect to OTLP endpoint")
return nil, err
}
r, err := orchestrator.New(
r, err := orchestrator.NewService(
orchestrator.WithServiceName(c.serviceName),
orchestrator.WithTarget(c.exePath),
orchestrator.WithExporter(traceExporter),
Expand Down
11 changes: 6 additions & 5 deletions internal/pkg/orchestrator/orchestrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ type pidServiceName struct {
pid int
}

// New creates a new Implementation of orchestrator Service.
func New(
// NewService creates a new Implementation of orchestrator Service.
func NewService(
opts ...ServiceOpt,
) (*Service, error) {
s := Service{
analyzer: process.NewAnalyzer(),
processch: make(chan *pidServiceName, 10),
deadProcess: make(chan int, 10),
managers: make(map[int]*instrumentors.Manager),
pidTicker: time.NewTicker(2 * time.Second).C,
pidTicker: time.NewTicker(2 * time.Second),
monitorAll: true,
}
for _, o := range opts {
Expand All @@ -57,8 +57,9 @@ func (s *Service) Run(ctx context.Context) error {
for {
select {
case <-ctx.Done():

log.Logger.Info("Got context done")
s.pidTicker.Stop()

for _, m := range s.managers {
m.Close()
}
Expand Down Expand Up @@ -167,7 +168,7 @@ func (s *Service) findProcess(ctx context.Context) {
select {
case <-ctx.Done():
return
case <-s.pidTicker:
case <-s.pidTicker.C:

pids, err := s.analyzer.FindAllProcesses("")
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/orchestrator/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type Service struct {
managers map[int]*instrumentors.Manager
exporter sdktrace.SpanExporter
pid int
pidTicker <-chan time.Time
pidTicker *time.Ticker
}

// ServiceOpt applies a configuration option to [Service].
Expand Down

0 comments on commit 74ecf77

Please sign in to comment.