alacrity-rails 0.11.0 → 0.12.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7de4111ca3d48f3ed4cb9e30221c107f226d2bfb
4
- data.tar.gz: 10afa26f0dd1242da44dc4fd1233ecfa061b41f7
3
+ metadata.gz: 4e71baac37d033be722f516ca9e2517f37acb4a1
4
+ data.tar.gz: f56b3bc0f27d22f9790d6fd2effd77bb4ef8174d
5
5
  SHA512:
6
- metadata.gz: 37e057d9025ae6cf31ce3424788c3c5b55b0b540cc38c51246caa6ae6b055a0e5e94b8a4b4369632520b744d75d7977167068e28a59a865f1509719d1ca2a424
7
- data.tar.gz: 29235ae28954ee446ce111a8cde6831a94b62a76583f97ea10fba6738b4f486d667ac9a547fb9e207293c6a63b447fbada98df0665884e82412a0da43bc13a92
6
+ metadata.gz: a94cc4f73f7f24f4a148aedff5494fa993cf30c14e012a0b516b53a5fdad4f7cdfcbe54c502b9b68a5337caf2ddd083c23d3ab01470a02b9f213ebe82c9112f7
7
+ data.tar.gz: 86f3312d6b307c6b7f30262ee32836d3c3026a0cb8145c9af848de9eaa7057a7cd3d383a66cd64d5dd58657f683e6e11667299890be437cd11e476e7d0e37b05
@@ -13,14 +13,16 @@ module AlacrityRails
13
13
  autoload :VERSION, 'alacrity-rails/version'
14
14
 
15
15
  module Probe
16
- autoload :ActionController, 'alacrity-rails/probe/action_controller'
17
- autoload :ActionMailer, 'alacrity-rails/probe/action_mailer'
18
- autoload :ActionView, 'alacrity-rails/probe/action_view'
19
- autoload :ActiveModelSerializers, 'alacrity-rails/probe/active_model_serializers'
20
- autoload :ActiveJob, 'alacrity-rails/probe/active_job'
21
- autoload :ActiveRecord, 'alacrity-rails/probe/active_record'
22
- autoload :Excon, 'alacrity-rails/probe/excon'
23
- autoload :MongoDriver, 'alacrity-rails/probe/mongo_driver'
16
+ autoload :ActionController, 'alacrity-rails/probe/action_controller'
17
+ autoload :ActionMailer, 'alacrity-rails/probe/action_mailer'
18
+ autoload :ActionView, 'alacrity-rails/probe/action_view'
19
+ autoload :ActiveModelSerializers, 'alacrity-rails/probe/active_model_serializers'
20
+ autoload :ActiveJob, 'alacrity-rails/probe/active_job'
21
+ autoload :ActiveRecord, 'alacrity-rails/probe/active_record'
22
+ autoload :Excon, 'alacrity-rails/probe/excon'
23
+ autoload :MongoDriver, 'alacrity-rails/probe/mongo_driver'
24
+ autoload :Sidekiq, 'alacrity-rails/probe/sidekiq'
25
+ autoload :SidekiqServerMiddleware, 'alacrity-rails/probe/sidekiq'
24
26
  end
25
27
 
26
28
  module Transaction
@@ -29,6 +31,7 @@ module AlacrityRails
29
31
  autoload :ConnectionTest, 'alacrity-rails/transaction/connection_test'
30
32
  autoload :Custom, 'alacrity-rails/transaction/custom'
31
33
  autoload :ServerStartup, 'alacrity-rails/transaction/server_startup'
34
+ autoload :Job, 'alacrity-rails/transaction/job'
32
35
  autoload :WebTransaction, 'alacrity-rails/transaction/web_transaction'
33
36
  end
34
37
  end
@@ -39,8 +39,11 @@ module AlacrityRails
39
39
 
40
40
  def self.transmit(transactable)
41
41
  Thread.new do
42
- Net::HTTP.start(*transactable.net_http_start_arguments) do |http|
43
- http.request(transactable.post_request)
42
+ begin
43
+ Net::HTTP.start(*transactable.net_http_start_arguments) do |http|
44
+ http.request(transactable.post_request)
45
+ end
46
+ rescue
44
47
  end
45
48
  end
46
49
  end
@@ -17,4 +17,14 @@ module AlacrityRails::Config
17
17
  def self.transmission_interval
18
18
  @transmission_interval ||= (ENV['ALACRITY_TRANSMISSION_INTERVAL'] || 0.5).to_f
19
19
  end
20
+
21
+ def self.yaml_options
22
+ @yaml_options ||= YAML.load_file(".alacrity.yml")
23
+ rescue
24
+ @yaml_options = {}
25
+ end
26
+
27
+ def self.sidekiq_enabled?
28
+ yaml_options['sidekiq'] != false
29
+ end
20
30
  end
@@ -0,0 +1,31 @@
1
+ module AlacrityRails
2
+ module Probe
3
+ class SidekiqServerMiddleware
4
+ def call(worker_instance, msg, queue)
5
+ AlacrityRails::Instrumentor.instrument(
6
+ type: AlacrityRails::Transaction::Job,
7
+ data: {
8
+ worker_class: msg['class'],
9
+ args: msg['args'],
10
+ error_class: msg['error_class'],
11
+ error_message: msg['error_message']
12
+ }
13
+ ) do
14
+ yield
15
+ end
16
+ end
17
+ end
18
+
19
+ class Sidekiq
20
+ def self.activate
21
+ if defined?(::Sidekiq) && AlacrityRails::Config.sidekiq_enabled?
22
+ ::Sidekiq.configure_server do |config|
23
+ config.server_middleware do |chain|
24
+ chain.add SidekiqServerMiddleware
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -14,7 +14,8 @@ module AlacrityRails
14
14
  Probe::ActiveModelSerializers,
15
15
  Probe::ActiveRecord,
16
16
  Probe::MongoDriver,
17
- Probe::Excon
17
+ Probe::Excon,
18
+ Probe::Sidekiq
18
19
  ].each(&:activate)
19
20
  end
20
21
  end
@@ -0,0 +1,29 @@
1
+ module AlacrityRails::Transaction
2
+ class Job < Base
3
+ attr_accessor :data, :start_time, :end_time
4
+
5
+ def initialize(data={})
6
+ self.data = data
7
+ self.start_time = DateTime.now
8
+ end
9
+
10
+ def finalize(response)
11
+ self.end_time = DateTime.now
12
+ end
13
+
14
+ def as_json(*args)
15
+ {
16
+ environment: AlacrityRails::ServerConfig.environment,
17
+ event_type: 'job',
18
+ started_at: absolute_time(start_time),
19
+ finished_at: absolute_time(end_time),
20
+ timeline_events: prepared_timeline_events,
21
+ data: data
22
+ }
23
+ end
24
+
25
+ def self.endpoint
26
+ @endpoint ||= URI("#{AlacrityRails::Config.collector_host}/v2/events")
27
+ end
28
+ end
29
+ end
@@ -1,3 +1,3 @@
1
1
  module AlacrityRails
2
- VERSION = '0.11.0'
2
+ VERSION = '0.12.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.11.0
4
+ version: 0.12.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: 2018-02-10 00:00:00.000000000 Z
11
+ date: 2018-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -48,11 +48,13 @@ files:
48
48
  - lib/alacrity-rails/probe/active_record.rb
49
49
  - lib/alacrity-rails/probe/excon.rb
50
50
  - lib/alacrity-rails/probe/mongo_driver.rb
51
+ - lib/alacrity-rails/probe/sidekiq.rb
51
52
  - lib/alacrity-rails/railtie.rb
52
53
  - lib/alacrity-rails/server_config.rb
53
54
  - lib/alacrity-rails/transaction/base.rb
54
55
  - lib/alacrity-rails/transaction/connection_test.rb
55
56
  - lib/alacrity-rails/transaction/custom.rb
57
+ - lib/alacrity-rails/transaction/job.rb
56
58
  - lib/alacrity-rails/transaction/server_startup.rb
57
59
  - lib/alacrity-rails/transaction/web_transaction.rb
58
60
  - lib/alacrity-rails/version.rb