Class: Sqreen::Kit::Signals::SignalsClient

Inherits:
Object
  • Object
show all
Defined in:
lib/sqreen/kit/signals/signals_client.rb

Constant Summary collapse

STATIC_HEADERS =
{ 'Content-type' => 'application/json' }.freeze

Instance Method Summary collapse

Constructor Details

#initialize(http_client) ⇒ SignalsClient

Returns a new instance of SignalsClient.

Parameters:

  • http_client (Sqreen::Kit:HttpClient)


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

Parameters:

  • signals_and_traces (Array)
  • headers (Hash{String=>String})


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