mirror of https://github.com/coder/coder.git
fix: Test flake for DataDog agent logs (#1026)
Sometimes the DataDog agent would fail to connect and angrily log using the standard lib logger. This would fail tests. See: https://github.com/coder/coder/runs/6038192436?check_suite_focus=true
This commit is contained in:
parent
1df750bf1a
commit
d98b7ec469
14
cli/start.go
14
cli/start.go
|
@ -64,8 +64,11 @@ func start() *cobra.Command {
|
|||
root := &cobra.Command{
|
||||
Use: "start",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
logger := slog.Make(sloghuman.Sink(os.Stderr))
|
||||
if traceDatadog {
|
||||
tracer.Start()
|
||||
tracer.Start(tracer.WithLogStartup(false), tracer.WithLogger(&datadogLogger{
|
||||
logger: logger.Named("datadog"),
|
||||
}))
|
||||
defer tracer.Stop()
|
||||
}
|
||||
|
||||
|
@ -153,7 +156,6 @@ func start() *cobra.Command {
|
|||
return xerrors.Errorf("parse ssh keygen algorithm %s: %w", sshKeygenAlgorithmRaw, err)
|
||||
}
|
||||
|
||||
logger := slog.Make(sloghuman.Sink(os.Stderr))
|
||||
options := &coderd.Options{
|
||||
AccessURL: accessURLParsed,
|
||||
Logger: logger.Named("coderd"),
|
||||
|
@ -534,3 +536,11 @@ func configureTLS(listener net.Listener, tlsMinVersion, tlsClientAuth, tlsCertFi
|
|||
|
||||
return tls.NewListener(listener, tlsConfig), nil
|
||||
}
|
||||
|
||||
type datadogLogger struct {
|
||||
logger slog.Logger
|
||||
}
|
||||
|
||||
func (d *datadogLogger) Log(msg string) {
|
||||
d.logger.Debug(context.Background(), msg)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue