union_station_hooks_core 2.0.0 → 2.0.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 +8 -8
- data/lib/union_station_hooks_core/api.rb +10 -0
- data/lib/union_station_hooks_core/context.rb +6 -24
- data/lib/union_station_hooks_core/request_reporter/basics.rb +2 -2
- data/lib/union_station_hooks_core/request_reporter/misc.rb +8 -1
- data/lib/union_station_hooks_core/request_reporter.rb +1 -0
- data/lib/union_station_hooks_core/version_data.rb +2 -2
- data/lib/union_station_hooks_core.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Mjg3MGI3ZWUzZTk0NDRmMWQyMTI5ZDJiY2JiN2U1NDk0ZjFiYTRjZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZDExODg5NjdjYWVlYjNiYmYyY2ZiNTlmYTZlNGQyOTgyMTEzMTMyOQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NzRlYTIyZDc5ZTE5Zjc1ODZkNzg3YjhjMmM1MTJmZjk4OWMwZWUwMzNiOTVl
|
10
|
+
NDViNDM2ZjFmMTdjZTk5MjkzNzg0NjliM2U4MTBmOWQ1Nzg5OGE2ZDRlOTUz
|
11
|
+
YWI0NTIzNjI5NjZlYjBkMTE2NGJiYjFiZDAyMzk3MzU4MGEzOWE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZjEyNWM2MGVjNjg5Zjk3OGYxOWIzZTQ4NjJjMDY2ODY3NGI5N2JiYmMxNWZl
|
14
|
+
ZDM3MjdhMGVhZWY5NzU4MjQ5NzY0ZjA0MWQzNWVlZjEwNTNlNTk4ZWRlNDky
|
15
|
+
Y2Q5NWQ2ZTgzYTcyOTZmNzgxZjI1ZTQyNmE3ZmRhYjM5YWNhN2M=
|
@@ -151,6 +151,16 @@ module UnionStationHooks
|
|
151
151
|
config[:node_name])
|
152
152
|
end
|
153
153
|
|
154
|
+
def install_postfork_hook
|
155
|
+
if defined?(PhusionPassenger)
|
156
|
+
PhusionPassenger.on_event(:starting_worker_process) do |forked|
|
157
|
+
if forked
|
158
|
+
UnionStationHooks.context.clear_connection
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
154
164
|
def install_event_pre_hook
|
155
165
|
preprocessor = @@config[:event_preprocessor]
|
156
166
|
if preprocessor
|
@@ -64,7 +64,6 @@ module UnionStationHooks
|
|
64
64
|
else
|
65
65
|
@node_name = `hostname`.strip
|
66
66
|
end
|
67
|
-
@random_dev = File.open('/dev/urandom')
|
68
67
|
|
69
68
|
# This mutex protects the following instance variables, but
|
70
69
|
# not the contents of @connection.
|
@@ -89,7 +88,6 @@ module UnionStationHooks
|
|
89
88
|
def clear_connection
|
90
89
|
@mutex.synchronize do
|
91
90
|
@connection.synchronize do
|
92
|
-
@random_dev = File.open('/dev/urandom') if @random_dev.closed?
|
93
91
|
@connection.unref
|
94
92
|
@connection = Connection.new(nil)
|
95
93
|
end
|
@@ -99,7 +97,6 @@ module UnionStationHooks
|
|
99
97
|
def close
|
100
98
|
@mutex.synchronize do
|
101
99
|
@connection.synchronize do
|
102
|
-
@random_dev.close
|
103
100
|
@connection.unref
|
104
101
|
@connection = nil
|
105
102
|
end
|
@@ -113,8 +110,6 @@ module UnionStationHooks
|
|
113
110
|
raise ArgumentError, 'Group name may not be empty'
|
114
111
|
end
|
115
112
|
|
116
|
-
txn_id = create_txn_id
|
117
|
-
|
118
113
|
Lock.new(@mutex).synchronize do |_lock|
|
119
114
|
if Time.now < @next_reconnect_time
|
120
115
|
return Transaction.new(nil, nil)
|
@@ -140,7 +135,7 @@ module UnionStationHooks
|
|
140
135
|
|
141
136
|
begin
|
142
137
|
@connection.channel.write('openTransaction',
|
143
|
-
|
138
|
+
'', group_name, '', category,
|
144
139
|
Utils.encoded_timestamp,
|
145
140
|
key,
|
146
141
|
true,
|
@@ -149,20 +144,21 @@ module UnionStationHooks
|
|
149
144
|
if result[0] != 'status'
|
150
145
|
raise "Expected UstRouter to respond with 'status', " \
|
151
146
|
"but got #{result.inspect} instead"
|
152
|
-
elsif result[1] == 'ok'
|
153
|
-
# Do nothing
|
154
147
|
elsif result[1] == 'error'
|
155
148
|
if result[2]
|
156
149
|
raise "Unable to close transaction: #{result[2]}"
|
157
150
|
else
|
158
151
|
raise 'Unable to close transaction (no server message given)'
|
159
152
|
end
|
160
|
-
|
153
|
+
elsif result[1] != 'ok'
|
161
154
|
raise "Expected UstRouter to respond with 'ok' or 'error', " \
|
162
155
|
"but got #{result.inspect} instead"
|
156
|
+
elsif result.size < 3
|
157
|
+
raise 'Expected UstRouter to respond with an autogenerated ' \
|
158
|
+
'transaction ID, but got none'
|
163
159
|
end
|
164
160
|
|
165
|
-
return Transaction.new(@connection,
|
161
|
+
return Transaction.new(@connection, result[2])
|
166
162
|
rescue SystemCallError, IOError
|
167
163
|
@connection.disconnect
|
168
164
|
UnionStationHooks::Log.warn(
|
@@ -279,19 +275,5 @@ module UnionStationHooks
|
|
279
275
|
process_ust_router_reply(channel,
|
280
276
|
'UstRouter client initialization error')
|
281
277
|
end
|
282
|
-
|
283
|
-
def random_token(length)
|
284
|
-
token = ''
|
285
|
-
@random_dev.read(length).each_byte do |c|
|
286
|
-
token << RANDOM_CHARS[c % RANDOM_CHARS.size]
|
287
|
-
end
|
288
|
-
token
|
289
|
-
end
|
290
|
-
|
291
|
-
def create_txn_id
|
292
|
-
result = (Time.now.to_i / 60).to_s(36)
|
293
|
-
result << "-#{random_token(11)}"
|
294
|
-
result
|
295
|
-
end
|
296
278
|
end
|
297
279
|
end
|
@@ -148,7 +148,7 @@ module UnionStationHooks
|
|
148
148
|
# @return An ID to be passed later to {#log_writing_rack_body_end}.
|
149
149
|
def log_writing_rack_body_begin
|
150
150
|
return do_nothing_on_null(:log_writing_rack_body_begin) if null?
|
151
|
-
@transaction.log_activity_begin('writing out response body')
|
151
|
+
@transaction.log_activity_begin('app writing out response body')
|
152
152
|
nil
|
153
153
|
end
|
154
154
|
|
@@ -162,7 +162,7 @@ module UnionStationHooks
|
|
162
162
|
# @private
|
163
163
|
def log_writing_rack_body_end(id)
|
164
164
|
return do_nothing_on_null(:log_writing_rack_body_end) if null?
|
165
|
-
@transaction.log_activity_end('writing out response body')
|
165
|
+
@transaction.log_activity_end('app writing out response body')
|
166
166
|
nil
|
167
167
|
end
|
168
168
|
|
@@ -159,7 +159,8 @@ module UnionStationHooks
|
|
159
159
|
do_nothing_on_null(:log_benchmark_block)
|
160
160
|
yield
|
161
161
|
else
|
162
|
-
|
162
|
+
@transaction.log_activity_block(next_benchmark_name,
|
163
|
+
title, &block)
|
163
164
|
end
|
164
165
|
end
|
165
166
|
|
@@ -283,6 +284,12 @@ module UnionStationHooks
|
|
283
284
|
"user activity #{result}"
|
284
285
|
end
|
285
286
|
|
287
|
+
def next_benchmark_name
|
288
|
+
result = @next_benchmark_number
|
289
|
+
@next_benchmark_number += 1
|
290
|
+
"benchmark #{result}"
|
291
|
+
end
|
292
|
+
|
286
293
|
def next_database_query_name
|
287
294
|
result = @next_database_query_number
|
288
295
|
@next_database_query_number += 1
|
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.0.
|
4
|
+
version: 2.0.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: 2015-09-
|
11
|
+
date: 2015-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Union Station Ruby hooks core code.
|
14
14
|
email: info@phusion.nl
|