Class: Atatus::BaseTransport

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/atatus/collector/transport.rb

Constant Summary collapse

TXN_ENDPOINT =
'/track/apm/txn'.freeze
TXN_HIST_ENDPOINT =
'/track/apm/txn/histogram'.freeze
TRACE_ENDPOINT =
'/track/apm/trace'.freeze
HOSTINFO_ENDPOINT =
"/track/apm/hostinfo".freeze
ERROR_ENDPOINT =
"/track/apm/error".freeze
ERROR_METRIC_ENDPOINT =
"/track/apm/error_metric".freeze
METRIC_ENDPOINT =
"/track/apm/metric".freeze

Constants included from Logging

Logging::LEVELS, Logging::PREFIX

Instance Method Summary collapse

Methods included from Logging

#debug, #error, #fatal, #info, #warn

Constructor Details

#initialize(config) ⇒ BaseTransport

Returns a new instance of BaseTransport.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/atatus/collector/transport.rb', line 18

def initialize(config)
  @config = config

  @notify_host = @config.notify_host
  uri = URI(@notify_host)
  if not uri.kind_of?(URI::HTTPS) and not uri.kind_of?(URI::HTTP)
    @notify_host = "https://apm-rx.atatus.com"
  end

  @builder = Atatus::Builder.new(config)
  @headers = {}
  @headers['Content-Type'] = "application/json"

  @blocked = false
  @capture_percentiles = false
  @hostinfo_response = {}
end

Instance Method Details

#error_metrics(start_time, end_time, metrics_data, requests_data) ⇒ Object



59
60
61
62
# File 'lib/atatus/collector/transport.rb', line 59

def error_metrics(start_time, end_time, metrics_data, requests_data)
  payload = @builder.error_metrics(start_time, end_time, metrics_data, requests_data)
  post(ERROR_METRIC_ENDPOINT, payload)
end

#errors(start_time, end_time, error_data) ⇒ Object



64
65
66
67
# File 'lib/atatus/collector/transport.rb', line 64

def errors(start_time, end_time, error_data)
  payload = @builder.errors(start_time, end_time, error_data)
  post(ERROR_ENDPOINT, payload)
end

#hostinfo(start_time) ⇒ Object



36
37
38
39
40
# File 'lib/atatus/collector/transport.rb', line 36

def hostinfo(start_time)
  payload = @builder.hostinfo(start_time)
  post(HOSTINFO_ENDPOINT, payload)
  @hostinfo_response
end

#metrics(start_time, end_time, metric_data) ⇒ Object



69
70
71
72
# File 'lib/atatus/collector/transport.rb', line 69

def metrics(start_time, end_time, metric_data)
  payload = @builder.metrics(start_time, end_time, metric_data)
  post(METRIC_ENDPOINT, payload)
end

#traces(start_time, end_time, data) ⇒ Object



54
55
56
57
# File 'lib/atatus/collector/transport.rb', line 54

def traces(start_time, end_time, data)
  payload = @builder.traces(start_time, end_time, data)
  post(TRACE_ENDPOINT, payload)
end

#txn_hist(start_time, end_time, data) ⇒ Object



47
48
49
50
51
52
# File 'lib/atatus/collector/transport.rb', line 47

def txn_hist(start_time, end_time, data)
  if @capture_percentiles == true
    payload = @builder.txn_hist(start_time, end_time, data)
    post(TXN_HIST_ENDPOINT, payload)
  end
end

#txns(start_time, end_time, data) ⇒ Object



42
43
44
45
# File 'lib/atatus/collector/transport.rb', line 42

def txns(start_time, end_time, data)
  payload = @builder.txns(start_time, end_time, data)
  post(TXN_ENDPOINT, payload)
end