From 7561b4f7a53803a2894493017861e409dd624753 Mon Sep 17 00:00:00 2001 From: Craig Smith <5344211-craigmsmith@users.noreply.gitlab.com> Date: Mon, 8 Sep 2025 16:15:50 +1000 Subject: [PATCH] Maintain logging context when inside thread --- .../secret_push_protection/secrets_check.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/ee/lib/gitlab/checks/secret_push_protection/secrets_check.rb b/ee/lib/gitlab/checks/secret_push_protection/secrets_check.rb index bc0c7a4da63a3d..b702c777c712f0 100644 --- a/ee/lib/gitlab/checks/secret_push_protection/secrets_check.rb +++ b/ee/lib/gitlab/checks/secret_push_protection/secrets_check.rb @@ -68,6 +68,8 @@ def run_validation! thread = nil + current_context = Labkit::Context.current.to_h + logger.log_timed(LOG_MESSAGES[:secrets_check]) do payloads = payload_processor.standardize_payloads @@ -79,12 +81,14 @@ def run_validation! Thread.current.abort_on_exception = false Thread.current.report_on_exception = false - extra_headers = { - 'x-correlation-id': correlation_id - } - sds_client.send_request_to_sds(payloads, - exclusions: exclusions_manager.active_exclusions, - extra_headers: extra_headers) + Labkit::Context.with_context(current_context) do + extra_headers = { + 'x-correlation-id': correlation_id + } + sds_client.send_request_to_sds(payloads, + exclusions: exclusions_manager.active_exclusions, + extra_headers: extra_headers) + end end # Pass payloads to gem for scanning. -- GitLab