gitlab.com/gitlab-org/labkit@v1.21.0/monitoring/doc.go (about)

     1  /*
     2  Package monitoring provides a monitoring endpoint and Continuous Profiling
     3  for Go service processes.
     4  
     5  - The monitoring endpoint will expose OpenMetrics at `/metrics`.
     6  
     7  - Pprof service endpoints at `/debug/pprof`. More information about the pprof
     8  	endpoints is available at https://golang.org/pkg/net/http/pprof/
     9  
    10  - Support the gitlab_build_info metric for exposing application version information
    11  
    12  This package includes optional support for continuous profiling, which is responsible for
    13  heap and cpu profiling of the Go process. Currently, the only supported driver is Google
    14  Cloud Platform's Stackdriver Profiler (see https://cloud.google.com/profiler/).
    15  
    16  The profiler is initialized upon `monitoring.Start` call.
    17  
    18  *Compiling applications with Profiler support*
    19  
    20  For compiling binaries with Stackdriver Profiler support (including its dependencies),
    21  build your binary with the `continuous_profiler_stackdriver` compilation tag:
    22  
    23  * `go build -tags="continuous_profiler_stackdriver"``
    24  
    25  *Initializing the Profiler*
    26  
    27  Use the following pattern in the `GITLAB_CONTINUOUS_PROFILING` environment variable
    28  for getting it started:
    29  
    30  * `GITLAB_CONTINUOUS_PROFILING="stackdriver?service=gitaly&service_version=1.0.1&project_id=test-123"`
    31  
    32  For more information about each argument see https://godoc.org/cloud.google.com/go/profiler#Config.
    33  Most of these shouldn't be required in GCP environments, so a simpler version could be used:
    34  
    35  * `GITLAB_CONTINUOUS_PROFILING="stackdriver"`
    36  
    37  See https://cloud.google.com/docs/authentication/production#providing_credentials_to_your_application
    38  for authentication details.
    39  
    40  *Profiler overhead*
    41  
    42  Google Cloud claim Stackdriver Profiler adds a 5% performance overhead to
    43  processes when it is enabled. This cost is only incurred when the profiler is switched on (through
    44  the `GITLAB_CONTINUOUS_PROFILING`) environment variable. More details can be found at
    45  https://medium.com/google-cloud/continuous-profiling-of-go-programs-96d4416af77b.
    46  
    47  *How to make use of profiles*
    48  
    49  - https://youtu.be/MxGQ7WZ2N74 : A look at how one can use Go profiles in practice
    50  
    51  */
    52  package monitoring