Skip to content
代码片段 群组 项目
提交 de1c4a28 编辑于 作者: Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre
浏览文件

Merge branch '413766-fix-execution-time-log' into 'master'

Path traversal middleware: log the execution time in ms

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/133465



Merged-by: default avatarDouglas Barbosa Alexandre <dbalexandre@gmail.com>
Approved-by: default avatarDouglas Barbosa Alexandre <dbalexandre@gmail.com>
Approved-by: default avatarRavi Kumar <rkumar@gitlab.com>
Co-authored-by: default avatarDavid Fernandez <dfernandez@gitlab.com>
No related branches found
No related tags found
无相关合并请求
...@@ -17,7 +17,7 @@ def call(env) ...@@ -17,7 +17,7 @@ def call(env)
check(env, log_params) check(env, log_params)
end end
log_params[:duration_s] = execution_time.round(5) if execution_time log_params[:duration_ms] = execution_time.round(5) if execution_time
log(log_params) unless log_params.empty? log(log_params) unless log_params.empty?
end end
...@@ -29,7 +29,7 @@ def call(env) ...@@ -29,7 +29,7 @@ def call(env)
def measure_execution_time(&blk) def measure_execution_time(&blk)
if Feature.enabled?(:log_execution_time_path_traversal_middleware, Feature.current_request) if Feature.enabled?(:log_execution_time_path_traversal_middleware, Feature.current_request)
Benchmark.realtime(&blk) Benchmark.ms(&blk)
else else
yield yield
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
.and_call_original .and_call_original
expect(::Gitlab::AppLogger) expect(::Gitlab::AppLogger)
.to receive(:warn) .to receive(:warn)
.with({ class_name: described_class.name, duration_s: instance_of(Float) }) .with({ class_name: described_class.name, duration_ms: instance_of(Float) })
.and_call_original .and_call_original
expect(subject).to eq(fake_response) expect(subject).to eq(fake_response)
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
.to receive(:warn) .to receive(:warn)
.with({ .with({
class_name: described_class.name, class_name: described_class.name,
duration_s: instance_of(Float), duration_ms: instance_of(Float),
message: described_class::PATH_TRAVERSAL_MESSAGE, message: described_class::PATH_TRAVERSAL_MESSAGE,
fullpath: fullpath fullpath: fullpath
}).and_call_original }).and_call_original
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册