Class: ProconBypassMan::ReportProconPerformanceMeasurementsJob

Inherits:
BaseJob
  • Object
show all
Extended by:
HasExternalApiSetting
Defined in:
lib/procon_bypass_man/background/jobs/report_procon_performance_measurements_job.rb

Class Method Summary collapse

Methods included from HasExternalApiSetting

api_server

Methods inherited from BaseJob

re_enqueue_if_failed

Methods included from Background::JobPerformable

#perform, #perform_async

Class Method Details

.pathObject



41
42
43
# File 'lib/procon_bypass_man/background/jobs/report_procon_performance_measurements_job.rb', line 41

def self.path
  "/api/devices/#{ProconBypassMan.device_id}/procon_performance_metrics"
end

.perform(measurement_collection) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/procon_bypass_man/background/jobs/report_procon_performance_measurements_job.rb', line 5

def self.perform(measurement_collection)
  return if measurement_collection.nil?

  collected_spans_size = measurement_collection.spans.size
  metric = ProconBypassMan::Procon::PerformanceMeasurement.summarize(
    spans: measurement_collection.spans
  )
  body = {
    timestamp: measurement_collection.timestamp_key,
    interval_from_previous_succeed_max: metric.interval_from_previous_succeed_max,
    interval_from_previous_succeed_p50: metric.interval_from_previous_succeed_p50,
    write_time_max: metric.write_time_max,
    write_time_p50: metric.write_time_p50,
    read_time_max: metric.read_time_max,
    read_time_p50: metric.read_time_p50,
    time_taken_max: metric.time_taken_max,
    time_taken_p50: metric.time_taken_p50,
    time_taken_p95: metric.time_taken_p95,
    time_taken_p99: metric.time_taken_p99,
    external_input_time_max: metric.external_input_time_max,
    read_error_count: metric.read_error_count,
    write_error_count: metric.write_error_count,
    gc_count: metric.gc_count,
    gc_time: metric.gc_time,
    succeed_rate: metric.succeed_rate,
    load_agv: ProconBypassMan::LoadAgv.new.get,
    collected_spans_size: collected_spans_size,
  }
  ProconBypassMan.logger.info(body)

  ProconBypassMan::ProconPerformanceHttpClient.new(
    path: path,
    server: api_server,
  ).post(body: body)
end