Skip to content

Use HTTP Service Metrics and Logging from LogKit

Andrew Newdigate requested to merge an-use-logkit-metrics into master

Requires labkit!30 (merged)

Requires labkit!22 (merged)

Requires !157 (merged)

Adds Metrics

This change adds the "standard" promhttp metrics to Pages, implemented by github.com/prometheus/client_golang/prometheus/promhttp as http handler middlewares.

  • InstrumentHandlerCounter
  • InstrumentHandlerDuration
  • InstrumentHandlerInFlight
  • InstrumentHandlerRequestSize
  • InstrumentHandlerResponseSize
  • InstrumentHandlerTimeToWriteHeader

For each of these metrics, we'll have code, method labels.

For example:

# HELP gitlab_pages_http_in_flight_requests A gauge of requests currently being served by the registry.
# TYPE gitlab_pages_http_in_flight_requests gauge
gitlab_pages_http_in_flight_requests 0

# HELP gitlab_pages_http_request_duration_seconds A histogram of latencies for requests to the registry.
# TYPE gitlab_pages_http_request_duration_seconds histogram
gitlab_pages_http_request_duration_seconds_bucket{code="502",method="get",le="0.01"} 5
gitlab_pages_http_request_duration_seconds_sum{code="502",method="get"} 0.009138354999999999
gitlab_pages_http_request_duration_seconds_count{code="502",method="get"} 5

# HELP gitlab_pages_http_request_size_bytes A histogram of sizes of requests to the registry.
# TYPE gitlab_pages_http_request_size_bytes histogram
gitlab_pages_http_request_size_bytes_bucket{code="502",method="get",le="10"} 0
gitlab_pages_http_request_size_bytes_sum{code="502",method="get"} 405
gitlab_pages_http_request_size_bytes_count{code="502",method="get"} 5


# HELP gitlab_pages_http_requests_total A counter for requests to the registry.
# TYPE gitlab_pages_http_requests_total counter
gitlab_pages_http_requests_total{code="502",method="get"} 5

# HELP gitlab_pages_http_time_to_write_header_seconds A histogram of request durations until the response headers are written.
# TYPE gitlab_pages_http_time_to_write_header_seconds histogram
gitlab_pages_http_time_to_write_header_seconds_bucket{code="502",method="get",le="0.01"} 5
gitlab_pages_http_time_to_write_header_seconds_sum{code="502",method="get"} 0.009059493
gitlab_pages_http_time_to_write_header_seconds_count{code="502",method="get"} 5

This change brings parity between the Workhorse metrics, added in gitlab-workhorse!279 (merged) and GitLab Pages.

Adds Logging

This switches Pages over to the LabKit access logger, as used in Workhorse too.

Additionally, it includes several extra fields, including:

  1. pages_https HTTPS request?
  2. pages_host The hostname
  3. pages_project_id The project id

cc @nolith

Edited by Andrew Newdigate

Merge request reports