From 58b436860e7fbd7cf0e7b6723a7d85c494413c4a Mon Sep 17 00:00:00 2001 From: Lee Brown Date: Wed, 28 Aug 2019 23:57:33 -0800 Subject: [PATCH] fix panic from datadog disabled --- build/cicd/internal/config/config.go | 2 +- cmd/web-app/handlers/routes.go | 1 + internal/mid/errors.go | 8 +++++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/build/cicd/internal/config/config.go b/build/cicd/internal/config/config.go index 7d2780f..43288b3 100644 --- a/build/cicd/internal/config/config.go +++ b/build/cicd/internal/config/config.go @@ -96,7 +96,7 @@ func NewConfig(log *log.Logger, targetEnv Env, awsCredentials devdeploy.AwsCrede // it will fail to create appropriate resources for the account of the forked user. if cfg.ProjectName == "saas-starter-kit" { remoteUser := gitRemoteUser(modDetails.ProjectRoot) - + // Its a true fork from the origin repo. if remoteUser != "oss" && remoteUser != "geeks-accelerator" { // Replace the prefix 'saas' with the parent directory name, hopefully the gitlab group/username. diff --git a/cmd/web-app/handlers/routes.go b/cmd/web-app/handlers/routes.go index 927d5c7..9dc54b7 100644 --- a/cmd/web-app/handlers/routes.go +++ b/cmd/web-app/handlers/routes.go @@ -238,6 +238,7 @@ func APP(shutdown chan os.Signal, appCtx *AppContext) http.Handler { Redis: appCtx.Redis, } app.Handle("GET", "/v1/health", check.Health) + app.Handle("GET", "/ping", check.Ping) // Handle static files/pages. Render a custom 404 page when file not found. static := func(ctx context.Context, w http.ResponseWriter, r *http.Request, params map[string]string) error { diff --git a/internal/mid/errors.go b/internal/mid/errors.go index f6154fe..ce6c670 100644 --- a/internal/mid/errors.go +++ b/internal/mid/errors.go @@ -27,7 +27,13 @@ func Errors(log *log.Logger, renderer web.Renderer) web.Middleware { if er := before(ctx, w, r, params); er != nil { // Log the error. - log.Printf("%d : ERROR : %+v", span.Context().TraceID(), er) + if span != nil && span.Context() != nil { + log.Printf("%d : ERROR : %+v", span.Context().TraceID(), er) + } else { + log.Printf("ERROR : %+v", er) + } + + // Respond to the error. if web.RequestIsJson(r) {