Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Wiedler <iwiedler@gitlab.com>2020-04-27 18:26:29 +0300
committerIgor Wiedler <iwiedler@gitlab.com>2020-04-27 18:26:29 +0300
commit1ed3180b610563430d3a51db3659f45205687aab (patch)
treec0667e93b45cd710aee70780aa65b394fb0f7099
parentfc85da228e669e88b001667b8314ce2e4e7f9510 (diff)
use labkit monitoring.Start() to get auto pprof on metrics port
-rw-r--r--app.go18
-rw-r--r--app_config.go2
-rw-r--r--main.go2
3 files changed, 19 insertions, 3 deletions
diff --git a/app.go b/app.go
index 22264eb8..c86d4c5e 100644
--- a/app.go
+++ b/app.go
@@ -3,15 +3,18 @@ package main
import (
"crypto/tls"
"errors"
+ "fmt"
+ "net"
"net/http"
+ "os"
"sync"
ghandlers "github.com/gorilla/handlers"
- "github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/rs/cors"
log "github.com/sirupsen/logrus"
"gitlab.com/gitlab-org/labkit/errortracking"
"gitlab.com/gitlab-org/labkit/metrics"
+ "gitlab.com/gitlab-org/labkit/monitoring"
mimedb "gitlab.com/lupine/go-mimedb"
"gitlab.com/gitlab-org/gitlab-pages/internal/acme"
@@ -430,8 +433,17 @@ func (a *theApp) listenMetricsFD(wg *sync.WaitGroup, fd uintptr) {
go func() {
defer wg.Done()
- handler := promhttp.Handler()
- err := listenAndServe(fd, handler, false, nil, nil)
+ l, err := net.FileListener(os.NewFile(fd, "[socket]"))
+ if err != nil {
+ capturingFatal(fmt.Errorf("failed to listen on FD %d: %v", fd, err), errortracking.WithField("listener", "metrics"))
+ }
+
+ monitoringOpts := []monitoring.Option{
+ monitoring.WithBuildInformation(a.Version, ""),
+ monitoring.WithListener(l),
+ }
+
+ err = monitoring.Start(monitoringOpts...)
if err != nil {
capturingFatal(err, errortracking.WithField("listener", "metrics"))
}
diff --git a/app_config.go b/app_config.go
index 245a9e0d..a39067a6 100644
--- a/app_config.go
+++ b/app_config.go
@@ -38,6 +38,8 @@ type appConfig struct {
SentryDSN string
SentryEnvironment string
CustomHeaders []string
+
+ Version string
}
// GitlabServerURL returns URL to a GitLab instance.
diff --git a/main.go b/main.go
index 9a316c5e..9b22fd0c 100644
--- a/main.go
+++ b/main.go
@@ -239,6 +239,8 @@ func loadConfig() appConfig {
initErrorReporting(config.SentryDSN, config.SentryEnvironment)
}
+ config.Version = VERSION
+
log.WithFields(log.Fields{
"artifacts-server": *artifactsServer,
"artifacts-server-timeout": *artifactsServerTimeout,