Commit 9ae74766 authored by Oswaldo Ferreira's avatar Oswaldo Ferreira

Add Stackdriver Profiler through Labkit

This updates the labkit library and adds minimal changes
to the `monitoring.Serve` initialization, given the profiler
can be initialized without requiring Prometheus.
parent b04fe75d
......@@ -13,7 +13,7 @@ BUILD_TIME := $(shell date -u +%Y%m%d.%H%M%S)
GOBUILD := go build -ldflags "-X main.Version=$(VERSION_STRING) -X main.BuildTime=$(BUILD_TIME)"
EXE_ALL := gitlab-zip-cat gitlab-zip-metadata gitlab-workhorse
INSTALL := install
BUILD_TAGS := tracer_static tracer_static_jaeger
BUILD_TAGS := tracer_static tracer_static_jaeger continuous_profiler_stackdriver
MINIMUM_SUPPORTED_GO_VERSION := 1.11
......
......@@ -251,9 +251,9 @@ It is OK if a feature is only covered by integration tests.
## Distributed Tracing
Workhorse supports distributed tracing through [LabKit](https://gitlab.com/gitlab-org/labkit/) using [OpenTracing APIs](https://opentracing.io).
Workhorse supports distributed tracing through [LabKit][] using [OpenTracing APIs](https://opentracing.io).
By default, no tracing implementation is linked into the binary, but different OpenTracing providers can be linked in using [build tags](https://golang.org/pkg/go/build/#hdr-Build_Constraints)/[build constraints](https://golang.org/pkg/go/build/#hdr-Build_Constraints). This can be done by setting the `BUILD_TAGS` make variable.
By default, no tracing implementation is linked into the binary, but different OpenTracing providers can be linked in using [build tags][build-tags]/[build constraints][build-tags]. This can be done by setting the `BUILD_TAGS` make variable.
For more details of the supported providers, see LabKit, but as an example, for Jaeger tracing support, include the tags: `BUILD_TAGS="tracer_static tracer_static_jaeger"`.
......@@ -269,8 +269,34 @@ For example:
GITLAB_TRACING=opentracing://jaeger ./gitlab-workhorse
```
## Continuous Profiling
Workhorse supports continuous profiling through [LabKit][] using [Stackdriver Profiler](https://cloud.google.com/profiler).
By default, the Stackdriver Profiler implementation is linked in the binary using [build tags][build-tags], though it's not
required and can be skipped.
For example:
```shell
make BUILD_TAGS=""
```
Once Workhorse is compiled with Continuous Profiling, the profiler configuration can be set via `GITLAB_CONTINUOUS_PROFILING`
environment variable.
For example:
```shell
GITLAB_CONTINUOUS_PROFILING="stackdriver?service=workhorse&service_version=1.0.1&project_id=test-123 ./gitlab-workhorse"
```
More information about see the [LabKit monitoring docs](https://gitlab.com/gitlab-org/labkit/-/blob/master/monitoring/doc.go).
## License
This code is distributed under the MIT license, see the LICENSE file.
[brief-history-blog]: https://about.gitlab.com/2016/04/12/a-brief-history-of-gitlab-workhorse/
[LabKit]: https://gitlab.com/gitlab-org/labkit/
[build-tags]: https://golang.org/pkg/go/build/#hdr-Build_Constraints
......@@ -10,7 +10,6 @@ require (
github.com/golang/gddo v0.0.0-20190419222130-af0f2af80721
github.com/golang/protobuf v1.3.2
github.com/gomodule/redigo v2.0.0+incompatible
github.com/google/go-cmp v0.3.1 // indirect
github.com/gorilla/websocket v1.4.0
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
......@@ -22,11 +21,11 @@ require (
github.com/sirupsen/logrus v1.3.0
github.com/stretchr/testify v1.4.0
gitlab.com/gitlab-org/gitaly v1.74.0
gitlab.com/gitlab-org/labkit v0.0.0-20190902063225-3253d7975ca7
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980
gitlab.com/gitlab-org/labkit v0.0.0-20200227174525-4f8041c014c2
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5 // indirect
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac
golang.org/x/tools v0.0.0-20200117161641-43d50277825c
google.golang.org/grpc v1.24.0
honnef.co/go/tools v0.0.1-2019.2.2
honnef.co/go/tools v0.0.1-2019.2.3
)
This diff is collapsed.
......@@ -121,17 +121,18 @@ func main() {
}()
}
monitoringOpts := []monitoring.Option{monitoring.WithBuildInformation(Version, BuildTime)}
if *prometheusListenAddr != "" {
monitoringOpts = append(monitoringOpts, monitoring.WithListenerAddress(*prometheusListenAddr))
}
go func() {
err := monitoring.Serve(
monitoring.WithListenerAddress(*prometheusListenAddr),
monitoring.WithBuildInformation(Version, BuildTime),
)
err := monitoring.Serve(monitoringOpts...)
if err != nil {
log.WithError(err).Error("Failed to start prometheus listener")
log.WithError(err).Error("Failed to start monitoring")
}
}()
}
secret.SetPath(*secretPath)
cfg := config.Config{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment