Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: Test flake for DataDog agent logs
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
  • Loading branch information
kylecarbs committed Apr 15, 2022
commit 855923a5beaac3079cc1882001b794e2009ed09b
14 changes: 12 additions & 2 deletions cli/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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)
}