alacrity-rails 0.3.0 → 0.4.0

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
  SHA1:
3
- metadata.gz: d2ebad46ea6fbcdeb0f2ea4b6d9e75b4b1a2bb36
4
- data.tar.gz: d9bc00ae09670c29a19334acf2621febe1b39a4b
3
+ metadata.gz: b4a31f3e6df15a1a21699624e93401efa2558982
4
+ data.tar.gz: accd16378db208150a6877e887e65809d4b5e1fd
5
5
  SHA512:
6
- metadata.gz: 7e22d676984230594dc2b9c32975923baaba7acfa9b35fc298353005fd7711a9a5f1f93bef8f51155b3afb1bf3a35c80efa8b67d2638dd15c3284d0c4f086dbf
7
- data.tar.gz: 09e4057d68e49dd70a1506ea1e3667fd2322766e914b980797ebde1074c3820840c395c3e3aa439e816cf2ab59353966db7445aaaefd712ceeb3aa9683fe9dea
6
+ metadata.gz: c26325730dee3b9f34bb75501472377cf2807aca50be22f6e8b6af0e6a3ae08b8cdc8f54d634125492d0b8c175a6e8c9679ea34bf0281dde7d1fba31417b6f6c
7
+ data.tar.gz: 66b0db61e130bbc1b9467fa2d77b2fe39e52db07fa3a86ad7ce87af8903f70439d09fef971f8cd17b8b7d161aaf2f669bc1ca0a8c0c2783236c6fbf8a9b094a7
@@ -20,10 +20,11 @@ module AlacrityRails
20
20
  end
21
21
 
22
22
  module Transaction
23
- autoload :Base, 'alacrity-rails/transaction/base'
24
- autoload :ConnectionTest, 'alacrity-rails/transaction/connection_test'
25
- autoload :ServerStartup, 'alacrity-rails/transaction/server_startup'
26
- autoload :WebTransaction, 'alacrity-rails/transaction/web_transaction'
23
+ autoload :Base, 'alacrity-rails/transaction/base'
24
+ autoload :BulkWebTransaction, 'alacrity-rails/transaction/bulk_web_transaction'
25
+ autoload :ConnectionTest, 'alacrity-rails/transaction/connection_test'
26
+ autoload :ServerStartup, 'alacrity-rails/transaction/server_startup'
27
+ autoload :WebTransaction, 'alacrity-rails/transaction/web_transaction'
27
28
  end
28
29
  end
29
30
 
@@ -16,8 +16,7 @@ module AlacrityRails
16
16
  def self.close_transaction!(response)
17
17
  if transaction
18
18
  transaction.status = response.first
19
- this_transaction = transaction
20
- Thread.new { transmit(this_transaction) }
19
+ transmission_queue.push(transaction)
21
20
  end
22
21
  ensure
23
22
  cleanup
@@ -43,6 +42,24 @@ module AlacrityRails
43
42
  end
44
43
  end
45
44
 
45
+ def self.transmission_queue
46
+ @transmission_queue ||= []
47
+ end
48
+
49
+ def self.start_transmission_worker
50
+ Thread.new do
51
+ loop do
52
+ sleep 1
53
+
54
+ if transmission_queue.any?
55
+ transmit(AlacrityRails::Transaction::BulkWebTransaction.new(
56
+ transmission_queue.shift(transmission_queue.length)
57
+ ))
58
+ end
59
+ end
60
+ end
61
+ end
62
+
46
63
  private
47
64
 
48
65
  def self.new_transaction!(env)
@@ -3,6 +3,7 @@ module AlacrityRails
3
3
  initializer 'alacrity' do |config|
4
4
  if Config.enabled?
5
5
  Client.log_server_startup
6
+ Client.start_transmission_worker
6
7
 
7
8
  config.middleware.insert_before 0, AlacrityRails::Middleware
8
9
 
@@ -0,0 +1,17 @@
1
+ module AlacrityRails::Transaction
2
+ class BulkWebTransaction < Base
3
+ attr_accessor :web_transactions
4
+
5
+ def initialize(web_transactions)
6
+ self.web_transactions = web_transactions
7
+ end
8
+
9
+ def as_json(*args)
10
+ web_transactions.as_json
11
+ end
12
+
13
+ def self.endpoint
14
+ @endpoint ||= URI("#{AlacrityRails::Config.collector_host}/v1/web-transactions")
15
+ end
16
+ end
17
+ end
@@ -39,7 +39,8 @@ module AlacrityRails::Transaction
39
39
  format: format,
40
40
  method: method,
41
41
  status: status,
42
- timeline_events: timeline_events
42
+ timeline_events: timeline_events,
43
+ timestamp: Time.now.utc
43
44
  }
44
45
  end
45
46
 
@@ -1,3 +1,3 @@
1
1
  module AlacrityRails
2
- VERSION = '0.3.0'
2
+ VERSION = '0.4.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alacrity-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alacrity, LLC
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-22 00:00:00.000000000 Z
11
+ date: 2017-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -47,6 +47,7 @@ files:
47
47
  - lib/alacrity-rails/railtie.rb
48
48
  - lib/alacrity-rails/server_config.rb
49
49
  - lib/alacrity-rails/transaction/base.rb
50
+ - lib/alacrity-rails/transaction/bulk_web_transaction.rb
50
51
  - lib/alacrity-rails/transaction/connection_test.rb
51
52
  - lib/alacrity-rails/transaction/server_startup.rb
52
53
  - lib/alacrity-rails/transaction/web_transaction.rb