Do not log process metrics when running locally
These process metrics are used to monitor our servers in production,
but they make the development logs pretty much useless. This will
allow us to actually read the logs from our development servers while
still preserving process monitoring in production.
@@ -49,10 +49,13 @@ type Server struct {
// Serve starts the server. It will return if an error occurs.
func (s *Server) Serve() error {
+ tracingToken := os.Getenv("TRACING_ACCESS_TOKEN")
+ ingestURL := os.Getenv("TRACING_INGEST_URL")
+ isLocal := os.Getenv("_IS_LOCAL") == "true"
- go func() {
- metrics.Log("{{.Title}}", 1*time.Minute)
- }()
+ if !isLocal {
+ startLoggingProcessMetrics()
+ }
go func() {
// This should never return. Listen on the pprof port
@@ -67,9 +70,6 @@ func (s *Server) Serve() error {
s.l.Info("please provide a kvconfig.yml file to enable app log routing")
}
- tracingToken := os.Getenv("TRACING_ACCESS_TOKEN")
- ingestURL := os.Getenv("TRACING_INGEST_URL")
- isLocal := os.Getenv("_IS_LOCAL") == "true"
if (tracingToken != "" && ingestURL != "") || isLocal {
samplingRate := .01 // 1%% of requests
@@ -144,6 +144,10 @@ type handler struct {
Controller
}
+func startLoggingProcessMetrics() {
+ metrics.Log("{{.Title}}", 1*time.Minute)
+}
+
func withMiddleware(serviceName string, router http.Handler, m []func(http.Handler) http.Handler) http.Handler {
handler := router
