Class: ThreeScale::Backend::ListenerMetrics

Inherits:
Object
  • Object
show all
Defined in:
lib/3scale/backend/listener_metrics.rb

Class Method Summary collapse

Class Method Details

.report_resp_code(path, resp_code) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/3scale/backend/listener_metrics.rb', line 51

def report_resp_code(path, resp_code)
  req_type = req_type(path)
  prometheus_group = prometheus_group(req_type)

  Yabeda.send(prometheus_group).response_codes.increment(
    {
      request_type: req_type,
      resp_code: code_group(resp_code)
    },
    by: 1
  )
end

.report_response_time(path, request_time) ⇒ Object



64
65
66
67
68
69
70
71
72
# File 'lib/3scale/backend/listener_metrics.rb', line 64

def report_response_time(path, request_time)
  req_type = req_type(path)
  prometheus_group = prometheus_group(req_type)

  Yabeda.send(prometheus_group).response_times.measure(
    { request_type: req_type },
    request_time
  )
end

.start_metrics_server(port = nil) ⇒ Object



42
43
44
45
46
47
48
49
# File 'lib/3scale/backend/listener_metrics.rb', line 42

def start_metrics_server(port = nil)
  configure_data_store
  define_metrics

  # Yabeda does not accept the port as a param
  ENV['PROMETHEUS_EXPORTER_PORT'] = port.to_s if port
  Yabeda::Prometheus::Exporter.start_metrics_server!
end