package app import ( "context" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/codes" "gitea.libretechconsulting.com/rmcguire/go-app/pkg/otel" "gitea.libretechconsulting.com/rmcguire/go-app/pkg/srv" ) func (a *App) initGRPC() { } func (a *App) initHTTP(ctx context.Context) error { var err error var httpShutdown shutdownFunc _, span := a.tracer.Start(ctx, "init.http") defer span.End() span.SetAttributes( attribute.Int("numHTTPFuncs", len(a.HTTP.Funcs)), attribute.Int("numHTTPMiddlewares", len(a.HTTP.Middleware)), attribute.Int("numHTTPHealthChecks", len(a.HTTP.HealthChecks)), ) httpShutdown, a.HTTP.httpDone, err = srv.InitHTTPServer( &srv.HTTPServerOpts{ Ctx: a.AppContext, HandleFuncs: a.HTTP.Funcs, Middleware: a.HTTP.Middleware, HealthCheckFuncs: a.HTTP.HealthChecks, }, ) a.shutdownFuncs = append(a.shutdownFuncs, httpShutdown) if err != nil { span.RecordError(err) span.SetStatus(codes.Error, err.Error()) } else { span.SetStatus(codes.Ok, "") } return err } func (a *App) initOTEL() { var otelShutdown shutdownFunc a.AppContext, otelShutdown = otel.Init(a.AppContext) a.shutdownFuncs = append(a.shutdownFuncs, otelShutdown) a.tracer = otel.MustTracerFromCtx(a.AppContext) }