http_instrumentation 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8c62a0d7cd2f490aab2e2dfda4ca18b6cfe794cc013e65862b1e5e0984a121e7
4
- data.tar.gz: be98556c0d7c90633278f6eae1688a0b9e07ddf5ad0065122ef7aefc6b36adb2
3
+ metadata.gz: 7a0f448a4cfc986fa5464322bbeaad7c72ceecd10fc50bc73c1cf4d8803c1526
4
+ data.tar.gz: b38f47152964ca8df8f21dd7f04f054c89e2bb904de075b5dbe358fe7960ea17
5
5
  SHA512:
6
- metadata.gz: 7239288a4d4ec3ab8545d0bacc37c47cd3eeb7be7786c1434bcc1fca2f7bb717597fd13319573a107acf0be8bf5cce79c2caa89ba1b30ec7a560efcc05fae05b
7
- data.tar.gz: 2b2020627f1ea45b8707827115f18337fa5fb42b11e673ff4078bd96241a8f495f9dba70fa38a7c21911d2692b05d19692ddd8042bc685d547caf549f64acbad
6
+ metadata.gz: df71fb5803be041e6764d7448610005338ddb9f1f3a2f0b70eef52b83c00bd7ec22827149b2afd6fb4ed573de17b093410034b68085bfb3ce6684c352552823c
7
+ data.tar.gz: d15c618345381bb7c2d96f5ab5fc0384d33080be5d2ccb205624058ae6ece2f81e01487527667045049f6cf4ecfa17792e25e3fb6e6dff80f5705948c0cc1e79
data/CHANGELOG.md CHANGED
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## 1.0.4
8
+
9
+ ### Fixed
10
+ - A request URL that parses as an opaque URI (e.g. `localhost:8080/path`, which parses with the scheme `localhost`) or that has an empty host (e.g. `http:///path`) no longer raises a `URI::Error` from the instrumentation after the request completes. Because the error was raised while normalizing the event payload, the published event also kept the raw `:url` value (such as a `URI` object) instead of a string.
11
+
7
12
  ## 1.0.3
8
13
 
9
14
  ### Fixed
data/README.md CHANGED
@@ -33,12 +33,12 @@ The payload on event notifications for all HTTP requests will include:
33
33
 
34
34
  If a single HTTP request was made, then these keys will exist as well:
35
35
 
36
- * `:uri` - The URI for the request
37
- * `:url` - The URL for the request with any query string stripped off
38
- * `:http_method` - The HTTP method for the request
39
- * `:status_code` - The numeric HTTP status code for the response
36
+ * `:uri` - The URI for the request (`URI`)
37
+ * `:url` - The URL for the request with any query string stripped off (`String`)
38
+ * `:http_method` - The HTTP method for the request (`Symbol`)
39
+ * `:status_code` - The numeric HTTP status code for the response (`Integer`)
40
40
 
41
- These additional values will not be present if multiple, concurrent requests were made. Only the typhoeus, ethon, and httpx libraries support making concurrent requests.
41
+ These additional values will not be present if multiple, concurrent requests were made. Only the typhoeus, ethon, and httpx libraries support making concurrent requests. Any of the values can also be nil if the request was corrupted or invalid.
42
42
 
43
43
  ```ruby
44
44
  ActiveSupport::Notifications.monotonic_subscribe("request.http") do |*args|
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.3
1
+ 1.0.4
@@ -148,17 +148,19 @@ module HTTPInstrumentation
148
148
  end
149
149
 
150
150
  # Remove any sensitive information from the given URL. Also normalizes
151
- # the host and protocol by downcasing them.
151
+ # the host and protocol by downcasing them. Returns nil if the value
152
+ # cannot be parsed or sanitized as a URI.
152
153
  #
153
154
  # @param url [URI] the sanitized URL
154
155
  def sanitized_uri(url)
155
156
  return nil if url.nil?
156
157
 
157
- begin
158
- uri = URI(url.to_s)
159
- rescue URI::Error
160
- return nil
161
- end
158
+ uri = URI(url.to_s)
159
+
160
+ # Opaque URIs (e.g. "localhost:8080/path" parses with scheme "localhost")
161
+ # have no user, host, or query components to sanitize, and the component
162
+ # setters raise on them.
163
+ return uri if uri.opaque
162
164
 
163
165
  uri.password = nil
164
166
  uri.user = nil
@@ -176,6 +178,8 @@ module HTTPInstrumentation
176
178
  end
177
179
 
178
180
  uri
181
+ rescue URI::Error
182
+ nil
179
183
  end
180
184
 
181
185
  def uri_without_query_string(uri)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http_instrumentation
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Durand
@@ -63,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
63
  - !ruby/object:Gem::Version
64
64
  version: '0'
65
65
  requirements: []
66
- rubygems_version: 4.0.3
66
+ rubygems_version: 3.6.9
67
67
  specification_version: 4
68
68
  summary: ActiveSupoprt instrumentation for a variety of Ruby HTTP client libraries.
69
69
  test_files: []