Class: Sqreen::Kit::Signals::SignalsClient
- Inherits:
-
Object
- Object
- Sqreen::Kit::Signals::SignalsClient
- Defined in:
- lib/sqreen/kit/signals/signals_client.rb
Constant Summary collapse
- STATIC_HEADERS =
{ 'Content-type' => 'application/json' }.freeze
Instance Method Summary collapse
-
#initialize(http_client) ⇒ SignalsClient
constructor
A new instance of SignalsClient.
- #report_batch(signals_and_traces, headers) ⇒ Object
- #report_signal(signal, headers) ⇒ Object
- #report_trace(trace, headers) ⇒ Object
Constructor Details
#initialize(http_client) ⇒ SignalsClient
Returns a new instance of SignalsClient.
15 16 17 |
# File 'lib/sqreen/kit/signals/signals_client.rb', line 15 def initialize(http_client) @http_client = http_client end |
Instance Method Details
#report_batch(signals_and_traces, headers) ⇒ Object
21 22 23 24 |
# File 'lib/sqreen/kit/signals/signals_client.rb', line 21 def report_batch(signals_and_traces, headers) data = '[' + signals_and_traces.map(&:to_json).join(',') + ']' @http_client.post('batches', data, STATIC_HEADERS.merge(headers)) end |
#report_signal(signal, headers) ⇒ Object
26 27 28 29 |
# File 'lib/sqreen/kit/signals/signals_client.rb', line 26 def report_signal(signal, headers) data = signal.to_json @http_client.post('signals', data, STATIC_HEADERS.merge(headers)) end |
#report_trace(trace, headers) ⇒ Object
31 32 33 34 |
# File 'lib/sqreen/kit/signals/signals_client.rb', line 31 def report_trace(trace, headers) data = trace.to_json @http_client.post('traces', data, STATIC_HEADERS.merge(headers)) end |