Commit ee8e6b65 authored by Michael Kozono's avatar Michael Kozono

Merge branch 'issue_336570_change_json_encoder' into 'master'

Use Gitlab::Json to record action cable payload size

See merge request gitlab-org/gitlab!66944
parents e4a92de6 90c51c30
......@@ -28,7 +28,7 @@ module Gitlab
if event.payload.present?
channel = event.payload[:channel_class]
operation = operation_name_from(event.payload)
data_size = ::ActiveSupport::JSON.encode(event.payload[:data]).bytesize
data_size = Gitlab::Json.generate(event.payload[:data]).bytesize
transmitted_bytes_histogram.observe({ channel: channel, operation: operation }, data_size)
end
......
......@@ -40,7 +40,7 @@ RSpec.describe Gitlab::Metrics::Subscribers::ActionCable, :request_store do
allow(::Gitlab::Metrics).to receive(:histogram).with(
:action_cable_transmitted_bytes, /transmit/
).and_return(counter)
message_size = ::ActiveSupport::JSON.encode(data).bytesize
message_size = ::Gitlab::Json.generate(data).bytesize
expect(counter).to receive(:observe).with({ channel: channel_class, operation: 'event' }, message_size)
......
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