Commit bbc16e2c authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Normalize empty params in ActionCable logging

Lograge defaults to empty hashes so we change these to `nil`
so that we won't have type mismatches because these are usually
strings.
parent 989d53d3
...@@ -17,6 +17,13 @@ unless Gitlab::Runtime.sidekiq? ...@@ -17,6 +17,13 @@ unless Gitlab::Runtime.sidekiq?
data[:duration_s] = Gitlab::Utils.ms_to_round_sec(data.delete(:duration)) if data[:duration] data[:duration_s] = Gitlab::Utils.ms_to_round_sec(data.delete(:duration)) if data[:duration]
data.merge!(::Gitlab::Metrics::Subscribers::ActiveRecord.db_counter_payload) data.merge!(::Gitlab::Metrics::Subscribers::ActiveRecord.db_counter_payload)
# Remove empty hashes to prevent type mismatches
# These are set to empty hashes in Lograge's ActionCable subscriber
# https://github.com/roidrage/lograge/blob/v0.11.2/lib/lograge/log_subscribers/action_cable.rb#L14-L16
%i(method path format).each do |key|
data[key] = nil if data[key] == {}
end
data data
end end
......
...@@ -100,9 +100,9 @@ The ActionCable connection or channel class is used as the `controller`. ...@@ -100,9 +100,9 @@ The ActionCable connection or channel class is used as the `controller`.
```json ```json
{ {
"method":{}, "method":null,
"path":{}, "path":null,
"format":{}, "format":null,
"controller":"IssuesChannel", "controller":"IssuesChannel",
"action":"subscribe", "action":"subscribe",
"status":200, "status":200,
......
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