// This template contains a simple // app with OTEL bootstrap that will create an // HTTP server configured by environment that exports // spans and metrics to an OTEL collector if configured // to do so. Will also stand up a prometheus metrics // endpoint. // // Configuration and logger stored in context // Reference implementation of the provided packages package main import ( "context" "net/http" "os" "os/signal" "github.com/rs/zerolog" "go.opentelemetry.io/otel/trace" "golang.org/x/sys/unix" "gitea.libretechconsulting.com/rmcguire/go-app/pkg/app" "gitea.libretechconsulting.com/rmcguire/go-app/pkg/config" "gitea.libretechconsulting.com/rmcguire/go-app/pkg/srv" ) var ( cfg *config.AppConfig l *zerolog.Logger tracer trace.Tracer ) func main() { ctx, cncl := signal.NotifyContext(context.Background(), os.Interrupt, unix.SIGTERM) defer cncl() // Load configuration and setup logging ctx = app.MustSetupConfigAndLogging(ctx) // Prepare app app := &app.App{ AppContext: ctx, HTTP: &app.AppHTTP{ Funcs: []srv.HTTPFunc{ { Path: "/test", HandlerFunc: func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusNotImplemented) w.Write([]byte("http test route")) }, }, }, }, } // Launch app app.MustRun() // Wait for app to complete // Perform any extra shutdown here <-app.Done() }