union_station_hooks_core 2.0.4 → 2.1.1
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 +4 -4
- data/LICENSE.md +1 -1
- data/lib/union_station_hooks_core/api.rb +28 -0
- data/lib/union_station_hooks_core/context.rb +7 -5
- data/lib/union_station_hooks_core/request_reporter/misc.rb +4 -0
- data/lib/union_station_hooks_core/spec_helper.rb +18 -0
- data/lib/union_station_hooks_core/transaction.rb +1 -10
- data/lib/union_station_hooks_core/version_data.rb +4 -4
- data/lib/union_station_hooks_core.rb +7 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dfc9815e53e9b9fdd1ec5ec8406c75dbe63cfad1
|
4
|
+
data.tar.gz: 9ff6e5d34e4c703e4a1a3d98272dea5e49b07cfc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95656628e3239ee71c71b21bf5d093150934f68dcd3cee2642d224c90f1b670304248b173b9b1d60503cd5df6ea75316a7c6a36118ccdb18870aa3624f92050c
|
7
|
+
data.tar.gz: a3fa7113d2d569c3c1c3a23dcb1efd2853bfaee3434f116b3c128a9b8e143a7f667a6018d90cdd38bcd4fba685587f8f6a4c6f641a6a416e6b4337b3cc1bad52
|
data/LICENSE.md
CHANGED
@@ -118,6 +118,34 @@ module UnionStationHooks
|
|
118
118
|
end
|
119
119
|
end
|
120
120
|
|
121
|
+
# Logs an exception that did NOT occur during a request.
|
122
|
+
#
|
123
|
+
# This method should be used for logging exceptions outside the
|
124
|
+
# request-response cycle, e.g. exceptions in threads. If you want to
|
125
|
+
# log a request that occurred during a request, use
|
126
|
+
# {RequestReporter#log_exception} instead. That method will also log
|
127
|
+
# any related request-specific information, while this method does not.
|
128
|
+
#
|
129
|
+
# @param [Exception] exception
|
130
|
+
# @since 2.1.0
|
131
|
+
def log_exception(exception)
|
132
|
+
transaction = context.new_transaction(app_group_name, :exceptions, key)
|
133
|
+
begin
|
134
|
+
return do_nothing_on_null(:log_exception) if transaction.null?
|
135
|
+
|
136
|
+
base64_message = exception.message
|
137
|
+
base64_message = exception.to_s if base64_message.empty?
|
138
|
+
base64_message = Utils.base64(base64_message)
|
139
|
+
base64_backtrace = Utils.base64(exception.backtrace.join("\n"))
|
140
|
+
|
141
|
+
transaction.message("Message: #{base64_message}")
|
142
|
+
transaction.message("Class: #{exception.class.name}")
|
143
|
+
transaction.message("Backtrace: #{base64_backtrace}")
|
144
|
+
ensure
|
145
|
+
transaction.close
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
121
149
|
# Returns an opaque object (a {TimePoint}) that represents a collection
|
122
150
|
# of metrics about the current time.
|
123
151
|
#
|
@@ -59,10 +59,8 @@ module UnionStationHooks
|
|
59
59
|
@server_address = ust_router_address
|
60
60
|
@username = username
|
61
61
|
@password = password
|
62
|
-
if node_name &&
|
63
|
-
@node_name =
|
64
|
-
else
|
65
|
-
@node_name = `hostname`.strip
|
62
|
+
if node_name && node_name.empty?
|
63
|
+
@node_name = nil
|
66
64
|
end
|
67
65
|
|
68
66
|
# This mutex protects the following instance variables, but
|
@@ -271,7 +269,11 @@ module UnionStationHooks
|
|
271
269
|
end
|
272
270
|
|
273
271
|
def handshake_initialization(channel)
|
274
|
-
|
272
|
+
if @node_name
|
273
|
+
channel.write('init', @node_name)
|
274
|
+
else
|
275
|
+
channel.write('init')
|
276
|
+
end
|
275
277
|
process_ust_router_reply(channel,
|
276
278
|
'UstRouter client initialization error')
|
277
279
|
end
|
@@ -166,6 +166,10 @@ module UnionStationHooks
|
|
166
166
|
|
167
167
|
# Logs an exception that occurred during a request.
|
168
168
|
#
|
169
|
+
# If you want to use an exception that occurred outside the
|
170
|
+
# request/response cycle, e.g. an exception that occurred in a thread,
|
171
|
+
# use {UnionStationHooks.log_exception} instead.
|
172
|
+
#
|
169
173
|
# If {#log_controller_action_block} or {#log_controller_action}
|
170
174
|
# was called during the same request, then the information passed to
|
171
175
|
# those methods will be included in the exception report.
|
@@ -220,6 +220,24 @@ module UnionStationHooks
|
|
220
220
|
end
|
221
221
|
end
|
222
222
|
|
223
|
+
# Assert that the dump file eventually exists and that its contents
|
224
|
+
# eventually match the given regex.
|
225
|
+
def eventually_expect_dump_file_to_match(regex, category = 'requests')
|
226
|
+
wait_for_dump_file_existance(category)
|
227
|
+
eventually do
|
228
|
+
read_dump_file(category) =~ regex
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
# Assert that the dump file (if it ever exists) its contents will never match
|
233
|
+
# the given regex.
|
234
|
+
def never_expect_dump_file_to_match(regex, category = 'requests')
|
235
|
+
should_never_happen do
|
236
|
+
File.exist?(dump_file_path(category)) &&
|
237
|
+
read_dump_file(category) =~ regex
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
223
241
|
# Makes `UnionStationHooks::Log.warn` not print anything.
|
224
242
|
def silence_warnings
|
225
243
|
UnionStationHooks::Log.warn_callback = lambda { |_message| }
|
@@ -125,7 +125,7 @@ module UnionStationHooks
|
|
125
125
|
log_activity_end(name, end_time, has_error)
|
126
126
|
end
|
127
127
|
|
128
|
-
def close
|
128
|
+
def close
|
129
129
|
return if !@connection
|
130
130
|
|
131
131
|
@connection.synchronize do
|
@@ -140,9 +140,6 @@ module UnionStationHooks
|
|
140
140
|
Utils.encoded_timestamp, true)
|
141
141
|
Utils.process_ust_router_reply(@connection.channel,
|
142
142
|
"Error handling reply for 'closeTransaction' message")
|
143
|
-
if should_flush_to_disk
|
144
|
-
flush_to_disk
|
145
|
-
end
|
146
143
|
end
|
147
144
|
ensure
|
148
145
|
@connection.unref
|
@@ -175,11 +172,5 @@ module UnionStationHooks
|
|
175
172
|
@connection.disconnect
|
176
173
|
raise e
|
177
174
|
end
|
178
|
-
|
179
|
-
def flush_to_disk
|
180
|
-
@connection.channel.write('flush')
|
181
|
-
Utils.process_ust_router_reply(@connection.channel,
|
182
|
-
"Error handling reply for 'flush' message")
|
183
|
-
end
|
184
175
|
end
|
185
176
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Union Station - https://www.unionstationapp.com/
|
2
|
-
# Copyright (c) 2010-
|
2
|
+
# Copyright (c) 2010-2016 Phusion Holding B.V.
|
3
3
|
#
|
4
4
|
# "Union Station" and "Passenger" are trademarks of Phusion Holding B.V.
|
5
5
|
#
|
@@ -38,7 +38,7 @@
|
|
38
38
|
|
39
39
|
{
|
40
40
|
:major => 2,
|
41
|
-
:minor =>
|
42
|
-
:tiny =>
|
43
|
-
:string => '2.
|
41
|
+
:minor => 1,
|
42
|
+
:tiny => 1,
|
43
|
+
:string => '2.1.1'
|
44
44
|
}
|
@@ -56,6 +56,7 @@ end
|
|
56
56
|
# * {UnionStationHooks.begin_rack_request} and
|
57
57
|
# {UnionStationHooks.end_rack_request}
|
58
58
|
# * {UnionStationHooks::RequestReporter}
|
59
|
+
# * {UnionStationHooks.log_exception}
|
59
60
|
#
|
60
61
|
# ## Rack example
|
61
62
|
#
|
@@ -323,6 +324,12 @@ module UnionStationHooks
|
|
323
324
|
nil
|
324
325
|
end
|
325
326
|
|
327
|
+
def log_exception(_exception)
|
328
|
+
# When `initialize!` is called, the definition in
|
329
|
+
# `api.rb` will override this implementation.
|
330
|
+
nil
|
331
|
+
end
|
332
|
+
|
326
333
|
private
|
327
334
|
|
328
335
|
def finalize_and_validate_config
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: union_station_hooks_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hongli Lai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Union Station Ruby hooks core code.
|
14
14
|
email: info@phusion.nl
|
@@ -58,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
58
|
version: '0'
|
59
59
|
requirements: []
|
60
60
|
rubyforge_project:
|
61
|
-
rubygems_version: 2.4.
|
61
|
+
rubygems_version: 2.4.5.1
|
62
62
|
signing_key:
|
63
63
|
specification_version: 4
|
64
64
|
summary: Union Station Ruby hooks core code
|