Class: RailsPerformance::Models::GrapeRecord
- Inherits:
-
BaseRecord
- Object
- BaseRecord
- RailsPerformance::Models::GrapeRecord
- Defined in:
- lib/rails_performance/models/grape_record.rb
Instance Attribute Summary collapse
-
#datetime ⇒ Object
Returns the value of attribute datetime.
-
#datetimei ⇒ Object
Returns the value of attribute datetimei.
-
#endpoint_render_grape ⇒ Object
Returns the value of attribute endpoint_render_grape.
-
#endpoint_run_grape ⇒ Object
Returns the value of attribute endpoint_run_grape.
-
#format ⇒ Object
Returns the value of attribute format.
-
#format_response_grape ⇒ Object
Returns the value of attribute format_response_grape.
-
#json ⇒ Object
Returns the value of attribute json.
-
#method ⇒ Object
Returns the value of attribute method.
-
#path ⇒ Object
Returns the value of attribute path.
-
#request_id ⇒ Object
Returns the value of attribute request_id.
-
#status ⇒ Object
Returns the value of attribute status.
Class Method Summary collapse
-
.from_db(key, value) ⇒ Object
key = grape|datetime|20210409T1115|datetimei|1617992134|format|json|path|/api/users|status|200|method|GET|request_id|1122|END|1.0.0 value = “endpoint_run.grape”=>0.002000907, “format_response.grape”=>0.0348967.
Instance Method Summary collapse
-
#initialize(datetime: nil, datetimei: nil, format: nil, path: nil, status: nil, method: nil, request_id:, endpoint_render_grape: nil, endpoint_run_grape: nil, format_response_grape: nil, json: '{}') ⇒ GrapeRecord
constructor
A new instance of GrapeRecord.
- #record_hash ⇒ Object
- #save ⇒ Object
Methods inherited from BaseRecord
Constructor Details
#initialize(datetime: nil, datetimei: nil, format: nil, path: nil, status: nil, method: nil, request_id:, endpoint_render_grape: nil, endpoint_run_grape: nil, format_response_grape: nil, json: '{}') ⇒ GrapeRecord
Returns a new instance of GrapeRecord.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rails_performance/models/grape_record.rb', line 24 def initialize(datetime: nil, datetimei: nil, format: nil, path: nil, status: nil, method: nil, request_id:, endpoint_render_grape: nil, endpoint_run_grape: nil, format_response_grape: nil, json: '{}') @datetime = datetime @datetimei = datetimei.to_i unless datetimei.nil? @format = format @path = path @status = status @method = method @request_id = request_id @endpoint_render_grape = endpoint_render_grape @endpoint_run_grape = endpoint_run_grape @format_response_grape = format_response_grape @json = json end |
Instance Attribute Details
#datetime ⇒ Object
Returns the value of attribute datetime.
4 5 6 |
# File 'lib/rails_performance/models/grape_record.rb', line 4 def datetime @datetime end |
#datetimei ⇒ Object
Returns the value of attribute datetimei.
4 5 6 |
# File 'lib/rails_performance/models/grape_record.rb', line 4 def datetimei @datetimei end |
#endpoint_render_grape ⇒ Object
Returns the value of attribute endpoint_render_grape.
5 6 7 |
# File 'lib/rails_performance/models/grape_record.rb', line 5 def endpoint_render_grape @endpoint_render_grape end |
#endpoint_run_grape ⇒ Object
Returns the value of attribute endpoint_run_grape.
5 6 7 |
# File 'lib/rails_performance/models/grape_record.rb', line 5 def endpoint_run_grape @endpoint_run_grape end |
#format ⇒ Object
Returns the value of attribute format.
4 5 6 |
# File 'lib/rails_performance/models/grape_record.rb', line 4 def format @format end |
#format_response_grape ⇒ Object
Returns the value of attribute format_response_grape.
5 6 7 |
# File 'lib/rails_performance/models/grape_record.rb', line 5 def format_response_grape @format_response_grape end |
#json ⇒ Object
Returns the value of attribute json.
4 5 6 |
# File 'lib/rails_performance/models/grape_record.rb', line 4 def json @json end |
#method ⇒ Object
Returns the value of attribute method.
4 5 6 |
# File 'lib/rails_performance/models/grape_record.rb', line 4 def method @method end |
#path ⇒ Object
Returns the value of attribute path.
4 5 6 |
# File 'lib/rails_performance/models/grape_record.rb', line 4 def path @path end |
#request_id ⇒ Object
Returns the value of attribute request_id.
4 5 6 |
# File 'lib/rails_performance/models/grape_record.rb', line 4 def request_id @request_id end |
#status ⇒ Object
Returns the value of attribute status.
4 5 6 |
# File 'lib/rails_performance/models/grape_record.rb', line 4 def status @status end |
Class Method Details
.from_db(key, value) ⇒ Object
key = grape|datetime|20210409T1115|datetimei|1617992134|format|json|path|/api/users|status|200|method|GET|request_id|1122|END|1.0.0 value = “endpoint_run.grape”=>0.002000907, “format_response.grape”=>0.0348967
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/rails_performance/models/grape_record.rb', line 9 def GrapeRecord.from_db(key, value) items = key.split("|") GrapeRecord.new( datetime: items[2], datetimei: items[4], format: items[6], path: items[8], status: items[10], method: items[12], request_id: items[14], json: value ) end |
Instance Method Details
#record_hash ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/rails_performance/models/grape_record.rb', line 40 def record_hash { format: self.format, status: self.status, method: self.method, path: self.path, datetime: Time.at(self.datetimei.to_i), datetimei: datetimei.to_i, request_id: self.request_id, }.merge(self.value) end |
#save ⇒ Object
52 53 54 55 56 57 |
# File 'lib/rails_performance/models/grape_record.rb', line 52 def save key = "grape|datetime|#{datetime}|datetimei|#{datetimei}|format|#{format}|path|#{path}|status|#{status}|method|#{method}|request_id|#{request_id}|END|#{RailsPerformance::SCHEMA}" value = { "endpoint_render.grape" => endpoint_render_grape, "endpoint_run.grape" => endpoint_run_grape, "format_response.grape" => format_response_grape } Utils.save_to_redis(key, value) end |