moesif_rack 1.4.9 → 1.4.13
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b3a1d161ed29b64ba421ea3ce26eeca1a4c07e254026ddde7c309050698f6b7
|
4
|
+
data.tar.gz: 5b1c25138700a1d87aad3544a2fcdd9c60d937ba9e5a9520f8c1d76504b25e57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb83df52630f55e46e87af701009adc52c88e0a3adf197482688fb6590f5b78f667123e356504dbe5ee8fb936e3e732879fb0c15d6531c7da9b6667e8aeb30ab
|
7
|
+
data.tar.gz: '087f2422c60f09f2aefd1e98ca84d99475257776950429cbdba67ea98adca0211ecdc81e9c2b9a751664f5b38e5630af1bc0b9e4633eff60bee95df4cdef7b0f'
|
data/LICENSE
CHANGED
@@ -156,17 +156,20 @@ module MoesifRack
|
|
156
156
|
end
|
157
157
|
|
158
158
|
def call env
|
159
|
-
start_time = Time.now.utc.iso8601
|
159
|
+
start_time = Time.now.utc.iso8601(3)
|
160
160
|
|
161
161
|
@helpers.log_debug('Calling Moesif middleware')
|
162
162
|
|
163
163
|
status, headers, body = @app.call env
|
164
|
-
end_time = Time.now.utc.iso8601
|
164
|
+
end_time = Time.now.utc.iso8601(3)
|
165
165
|
|
166
166
|
process_send = lambda do
|
167
167
|
req = Rack::Request.new(env)
|
168
168
|
complex_copy = env.dup
|
169
169
|
|
170
|
+
# Filter hash to only have keys of type string
|
171
|
+
complex_copy = complex_copy.select { |k, v| k.is_a? String }
|
172
|
+
|
170
173
|
req_headers = {}
|
171
174
|
complex_copy.select {|k,v| k.start_with?('HTTP_', 'CONTENT_') }.each do |key, val|
|
172
175
|
new_key = key.sub(/^HTTP_/, '')
|
@@ -336,6 +339,7 @@ module MoesifRack
|
|
336
339
|
rescue => exception
|
337
340
|
@helpers.log_debug 'Error while logging event - '
|
338
341
|
@helpers.log_debug exception.to_s
|
342
|
+
@helpers.log_debug exception.backtrace
|
339
343
|
end
|
340
344
|
end
|
341
345
|
|
@@ -7,7 +7,7 @@ module Net
|
|
7
7
|
def request(request, body = nil, &block)
|
8
8
|
|
9
9
|
# Request Start Time
|
10
|
-
request_time = Time.now.utc.iso8601
|
10
|
+
request_time = Time.now.utc.iso8601(3)
|
11
11
|
|
12
12
|
# URL
|
13
13
|
url = "https://#{@address}#{request.path}"
|
@@ -16,7 +16,7 @@ module Net
|
|
16
16
|
@response = orig_request(request, body, &block)
|
17
17
|
|
18
18
|
# Response Time
|
19
|
-
response_time = Time.now.utc.iso8601
|
19
|
+
response_time = Time.now.utc.iso8601(3)
|
20
20
|
|
21
21
|
# Log Event to Moesif
|
22
22
|
if started?
|
@@ -24,15 +24,15 @@ module MoesifCaptureOutgoing
|
|
24
24
|
@skip_outgoing = options['skip_outgoing']
|
25
25
|
@mask_data_outgoing = options['mask_data_outgoing']
|
26
26
|
@log_body_outgoing = options.fetch('log_body_outgoing', true)
|
27
|
-
@app_config = AppConfig.new
|
28
|
-
@config = @app_config.get_config(@api_controller, @debug)
|
27
|
+
@app_config = AppConfig.new(@debug)
|
29
28
|
@config_etag = nil
|
30
29
|
@sampling_percentage = 100
|
31
30
|
@last_updated_time = Time.now.utc
|
32
31
|
@config_dict = Hash.new
|
33
32
|
begin
|
34
|
-
|
35
|
-
|
33
|
+
new_config = @app_config.get_config(@api_controller)
|
34
|
+
if !new_config.nil?
|
35
|
+
@config, @config_etag, @last_config_download_time = @app_config.parse_configuration(new_config)
|
36
36
|
end
|
37
37
|
rescue => exception
|
38
38
|
if @debug
|
@@ -176,7 +176,7 @@ module MoesifCaptureOutgoing
|
|
176
176
|
begin
|
177
177
|
@random_percentage = Random.rand(0.00..100.00)
|
178
178
|
begin
|
179
|
-
@sampling_percentage = @app_config.get_sampling_percentage(@config, event_model.user_id, event_model.company_id
|
179
|
+
@sampling_percentage = @app_config.get_sampling_percentage(@config, event_model.user_id, event_model.company_id)
|
180
180
|
rescue => exception
|
181
181
|
if @debug
|
182
182
|
puts 'Error while getting sampling percentage, assuming default behavior'
|
@@ -196,8 +196,10 @@ module MoesifCaptureOutgoing
|
|
196
196
|
|
197
197
|
if !event_response_config_etag.nil? && !@config_etag.nil? && @config_etag != event_response_config_etag && Time.now.utc > @last_updated_time + 300
|
198
198
|
begin
|
199
|
-
|
200
|
-
|
199
|
+
new_config = @app_config.get_config(@api_controller)
|
200
|
+
if !new_config.nil?
|
201
|
+
@config, @config_etag, @last_config_download_time = @app_config.parse_configuration(new_config)
|
202
|
+
end
|
201
203
|
rescue => exception
|
202
204
|
if @debug
|
203
205
|
puts 'Error while updating the application configuration'
|
@@ -222,7 +224,7 @@ module MoesifCaptureOutgoing
|
|
222
224
|
puts e.response_code
|
223
225
|
end
|
224
226
|
rescue => e
|
225
|
-
if debug
|
227
|
+
if @debug
|
226
228
|
puts e.to_s
|
227
229
|
end
|
228
230
|
end
|
data/test/moesif_rack_test.rb
CHANGED
@@ -46,7 +46,7 @@ class MoesifRackTest < Test::Unit::TestCase
|
|
46
46
|
}
|
47
47
|
}
|
48
48
|
@moesif_rack_app = MoesifRack::MoesifMiddleware.new(@app, @options)
|
49
|
-
@app_config = AppConfig.new
|
49
|
+
@app_config = AppConfig.new(true)
|
50
50
|
end
|
51
51
|
|
52
52
|
def test_capture_outgoing
|
@@ -116,7 +116,7 @@ class MoesifRackTest < Test::Unit::TestCase
|
|
116
116
|
def test_get_config
|
117
117
|
@api_client = MoesifApi::MoesifAPIClient.new(@options['application_id'])
|
118
118
|
@api_controller = @api_client.api
|
119
|
-
@config = @app_config.get_config(@api_controller
|
119
|
+
@config = @app_config.get_config(@api_controller)
|
120
120
|
@config_etag, @sampling_percentage, @last_updated_time = @app_config.parse_configuration(@config, @debug)
|
121
121
|
assert_operator 100, :>=, @sampling_percentage
|
122
122
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moesif_rack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Moesif, Inc
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-08-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|