Loading lib/labkit/excon_publisher.rb +23 −5 Original line number Diff line number Diff line Loading @@ -92,11 +92,11 @@ module Labkit def start_payload(datum) payload = { method: datum[:method].to_s.upcase, host: datum[:host], path: datum[:path], port: datum[:port], scheme: datum[:scheme], query: datum[:query], host: nil_or_string(datum[:host]), path: nil_or_string(datum[:path]), port: nil_or_int(datum[:port]), scheme: nil_or_string(datum[:scheme]), query: generate_query_string(datum[:query]), start_time: ::Labkit::System.monotonic_time, } unless datum[:proxy].nil? Loading Loading @@ -126,5 +126,23 @@ module Labkit def remove_connection_payload(datum) connection_payload.delete(datum[:connection]) end def nil_or_string(str) str&.to_s end def nil_or_int(int) int&.to_i rescue nil end def generate_query_string(query) if query.is_a?(Hash) query.to_query else nil_or_string(query) end end end end spec/labkit/excon_publisher_spec.rb +23 −0 Original line number Diff line number Diff line Loading @@ -118,6 +118,16 @@ describe Labkit::ExconPublisher do }, ], ], [ -> { Excon.get("http://127.0.0.1:9202/api/v1/tests", query: { "abc" => "1", xyz: 2, nil_key: nil }) }, successful_handler_proc, [ { method: "GET", code: "200", scheme: "http", host: "127.0.0.1", port: 9202, path: "/api/v1/tests", query: "abc=1&nil_key=&xyz=2", }, ], ], [ -> { Excon.get("http://127.0.0.1:9202/this/is/a/not/found/path") }, successful_handler_proc, Loading Loading @@ -162,6 +172,19 @@ describe Labkit::ExconPublisher do }, ], ], [ -> { connection = Excon.new("http://127.0.0.1:9202/api/v1/tests") connection.get(query: { "abc" => "1", xyz: 2 }) }, successful_handler_proc, [ { method: "GET", code: "200", scheme: "http", host: "127.0.0.1", port: 9202, path: "/api/v1/tests", query: "abc=1&xyz=2", }, ], ], ] end Loading Loading
lib/labkit/excon_publisher.rb +23 −5 Original line number Diff line number Diff line Loading @@ -92,11 +92,11 @@ module Labkit def start_payload(datum) payload = { method: datum[:method].to_s.upcase, host: datum[:host], path: datum[:path], port: datum[:port], scheme: datum[:scheme], query: datum[:query], host: nil_or_string(datum[:host]), path: nil_or_string(datum[:path]), port: nil_or_int(datum[:port]), scheme: nil_or_string(datum[:scheme]), query: generate_query_string(datum[:query]), start_time: ::Labkit::System.monotonic_time, } unless datum[:proxy].nil? Loading Loading @@ -126,5 +126,23 @@ module Labkit def remove_connection_payload(datum) connection_payload.delete(datum[:connection]) end def nil_or_string(str) str&.to_s end def nil_or_int(int) int&.to_i rescue nil end def generate_query_string(query) if query.is_a?(Hash) query.to_query else nil_or_string(query) end end end end
spec/labkit/excon_publisher_spec.rb +23 −0 Original line number Diff line number Diff line Loading @@ -118,6 +118,16 @@ describe Labkit::ExconPublisher do }, ], ], [ -> { Excon.get("http://127.0.0.1:9202/api/v1/tests", query: { "abc" => "1", xyz: 2, nil_key: nil }) }, successful_handler_proc, [ { method: "GET", code: "200", scheme: "http", host: "127.0.0.1", port: 9202, path: "/api/v1/tests", query: "abc=1&nil_key=&xyz=2", }, ], ], [ -> { Excon.get("http://127.0.0.1:9202/this/is/a/not/found/path") }, successful_handler_proc, Loading Loading @@ -162,6 +172,19 @@ describe Labkit::ExconPublisher do }, ], ], [ -> { connection = Excon.new("http://127.0.0.1:9202/api/v1/tests") connection.get(query: { "abc" => "1", xyz: 2 }) }, successful_handler_proc, [ { method: "GET", code: "200", scheme: "http", host: "127.0.0.1", port: 9202, path: "/api/v1/tests", query: "abc=1&xyz=2", }, ], ], ] end Loading