logtail-rails 0.2.2 → 0.2.3

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: ed20f6d4677ee4cce10f91ce1acde469e3f201c12092aaccec4d172137089119
4
- data.tar.gz: 3c8e38d62f4a9b58c37ec1aae0f1cdddbbddec16cd8caf3d790cba641fd8effa
3
+ metadata.gz: d7123b2162f46a2a107ead8671135561f7a5d53f49a66196f4684776ad14a7c5
4
+ data.tar.gz: 749ff8b0d6367026632cb6beee6a5742168aeb0b038d87b786ae683472c83409
5
5
  SHA512:
6
- metadata.gz: f0394b6d9ec9e4282082ed6abde5ae81a6ec0768faa738c5f6c753535bfb7ddf4e3913839393ef59ddd968d99816a53abf7ad7f6f173ced965c4abb28c20f695
7
- data.tar.gz: 1a77af8d51a25997f1af62d066868fd73bda872b2932c499d688c04829d2a5abad15b3398435db95164e81b8948040725186bb5f36135756cdcf1cc544de9050
6
+ metadata.gz: 248ef31c5d69238893ce2b0e8c0d1bc5de1a9edd94df498da0c2ef61dbe608ff0cfb2761c390eb18e70b24481bfc8455750d99340d539aed84c21feebf53d3b9
7
+ data.tar.gz: fe08fa5eba61b5908202ea011153721b02c703d239cc78b7edc0d76484debb5e80faddeaa4d2bdf41fde63190dd4fec068e705262326e5829d2de683256f10ab
@@ -32,7 +32,16 @@ module Logtail
32
32
  io_device = STDOUT
33
33
  end
34
34
 
35
- self.create_logger(io_device)
35
+ logger = self.create_logger(io_device)
36
+
37
+ if defined?(Sidekiq)
38
+ Sidekiq.configure_server do |config|
39
+ logger = self.create_logger(io_device, config.logger) if config.logger.class == Sidekiq::Logger
40
+ config.logger = logger
41
+ end
42
+ end
43
+
44
+ logger
36
45
  end
37
46
  end
38
47
  end
@@ -0,0 +1,38 @@
1
+ # integrates Logtail::CurrentContext with Sidekiq::Context if installed
2
+
3
+ begin
4
+ require 'sidekiq/job_logger'
5
+
6
+ class Sidekiq::JobLogger
7
+ def call(_item, _queue)
8
+ start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
9
+
10
+ Logtail::CurrentContext.with({ sidekiq: Sidekiq::Context.current.to_h }) do
11
+ @logger.info("start")
12
+
13
+ yield
14
+ end
15
+
16
+ Sidekiq::Context.add(:elapsed, elapsed(start))
17
+ Logtail::CurrentContext.with({ sidekiq: Sidekiq::Context.current.to_h }) do
18
+ @logger.info('done')
19
+ end
20
+ rescue Exception
21
+ Sidekiq::Context.add(:elapsed, elapsed(start))
22
+ Logtail::CurrentContext.with({ sidekiq: Sidekiq::Context.current.to_h }) do
23
+ @logger.info('fail')
24
+ end
25
+
26
+ raise
27
+ end
28
+
29
+ private
30
+
31
+ def elapsed(start)
32
+ (Process.clock_gettime(::Process::CLOCK_MONOTONIC) - start).round(3)
33
+ end
34
+ end
35
+
36
+ rescue LoadError
37
+ # sidekiq is not present
38
+ end
@@ -1,7 +1,7 @@
1
1
  module Logtail
2
2
  module Integrations
3
3
  module Rails
4
- VERSION = "0.2.2"
4
+ VERSION = "0.2.3"
5
5
  end
6
6
  end
7
7
  end
data/lib/logtail-rails.rb CHANGED
@@ -21,6 +21,7 @@ require "logtail-rails/action_controller"
21
21
  require "logtail-rails/action_dispatch"
22
22
  require "logtail-rails/action_view"
23
23
  require "logtail-rails/active_record"
24
+ require "logtail-rails/sidekiq"
24
25
 
25
26
  require "logtail-rails/log_entry"
26
27
  require "logtail-rails/logger"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logtail-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Better Stack
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-12 00:00:00.000000000 Z
11
+ date: 2023-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logtail
@@ -334,6 +334,7 @@ files:
334
334
  - lib/logtail-rails/rack_logger.rb
335
335
  - lib/logtail-rails/railtie.rb
336
336
  - lib/logtail-rails/session_context.rb
337
+ - lib/logtail-rails/sidekiq.rb
337
338
  - lib/logtail-rails/version.rb
338
339
  - logtail-rails.gemspec
339
340
  homepage: https://github.com/logtail/logtail-ruby-rails