Class: Stripe::APIRequestor::StripeRequestMetrics

Inherits:
Object
  • Object
show all
Defined in:
lib/stripe/api_requestor.rb

Overview

StripeRequestMetrics tracks metadata to be reported to stripe for metrics collection

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_id, request_duration_ms, usage: []) ⇒ StripeRequestMetrics

Returns a new instance of StripeRequestMetrics.



1118
1119
1120
1121
1122
# File 'lib/stripe/api_requestor.rb', line 1118

def initialize(request_id, request_duration_ms, usage: [])
  self.request_id = request_id
  self.request_duration_ms = request_duration_ms
  self.usage = usage
end

Instance Attribute Details

#request_duration_msObject

Request duration in milliseconds



1113
1114
1115
# File 'lib/stripe/api_requestor.rb', line 1113

def request_duration_ms
  @request_duration_ms
end

#request_idObject

The Stripe request ID of the response.



1110
1111
1112
# File 'lib/stripe/api_requestor.rb', line 1110

def request_id
  @request_id
end

#usageObject

list of names of tracked behaviors associated with this request



1116
1117
1118
# File 'lib/stripe/api_requestor.rb', line 1116

def usage
  @usage
end

Instance Method Details

#payloadObject



1124
1125
1126
1127
1128
# File 'lib/stripe/api_requestor.rb', line 1124

def payload
  ret = { request_id: request_id, request_duration_ms: request_duration_ms }
  ret[:usage] = usage if !usage.nil? && !usage.empty?
  ret
end