Skip to content

Commit 50ddead

Browse files
committed
fix: enhance logging for webhook event processing and add start time to context
1 parent cbb6689 commit 50ddead

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/hooks/app/api.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ def self.create(config:, endpoints:, log:)
7676
"REMOTE_ADDR" => request.env["REMOTE_ADDR"],
7777
"hooks.request_id" => request_id,
7878
"hooks.handler" => handler_class_name,
79-
"hooks.endpoint_config" => endpoint_config
79+
"hooks.endpoint_config" => endpoint_config,
80+
"hooks.start_time" => start_time.iso8601,
81+
"hooks.full_path" => full_path
8082
}
8183

8284
# Add HTTP headers to environment
@@ -113,20 +115,20 @@ def self.create(config:, endpoints:, log:)
113115
plugin.on_response(rack_env, response)
114116
end
115117

116-
log.info "request processed successfully by handler: #{handler_class_name}"
117-
log.debug "request duration: #{Time.now - start_time}s"
118+
log.info("successfully processed webhook event with handler: #{handler_class_name}")
119+
log.debug("processing duration: #{Time.now - start_time}s")
118120
status 200
119121
content_type "application/json"
120122
response.to_json
121-
rescue => e
123+
rescue StandardError => e
122124
# Call lifecycle hooks: on_error
123125
if defined?(rack_env)
124126
Core::PluginLoader.lifecycle_plugins.each do |plugin|
125127
plugin.on_error(e, rack_env)
126128
end
127129
end
128130

129-
log.error "request failed: #{e.message}"
131+
log.error("an error occuring during the processing of a webhook event - #{e.message}")
130132
error_response = {
131133
error: e.message,
132134
code: determine_error_code(e),

0 commit comments

Comments
 (0)