Skip to content

Commit

Permalink
Update autosdk to wait for signal
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlias committed Sep 30, 2024
1 parent 35e9be4 commit e597072
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions internal/test/e2e/autosdk/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"errors"
"os"
"os/signal"
"syscall"
"time"

"go.opentelemetry.io/otel/attribute"
Expand Down Expand Up @@ -41,8 +42,18 @@ func (a *app) Run(ctx context.Context, user string, admin bool) error {
}

func main() {
// give time for auto-instrumentation to start up
time.Sleep(5 * time.Second)
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt)
defer stop()

sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, syscall.SIGCONT)

// Wait for auto-instrumentation.
select {
case <-ctx.Done():
os.Exit(1)
case <-sigChan:
}

provider := sdk.GetTracerProvider()
tracer := provider.Tracer(
Expand All @@ -52,9 +63,6 @@ func main() {
)
app := app{tracer: tracer}

ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt)
defer stop()

ctx, span := tracer.Start(ctx, "main", trace.WithTimestamp(y2k))
defer span.End(trace.WithTimestamp(y2k.Add(5 * time.Second)))

Expand All @@ -68,7 +76,4 @@ func main() {
trace.WithStackTrace(true),
)
}

// give time for auto-instrumentation to report signal
time.Sleep(5 * time.Second)
}

0 comments on commit e597072

Please sign in to comment.