Class: Callstacking::Rails::Client::Trace

Inherits:
Base
  • Object
show all
Defined in:
lib/callstacking/rails/client/trace.rb

Constant Summary collapse

CREATE_URL =
"/api/v1/traces.json"
UPDATE_URL =
"/api/v1/traces/:id.json"
SHOW_URL =
"/api/v1/traces/:id.json"

Instance Attribute Summary

Attributes inherited from Base

#async, #auth_token, #threads, #url

Instance Method Summary collapse

Methods inherited from Base

#connection, #get, #patch, #post, #r

Constructor Details

#initialize(url, auth_token) ⇒ Trace

Returns a new instance of Trace.



11
12
13
14
15
16
17
# File 'lib/callstacking/rails/client/trace.rb', line 11

def initialize(url, auth_token)
  super

  # All requests for trace and trace entry creation are async
  #   join by the client side generated tuid
  @async = true
end

Instance Method Details

#create(request_id, tuid, method_name, klass, action_name, format_name, root_path, url, headers, params) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/callstacking/rails/client/trace.rb', line 19

def create(request_id, tuid, method_name, klass, action_name, format_name, root_path, url, headers, params)
  post(CREATE_URL,
       {},
       {
         request_id: request_id,
         tuid: tuid,
         method_name: method_name,
         klass: klass,
         action_name: action_name,
         format_name: format_name,
         root_path: root_path,
         url: url,
         h: headers.to_h,
         p: params.to_h,
       })

  nil
end

#show(trace_id, params = {}) ⇒ Object



42
43
44
# File 'lib/callstacking/rails/client/trace.rb', line 42

def show(trace_id, params = {})
  get(SHOW_URL.gsub(':id', trace_id), params)
end

#upsert(trace_id, traces) ⇒ Object



38
39
40
# File 'lib/callstacking/rails/client/trace.rb', line 38

def upsert(trace_id, traces)
  patch(UPDATE_URL.gsub(':id', trace_id), {}, traces)
end