moesif_rack 1.4.18 → 1.4.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -1
- data/lib/moesif_rack/moesif_middleware.rb +17 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9648d28da08853893881cd32fef5fcf61d4f8d2c6a573d06ced10bb4e01bda3c
|
4
|
+
data.tar.gz: cebdf8b64372dd77a80520e8cbec1da161f623a6435a8ced10a700aa86e57113
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35bb379b52dc6f4323d5dc98154c5ba741e438ec1cf98030f06775405c405e4a34871b9435a9a3f89d0b32e6545c2f6ec88083e59d2c4e97c271e765200e89bc
|
7
|
+
data.tar.gz: 72422bb99d80d78e91af4034ff4dd31f7f94c8424a498819a6767ce066045209e4dc8c1e9784a88377cf100e79fad3cb0733989f0869b449dedf60e91b916f60
|
data/README.md
CHANGED
@@ -255,8 +255,17 @@ Optional. Boolean. Default false. If true, it will print out debug messages. In
|
|
255
255
|
|
256
256
|
Optional. Boolean. Default true. If false, will not log request and response body to Moesif.
|
257
257
|
|
258
|
+
#### __`batch_size`__
|
259
|
+
Optional. int, default 200, Maximum batch size when sending to Moesif.
|
260
|
+
|
261
|
+
#### __`batch_max_time`__
|
262
|
+
Optional. int in seconds Default 2. This is the maximum wait time (approximately) before triggering flushing of the queue and sending to Moesif.
|
263
|
+
|
264
|
+
#### __`event_queue_size`__
|
265
|
+
Optional. int, Default 1000, Maximum number of events to hold in queue before sending to Moesif. In case of network issues when not able to connect/send event to Moesif, skips adding new to event to queue to prevent memory overflow.
|
266
|
+
|
258
267
|
#### __`capture_outgoing_requests`__
|
259
|
-
Optional.
|
268
|
+
Optional. Boolean, Default `false`. Set to `true` to capture all outgoing API calls from your app to third parties like Stripe, Github or to your own dependencies while using [Net::HTTP](https://ruby-doc.org/stdlib-2.6.3/libdoc/net/http/rdoc/Net/HTTP.html) package. The options below is applied to outgoing API calls. When the request is outgoing, for options functions that take request and response as input arguments, the request and response objects passed in are [Request](https://www.rubydoc.info/stdlib/net/Net/HTTPRequest) request and [Response](https://www.rubydoc.info/stdlib/net/Net/HTTPResponse) response objects.
|
260
269
|
|
261
270
|
|
262
271
|
##### __`identify_user_outgoing`__
|
@@ -35,14 +35,17 @@ module MoesifRack
|
|
35
35
|
@config = @app_config.get_config(@api_controller)
|
36
36
|
@config_etag = nil
|
37
37
|
@last_config_download_time = Time.now.utc
|
38
|
-
@last_worker_run = Time.now.utc
|
39
38
|
@config_dict = Hash.new
|
40
39
|
@disable_transaction_id = options['disable_transaction_id'] || false
|
41
40
|
@log_body = options.fetch('log_body', true)
|
42
|
-
@batch_size = options['batch_size'] ||
|
41
|
+
@batch_size = options['batch_size'] || 200
|
42
|
+
@event_queue_size = options['event_queue_size'] || 1000
|
43
43
|
@batch_max_time = options['batch_max_time'] || 2
|
44
44
|
@events_queue = Queue.new
|
45
45
|
@event_response_config_etag = nil
|
46
|
+
|
47
|
+
# start the worker and Update the last worker run
|
48
|
+
@last_worker_run = Time.now.utc
|
46
49
|
start_worker()
|
47
50
|
|
48
51
|
begin
|
@@ -144,10 +147,14 @@ module MoesifRack
|
|
144
147
|
|
145
148
|
def start_worker
|
146
149
|
Thread::new do
|
147
|
-
@last_worker_run = Time.now.utc
|
148
150
|
loop do
|
151
|
+
# Update the last worker run, in case the events_queue is empty
|
152
|
+
@last_worker_run = Time.now.utc
|
149
153
|
begin
|
150
154
|
until @events_queue.empty? do
|
155
|
+
# Update the last worker run in case sending events take more than 60 seconds
|
156
|
+
@last_worker_run = Time.now.utc
|
157
|
+
# Populate the batch events from queue
|
151
158
|
batch_events = []
|
152
159
|
until batch_events.size == @batch_size || @events_queue.empty? do
|
153
160
|
batch_events << @events_queue.pop
|
@@ -321,8 +328,13 @@ module MoesifRack
|
|
321
328
|
if sampling_percentage > random_percentage
|
322
329
|
event_model.weight = @app_config.calculate_weight(sampling_percentage)
|
323
330
|
# Add Event to the queue
|
324
|
-
@events_queue
|
325
|
-
|
331
|
+
if @events_queue.size >= @event_queue_size
|
332
|
+
@moesif_helpers.log_debug("Skipped Event due to events_queue size [#{@events_queue.size}] is over max #{@event_queue_size} ")
|
333
|
+
else
|
334
|
+
@events_queue << event_model
|
335
|
+
@moesif_helpers.log_debug("Event added to the queue ")
|
336
|
+
end
|
337
|
+
|
326
338
|
if Time.now.utc > (@last_worker_run + 60)
|
327
339
|
start_worker()
|
328
340
|
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.19
|
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: 2023-02-
|
12
|
+
date: 2023-02-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: test-unit
|