Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlias committed Dec 7, 2024
1 parent 10e2136 commit 2799f0b
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 17 deletions.
3 changes: 2 additions & 1 deletion internal/test/e2e/databasesql/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ import (
"os/signal"

_ "github.com/mattn/go-sqlite3"
"go.opentelemetry.io/auto/internal/test/trigger"
"go.uber.org/zap"

"go.opentelemetry.io/auto/internal/test/trigger"
)

const (
Expand Down
1 change: 1 addition & 0 deletions internal/test/e2e/gin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"os/signal"

"github.com/gin-gonic/gin"

"go.opentelemetry.io/auto/internal/test/trigger"
)

Expand Down
3 changes: 2 additions & 1 deletion internal/test/e2e/grpc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ import (
"os/signal"
"time"

"go.opentelemetry.io/auto/internal/test/trigger"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials/insecure"
pb "google.golang.org/grpc/examples/helloworld/helloworld"
"google.golang.org/grpc/status"

"go.opentelemetry.io/auto/internal/test/trigger"
)

const port = 1701
Expand Down
1 change: 1 addition & 0 deletions internal/test/e2e/kafka-go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"time"

kafka "github.com/segmentio/kafka-go"

"go.opentelemetry.io/auto/internal/test/trigger"
)

Expand Down
3 changes: 2 additions & 1 deletion internal/test/e2e/otelglobal/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ import (
"os"
"os/signal"

"go.opentelemetry.io/auto/internal/test/trigger"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/trace"

"go.opentelemetry.io/auto/internal/test/trigger"
)

var tracer = otel.Tracer(
Expand Down
14 changes: 7 additions & 7 deletions internal/tools/collector/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ func main() {

configYaml := fmt.Sprintf(config, *outPath)
logger.Debug("built config", "config", configYaml)
coll := Collector{logger: logger}
if err := coll.Start(ctx, configYaml); err != nil {
coll := collector{logger: logger}
if err := coll.start(ctx, configYaml); err != nil {
logger.Error("failed to start collector", "error", err)
os.Exit(1)
}
Expand All @@ -98,7 +98,7 @@ func main() {
// Wait for the context to be canceled
<-ctx.Done()

coll.Stop()
coll.stop()
}

func newLogger(lvlStr string) *slog.Logger {
Expand All @@ -121,14 +121,14 @@ func newLogger(lvlStr string) *slog.Logger {
return logger
}

type Collector struct {
type collector struct {
logger *slog.Logger

collMu sync.Mutex
coll *otelcol.Collector
}

func (c *Collector) Start(ctx context.Context, configYaml string) error {
func (c *collector) start(ctx context.Context, configYaml string) error {
c.collMu.Lock()
defer c.collMu.Unlock()

Expand Down Expand Up @@ -174,7 +174,7 @@ func (c *Collector) Start(ctx context.Context, configYaml string) error {
return nil
}

func (c *Collector) Stop() {
func (c *collector) stop() {
c.logger.Info("stopping collector")
c.collMu.Lock()
defer c.collMu.Unlock()
Expand All @@ -193,7 +193,7 @@ func startHTTPServer(addr string, cancel context.CancelFunc, logger *slog.Logger
logger.Info("shutdown endpoint hit")
cancel()
w.WriteHeader(http.StatusOK)
w.Write([]byte("Shutting down collector..."))
_, _ = w.Write([]byte("Shutting down collector..."))
})

logger.Info("starting shutdown HTTP server", "addr", addr)
Expand Down
20 changes: 13 additions & 7 deletions internal/tools/runner/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import (
"os/signal"
"syscall"

"go.opentelemetry.io/auto"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp"

"go.opentelemetry.io/auto"
)

func main() {
Expand All @@ -32,8 +33,8 @@ func main() {
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt)
defer stop()

app := App{logger: logger}
if err := app.Run(ctx, *binPath); err != nil {
app := app{logger: logger}
if err := app.run(ctx, *binPath); err != nil {
logger.Error("failed to run", "error", err)
os.Exit(1)
}
Expand All @@ -59,11 +60,11 @@ func newLogger(lvlStr string) *slog.Logger {
return logger
}

type App struct {
type app struct {
logger *slog.Logger
}

func (a *App) Run(ctx context.Context, binPath string) error {
func (a *app) run(ctx context.Context, binPath string) error {
exp, err := otlptracehttp.New(ctx)
if err != nil {
return err
Expand Down Expand Up @@ -109,13 +110,18 @@ func (a *App) Run(ctx context.Context, binPath string) error {

var sig os.Signal = syscall.SIGCONT
a.logger.Debug("sending signal to target")
cmd.Process.Signal(sig)
if err := cmd.Process.Signal(sig); err != nil {
return err
}
a.logger.Debug("sent signal to target")

done := make(chan struct{})
go func() {
cmd.Wait()
err := cmd.Wait()
close(done)
if err != nil {
a.logger.Error("command failed", "error", err)
}
}()

select {
Expand Down

0 comments on commit 2799f0b

Please sign in to comment.