mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-06 10:21:05 +02:00
add span events in TestEnvironment.debugf
This commit is contained in:
parent
80e559c817
commit
63fad4e3d6
2 changed files with 8 additions and 2 deletions
|
@ -9,6 +9,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
|
||||
"github.com/pomerium/pomerium/internal/log"
|
||||
)
|
||||
|
@ -47,7 +48,10 @@ restart:
|
|||
backoff:
|
||||
for {
|
||||
interval := backoff.NextBackOff()
|
||||
log.Ctx(ctx).Info().Msgf("backing off for %s...", interval.String())
|
||||
span := trace.SpanFromContext(ctx)
|
||||
msg := fmt.Sprintf("backing off for %s...", interval.String())
|
||||
span.AddEvent(msg)
|
||||
log.Ctx(ctx).Info().Msg(msg)
|
||||
timer := time.NewTimer(interval)
|
||||
s := makeSelect(ctx, watches, name, timer.C, fn)
|
||||
next, err := s.Exec(ctx)
|
||||
|
|
|
@ -412,10 +412,12 @@ func New(t testing.TB, opts ...EnvironmentOption) Environment {
|
|||
|
||||
func (e *environment) debugf(format string, args ...any) {
|
||||
e.t.Helper()
|
||||
if e.rootSpan.IsRecording() {
|
||||
e.rootSpan.AddEvent(fmt.Sprintf(format, args...))
|
||||
}
|
||||
if !e.debug {
|
||||
return
|
||||
}
|
||||
|
||||
e.t.Logf("\x1b[34m[debug] "+format+"\x1b[0m", args...)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue