mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-10-04 00:00:47 -04:00
Add request_id
to RequestEndEvent (#993)
Co-authored-by: Richard Marmorstein <52928443+richardm-stripe@users.noreply.github.com>
This commit is contained in:
parent
378c71dec7
commit
85c7f52c3a
@ -252,6 +252,7 @@ a success or error. Receives `RequestEndEvent` with the following properties:
|
||||
- `path`: Request path. (`String`)
|
||||
- `user_data`: A hash on which users may have set arbitrary data in
|
||||
`request_begin`. See above for more information. (`Hash`)
|
||||
- `request_id`. HTTP request identifier.
|
||||
|
||||
#### Example
|
||||
|
||||
|
@ -32,6 +32,7 @@ module Stripe
|
||||
attr_reader :method
|
||||
attr_reader :num_retries
|
||||
attr_reader :path
|
||||
attr_reader :request_id
|
||||
|
||||
# Arbitrary user-provided data in the form of a Ruby hash that's passed
|
||||
# from subscribers on `request_begin` to subscribers on `request_end`.
|
||||
@ -40,12 +41,13 @@ module Stripe
|
||||
attr_reader :user_data
|
||||
|
||||
def initialize(duration:, http_status:, method:, num_retries:, path:,
|
||||
user_data: nil)
|
||||
request_id:, user_data: nil)
|
||||
@duration = duration
|
||||
@http_status = http_status
|
||||
@method = method
|
||||
@num_retries = num_retries
|
||||
@path = path
|
||||
@request_id = request_id
|
||||
@user_data = user_data
|
||||
freeze
|
||||
end
|
||||
|
@ -667,6 +667,7 @@ module Stripe
|
||||
method: context.method,
|
||||
num_retries: num_retries,
|
||||
path: context.path,
|
||||
request_id: context.request_id,
|
||||
user_data: user_data || {}
|
||||
)
|
||||
Stripe::Instrumentation.notify(:request_end, event)
|
||||
|
@ -64,6 +64,7 @@ module Stripe
|
||||
method: :get,
|
||||
num_retries: 0,
|
||||
path: "/v1/test",
|
||||
request_id: "req_123",
|
||||
user_data: nil
|
||||
)
|
||||
|
||||
|
@ -1408,7 +1408,7 @@ module Stripe
|
||||
Stripe::Instrumentation.subscribe(:request_end, :test) { |event| events << event }
|
||||
|
||||
stub_request(:get, "#{Stripe.api_base}/v1/charges")
|
||||
.to_return(body: JSON.generate(object: "charge"))
|
||||
.to_return(body: JSON.generate(object: "charge"), headers: { "Request-ID": "req_123" })
|
||||
Stripe::Charge.list
|
||||
|
||||
assert_equal(1, events.size)
|
||||
@ -1418,6 +1418,7 @@ module Stripe
|
||||
assert_equal(200, event.http_status)
|
||||
assert(event.duration.positive?)
|
||||
assert_equal(0, event.num_retries)
|
||||
assert_equal("req_123", event.request_id)
|
||||
end
|
||||
|
||||
should "notify a subscriber of a StripeError" do
|
||||
|
Loading…
x
Reference in New Issue
Block a user