internal/config: only enabled error reporting for prod
Don't alert if the errors are in dev.
Change-Id: I1c862c177ba0eb54ea874db090b21425670d5f12
Reviewed-on: https://go-review.googlesource.com/c/pkgsite-metrics/+/496576
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
diff --git a/internal/config/config.go b/internal/config/config.go
index 7e86ebe..7c3af0e 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -16,6 +16,7 @@
"net/http"
"os"
"strconv"
+ "strings"
"github.com/google/safehtml/template"
"golang.org/x/net/context/ctxhttp"
@@ -148,16 +149,19 @@
return nil, err
}
cfg.ServiceAccount = sa
+ configName := os.Getenv("K_CONFIGURATION")
cfg.MonitoredResource = &mrpb.MonitoredResource{
Type: "cloud_run_revision",
Labels: map[string]string{
"project_id": cfg.ProjectID,
"service_name": cfg.ServiceID,
"revision_name": cfg.VersionID,
- "configuration_name": os.Getenv("K_CONFIGURATION"),
+ "configuration_name": configName,
},
}
- cfg.UseErrorReporting = true
+ // Only enable error reporting for prod. The configName is the
+ // Cloud Run service name: "dev-ecosystem-worker" or "prod-ecosystem-worker".
+ cfg.UseErrorReporting = strings.HasPrefix(configName, "prod-")
} else { // running locally, perhaps
cfg.MonitoredResource = &mrpb.MonitoredResource{
Type: "global",