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, #verbose, #warn

Constructor Details

#initialize(config) ⇒ BaseTransport

Returns a new instance of BaseTransport.



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

def initialize(config)
  @config = config

  @apm_server_url = @config.apm_server_url
  @analytics_server_url = @config.analytics_server_url

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

  @blocked = false
  @capture_percentiles = false
  @hostinfo_response = {}
  @wildcard_pattern_factory = Config::WildcardPatternList.new

  @http_transport = Transport::Connection::Http.new(@config, headers: @headers)
  @compressor = Compress.new
end

Instance Method Details

#analytics(start_time, end_time, analytics_data) ⇒ Object



89
90
91
92
# File 'lib/atatus/collector/transport.rb', line 89

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



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

def error_metrics(start_time, end_time, metrics_data, requests_data)
  return unless @hostinfo_response["performance"] && @config.performance

  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



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

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



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

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

#metrics(start_time, end_time, metric_data) ⇒ Object



82
83
84
85
86
87
# File 'lib/atatus/collector/transport.rb', line 82

def metrics(start_time, end_time, metric_data)
  return unless @hostinfo_response["performance"] && @config.performance

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

#traces(start_time, end_time, data) ⇒ Object



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

def traces(start_time, end_time, data)
  return unless @hostinfo_response["performance"] && @config.performance
  
  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
60
61
# File 'lib/atatus/collector/transport.rb', line 54

def txn_hist(start_time, end_time, data)
  return unless @hostinfo_response["performance"] && @config.performance
  
  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



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

def txns(start_time, end_time, data)
  return unless @hostinfo_response["performance"] && @config.performance

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