Commit 7e3a759b authored by Matthias Kaeppler's avatar Matthias Kaeppler

Move timeout settings from Prom Client to Service

Also:
- Restore original 60s timeouts at service level
- Include duration in the error message in application logs.
- Add changlog entry

Since the client is used widely now and different features come with
different query profiles, and since we already set defaults in the http
client, we should define this closer to the caller now.
parent 08b4e70e
...@@ -97,7 +97,13 @@ class PrometheusService < MonitoringService ...@@ -97,7 +97,13 @@ class PrometheusService < MonitoringService
def prometheus_client def prometheus_client
return unless should_return_client? return unless should_return_client?
options = { allow_local_requests: allow_local_api_url? } options = {
allow_local_requests: allow_local_api_url?,
# We should choose more conservative timeouts, but some queries we run are now busting our
# default timeouts, which are stricter. We should make those queries faster instead.
# See https://gitlab.com/gitlab-org/gitlab/-/issues/233109
timeout: 60
}
if behind_iap? if behind_iap?
# Adds the Authorization header # Adds the Authorization header
......
...@@ -55,16 +55,17 @@ class WebHookService ...@@ -55,16 +55,17 @@ class WebHookService
message: response.to_s message: response.to_s
} }
rescue SocketError, OpenSSL::SSL::SSLError, Errno::ECONNRESET, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Net::OpenTimeout, Net::ReadTimeout, Gitlab::HTTP::BlockedUrlError, Gitlab::HTTP::RedirectionTooDeep, Gitlab::Json::LimitedEncoder::LimitExceeded => e rescue SocketError, OpenSSL::SSL::SSLError, Errno::ECONNRESET, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Net::OpenTimeout, Net::ReadTimeout, Gitlab::HTTP::BlockedUrlError, Gitlab::HTTP::RedirectionTooDeep, Gitlab::Json::LimitedEncoder::LimitExceeded => e
execution_duration = Gitlab::Metrics::System.monotonic_time - start_time
log_execution( log_execution(
trigger: hook_name, trigger: hook_name,
url: hook.url, url: hook.url,
request_data: data, request_data: data,
response: InternalErrorResponse.new, response: InternalErrorResponse.new,
execution_duration: Gitlab::Metrics::System.monotonic_time - start_time, execution_duration: execution_duration,
error_message: e.to_s error_message: e.to_s
) )
Gitlab::AppLogger.error("WebHook Error => #{e}") Gitlab::AppLogger.error("WebHook Error after #{execution_duration.to_i.seconds}s => #{e}")
{ {
status: :error, status: :error,
......
---
title: Set longer Prometheus timeouts in PrometheusService
merge_request: 39318
author:
type: other
...@@ -132,7 +132,7 @@ module Gitlab ...@@ -132,7 +132,7 @@ module Gitlab
def http_options def http_options
strong_memoize(:http_options) do strong_memoize(:http_options) do
{ follow_redirects: false, open_timeout: 5, read_timeout: 10 }.merge(mapped_options) { follow_redirects: false }.merge(mapped_options)
end end
end end
......
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