Skip to content

Commit 0283cce

Browse files
committed
fix tests
1 parent 555b8e1 commit 0283cce

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

internal/collector/otel_collector_plugin.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ type (
6161
debugOTelConfigPath string
6262
stopped bool
6363
agentConfigMutex sync.Mutex
64+
restartMutex sync.Mutex
6465
}
6566
)
6667

@@ -220,10 +221,14 @@ func (oc *Collector) Reconfigure(ctx context.Context, agentConfig *config.Config
220221
agentConfig.Collector.Extensions.HeadersSetter.Headers) {
221222
slog.InfoContext(ctx, "OTel collector headers have changed, restarting collector")
222223
oc.config = agentConfig
224+
oc.restartMutex.Lock()
225+
defer oc.restartMutex.Unlock()
223226
oc.restartCollector(ctx)
224227
}
225228
} else {
226229
oc.config = agentConfig
230+
oc.restartMutex.Lock()
231+
defer oc.restartMutex.Unlock()
227232
oc.restartCollector(ctx)
228233
}
229234

@@ -324,6 +329,8 @@ func (oc *Collector) handleNginxConfigUpdate(ctx context.Context, msg *bus.Messa
324329
return
325330
}
326331

332+
oc.restartMutex.Lock()
333+
defer oc.restartMutex.Unlock()
327334
oc.restartCollector(ctx)
328335
}
329336
}
@@ -350,6 +357,8 @@ func (oc *Collector) handleResourceUpdate(ctx context.Context, msg *bus.Message)
350357
return
351358
}
352359

360+
oc.restartMutex.Lock()
361+
defer oc.restartMutex.Unlock()
353362
oc.restartCollector(ctx)
354363
}
355364
}

0 commit comments

Comments
 (0)