stripe 8.0.0 → 8.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6dccdd56e293fe589e24cbe9dfaa4a4dec846e6693725f695e023c731c29a9a1
4
- data.tar.gz: 899abdb8f1449712fbf30bab8b615819e853500d7df10b5830dd29ea652bed63
3
+ metadata.gz: 33a577d3a54901e265c71453a87d54a54bbb6905f2b698b1f7ee8129661dbdb7
4
+ data.tar.gz: 5c1d73b562666f0761f01c505e1958a81ccc1d94e582d88087ddf768db3ca814
5
5
  SHA512:
6
- metadata.gz: ccc38cdd75c55a8af558550fbaa37adef6e3802ce3b2399e0c5d8c883eefcbbbc0ef356d4d905006eb6f26459c8a276225c180938e5f007c7b247cc938e1842f
7
- data.tar.gz: b8d4252feb4c72fbd1f4a6a049604d2731b66f8f1400fcae9c9093b018c5d6bce7417bec009b2609f109ff8fca301c6ef5d6e81d37ddff7cc817678dfb3342ed
6
+ metadata.gz: af632e67609cb9b0486fdee261403c54d9f0b2e3b5b3332ad66eaf974bd240f102a8c7db3dddd4edc2919255a31363d77144722a5ee2f974661380ef3a92bffb
7
+ data.tar.gz: 3c184ec9d7ef44027e74b8b74a2bb72446fe45b68e5ce0c862a7aff51a5f4cc992b1d8ca6aeb48f6e359a8c0cf2e8eef1a80facde43f8eefddca03ef53a8b8f6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## 8.1.0 - 2023-01-12
4
+ * [#1162](https://github.com/stripe/stripe-ruby/pull/1162) Improve request events instrumentation
5
+
3
6
  ## 8.0.0 - 2022-11-16
4
7
  * [#1144](https://github.com/stripe/stripe-ruby/pull/1144) Next major release changes
5
8
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 8.0.0
1
+ 8.1.0
@@ -33,6 +33,10 @@ module Stripe
33
33
  attr_reader :num_retries
34
34
  attr_reader :path
35
35
  attr_reader :request_id
36
+ attr_reader :response_header
37
+ attr_reader :response_body
38
+ attr_reader :request_header
39
+ attr_reader :request_body
36
40
 
37
41
  # Arbitrary user-provided data in the form of a Ruby hash that's passed
38
42
  # from subscribers on `request_begin` to subscribers on `request_end`.
@@ -40,19 +44,53 @@ module Stripe
40
44
  # in `request_end`.
41
45
  attr_reader :user_data
42
46
 
43
- def initialize(duration:, http_status:, method:, num_retries:, path:,
44
- request_id:, user_data: nil)
45
- @duration = duration
46
- @http_status = http_status
47
- @method = method
47
+ def initialize(request_context:, response_context:,
48
+ num_retries:, user_data: nil)
49
+ @duration = request_context.duration
50
+ @http_status = response_context.http_status
51
+ @method = request_context.method
48
52
  @num_retries = num_retries
49
- @path = path
50
- @request_id = request_id
53
+ @path = request_context.path
54
+ @request_id = request_context.request_id
51
55
  @user_data = user_data
56
+ @response_header = response_context.header
57
+ @response_body = response_context.body
58
+ @request_header = request_context.header
59
+ @request_body = request_context.body
52
60
  freeze
53
61
  end
54
62
  end
55
63
 
64
+ class RequestContext
65
+ attr_reader :duration
66
+ attr_reader :method
67
+ attr_reader :path
68
+ attr_reader :request_id
69
+ attr_reader :body
70
+ attr_reader :header
71
+
72
+ def initialize(duration:, context:, header:)
73
+ @duration = duration
74
+ @method = context.method
75
+ @path = context.path
76
+ @request_id = context.request_id
77
+ @body = context.body
78
+ @header = header
79
+ end
80
+ end
81
+
82
+ class ResponseContext
83
+ attr_reader :http_status
84
+ attr_reader :body
85
+ attr_reader :header
86
+
87
+ def initialize(http_status:, response:)
88
+ @http_status = http_status
89
+ @header = response ? response.to_hash : nil
90
+ @body = response ? response.body : nil
91
+ end
92
+ end
93
+
56
94
  # This class was renamed for consistency. This alias is here for backwards
57
95
  # compatibility.
58
96
  RequestEvent = RequestEndEvent
@@ -494,15 +494,16 @@ module Stripe
494
494
  end
495
495
  end
496
496
 
497
- http_resp = execute_request_with_rescues(method, api_base, context) do
498
- self.class
499
- .default_connection_manager(config)
500
- .execute_request(method, url,
501
- body: body,
502
- headers: headers,
503
- query: query,
504
- &response_block)
505
- end
497
+ http_resp =
498
+ execute_request_with_rescues(method, api_base, headers, context) do
499
+ self.class
500
+ .default_connection_manager(config)
501
+ .execute_request(method, url,
502
+ body: body,
503
+ headers: headers,
504
+ query: query,
505
+ &response_block)
506
+ end
506
507
 
507
508
  [http_resp, api_key]
508
509
  end
@@ -564,7 +565,7 @@ module Stripe
564
565
  http_status >= 400
565
566
  end
566
567
 
567
- private def execute_request_with_rescues(method, api_base, context)
568
+ private def execute_request_with_rescues(method, api_base, headers, context)
568
569
  num_retries = 0
569
570
 
570
571
  begin
@@ -587,7 +588,7 @@ module Stripe
587
588
 
588
589
  log_response(context, request_start, http_status, resp.body, resp)
589
590
  notify_request_end(context, request_duration, http_status,
590
- num_retries, user_data)
591
+ num_retries, user_data, resp, headers)
591
592
 
592
593
  if config.enable_telemetry? && context.request_id
593
594
  request_duration_ms = (request_duration * 1000).to_i
@@ -614,7 +615,7 @@ module Stripe
614
615
  log_response_error(error_context, request_start, e)
615
616
  end
616
617
  notify_request_end(context, request_duration, http_status, num_retries,
617
- user_data)
618
+ user_data, resp, headers)
618
619
 
619
620
  if self.class.should_retry?(e,
620
621
  method: method,
@@ -657,17 +658,24 @@ module Stripe
657
658
  end
658
659
 
659
660
  private def notify_request_end(context, duration, http_status, num_retries,
660
- user_data)
661
+ user_data, resp, headers)
661
662
  return if !Instrumentation.any_subscribers?(:request_end) &&
662
663
  !Instrumentation.any_subscribers?(:request)
663
664
 
664
- event = Instrumentation::RequestEndEvent.new(
665
+ request_context = Stripe::Instrumentation::RequestContext.new(
665
666
  duration: duration,
667
+ context: context,
668
+ header: headers
669
+ )
670
+ response_context = Stripe::Instrumentation::ResponseContext.new(
666
671
  http_status: http_status,
667
- method: context.method,
672
+ response: resp
673
+ )
674
+
675
+ event = Instrumentation::RequestEndEvent.new(
676
+ request_context: request_context,
677
+ response_context: response_context,
668
678
  num_retries: num_retries,
669
- path: context.path,
670
- request_id: context.request_id,
671
679
  user_data: user_data || {}
672
680
  )
673
681
  Stripe::Instrumentation.notify(:request_end, event)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Stripe
4
- VERSION = "8.0.0"
4
+ VERSION = "8.1.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stripe
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.0.0
4
+ version: 8.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stripe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-16 00:00:00.000000000 Z
11
+ date: 2023-01-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Stripe is the easiest way to accept payments online. See https://stripe.com
14
14
  for details.
@@ -187,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
187
187
  - !ruby/object:Gem::Version
188
188
  version: '0'
189
189
  requirements: []
190
- rubygems_version: 3.3.7
190
+ rubygems_version: 3.3.26
191
191
  signing_key:
192
192
  specification_version: 4
193
193
  summary: Ruby bindings for the Stripe API