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
ANALYTICS_ENDPOINT =
"/track/apm/analytics/txn".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.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/atatus/collector/transport.rb', line 19

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

  @analytics_notify_host = @config.analytics_notify_host
  uri = URI(@analytics_notify_host)
  if not uri.kind_of?(URI::HTTPS) and not uri.kind_of?(URI::HTTP)
    @analytics_notify_host = "https://an-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

#analytics(start_time, end_time, analytics_data) ⇒ Object



81
82
83
84
# File 'lib/atatus/collector/transport.rb', line 81

def analytics(start_time, end_time, analytics_data)
  payload = @builder.analytics(start_time, end_time, analytics_data)
  post(ANALYTICS_ENDPOINT, payload)
end

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



66
67
68
69
# File 'lib/atatus/collector/transport.rb', line 66

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



71
72
73
74
# File 'lib/atatus/collector/transport.rb', line 71

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



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

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

#metrics(start_time, end_time, metric_data) ⇒ Object



76
77
78
79
# File 'lib/atatus/collector/transport.rb', line 76

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



61
62
63
64
# File 'lib/atatus/collector/transport.rb', line 61

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



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

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



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

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