logtail-rails 0.2.1 → 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: '0194357c22696c69efc90f63324d9e17b5b92c2a8a8f787a09fc56ef64939726'
4
- data.tar.gz: 1f6023f784446349e83484c4663088b260af2f7eb62b114789380dacd154494d
3
+ metadata.gz: d7123b2162f46a2a107ead8671135561f7a5d53f49a66196f4684776ad14a7c5
4
+ data.tar.gz: 749ff8b0d6367026632cb6beee6a5742168aeb0b038d87b786ae683472c83409
5
5
  SHA512:
6
- metadata.gz: 01fac73b610686a7ea103847e501a0ef69e14a08e23757e2dfe13e4cb7fe8b23c5d3bf0022aba98831ed42e95bfedc310b2458fb0d4b7510ca65f1d8d984de9d
7
- data.tar.gz: bcc0d8246d57ab258c52964023a5239adf6794444749fa8a210ebbe29a63afcbb968e6b5ee6674c0308f39a4cbe5309d966c79529ad7693158905f1e3230fb91
6
+ metadata.gz: 248ef31c5d69238893ce2b0e8c0d1bc5de1a9edd94df498da0c2ef61dbe608ff0cfb2761c390eb18e70b24481bfc8455750d99340d539aed84c21feebf53d3b9
7
+ data.tar.gz: fe08fa5eba61b5908202ea011153721b02c703d239cc78b7edc0d76484debb5e80faddeaa4d2bdf41fde63190dd4fec068e705262326e5829d2de683256f10ab
@@ -5,6 +5,7 @@ on:
5
5
  pull_request:
6
6
  schedule:
7
7
  - cron: '20 5 * * 1'
8
+ workflow_dispatch:
8
9
 
9
10
  jobs:
10
11
  test:
@@ -15,37 +16,69 @@ jobs:
15
16
 
16
17
  matrix:
17
18
  ruby-version:
18
- - 3.0.0
19
+ - 3.2.2
20
+ - 3.1.4
21
+ - 3.0.6
19
22
  - 2.7.2
20
23
  - 2.6.6
21
24
  - 2.5.8
25
+ - jruby-9.4.3.0
22
26
  - jruby-9.2.14.0
23
- - truffleruby-21.0.0
27
+ - truffleruby-23.0.0
28
+ - truffleruby-22.1.0
24
29
  gemfile:
25
- - rails-edge
30
+ - rails-7.0
26
31
  - rails-6.1
27
32
  - rails-6.0
28
33
  - rails-5.2
29
34
  - rails-5.1
30
35
  - rails-5.0
31
36
  exclude:
32
- - gemfile: rails-edge
37
+ - gemfile: rails-7.0
33
38
  ruby-version: 2.6.6
34
- - gemfile: rails-edge
39
+ - gemfile: rails-7.0
35
40
  ruby-version: 2.5.8
36
- - gemfile: rails-edge
41
+ - gemfile: rails-7.0
37
42
  ruby-version: jruby-9.2.14.0
38
- - gemfile: rails-edge
39
- ruby-version: truffleruby-21.0.0
40
43
 
41
44
  - gemfile: rails-5.2
42
- ruby-version: 3.0.0
45
+ ruby-version: 3.2.2
46
+ - gemfile: rails-5.2
47
+ ruby-version: 3.1.4
48
+ - gemfile: rails-5.2
49
+ ruby-version: 3.0.6
50
+ - gemfile: rails-5.2
51
+ ruby-version: jruby-9.4.3.0
52
+ - gemfile: rails-5.2
53
+ ruby-version: truffleruby-22.1.0
54
+ - gemfile: rails-5.2
55
+ ruby-version: truffleruby-23.0.0
43
56
 
44
57
  - gemfile: rails-5.1
45
- ruby-version: 3.0.0
58
+ ruby-version: 3.2.2
59
+ - gemfile: rails-5.1
60
+ ruby-version: 3.1.4
61
+ - gemfile: rails-5.1
62
+ ruby-version: 3.0.6
63
+ - gemfile: rails-5.1
64
+ ruby-version: jruby-9.4.3.0
65
+ - gemfile: rails-5.1
66
+ ruby-version: truffleruby-23.0.0
67
+ - gemfile: rails-5.1
68
+ ruby-version: truffleruby-22.1.0
46
69
 
47
70
  - gemfile: rails-5.0
48
- ruby-version: 3.0.0
71
+ ruby-version: 3.2.2
72
+ - gemfile: rails-5.0
73
+ ruby-version: 3.1.4
74
+ - gemfile: rails-5.0
75
+ ruby-version: 3.0.6
76
+ - gemfile: rails-5.0
77
+ ruby-version: jruby-9.4.3.0
78
+ - gemfile: rails-5.0
79
+ ruby-version: truffleruby-23.0.0
80
+ - gemfile: rails-5.0
81
+ ruby-version: truffleruby-22.1.0
49
82
 
50
83
  env:
51
84
  BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![Logtail ruby dashboard](https://user-images.githubusercontent.com/19272921/154085622-59997d5a-3f91-4bc9-a815-3b8ead16d28d.jpeg)](https://betterstack.com/logtail)
4
4
 
5
5
  [![ISC License](https://img.shields.io/badge/license-ISC-ff69b4.svg)](LICENSE.md)
6
- [![Gem Version](https://badge.fury.io/rb/logtail-ruby.svg)](https://badge.fury.io/rb/logtail-ruby)
6
+ [![Gem Version](https://badge.fury.io/rb/logtail-rails.svg)](https://badge.fury.io/rb/logtail-rails)
7
7
  [![Build Status](https://github.com/logtail/logtail-ruby-rails/workflows/build/badge.svg)](https://github.com/logtail/logtail-ruby-rails/actions?query=workflow%3Abuild)
8
8
 
9
9
  Collect logs directly from your Ruby on Rails projects. To start logging Ruby projects explore the [Logtail Ruby library](https://github.com/logtail/logtail-ruby).
@@ -71,4 +71,4 @@ group :test do
71
71
  gem "webdrivers"
72
72
  end
73
73
 
74
- gem "logtail-rails", "~> 0.1.7"
74
+ gem "logtail-rails", "~> 0.2.0"
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rails', '~> 7.0.0'
4
+
5
+ gem 'logtail'
6
+ gem 'logtail-rack'
7
+
8
+ if RUBY_PLATFORM == "java"
9
+ gem 'mime-types', '2.6.2'
10
+ end
11
+
12
+ gemspec :path => '../'
@@ -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
@@ -6,10 +6,6 @@ module Logtail
6
6
  # Installs Logtail into your Rails app automatically.
7
7
  class Railtie < ::Rails::Railtie
8
8
  railtie_name 'logtail-rails'
9
- rake_tasks do
10
- path = File.expand_path(__dir__)
11
- load "#{path}/tasks/logtail.rake"
12
- end
13
9
 
14
10
  config.logtail = Config.instance
15
11
 
@@ -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.1"
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.1
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
@@ -305,7 +305,7 @@ files:
305
305
  - gemfiles/rails-5.2.gemfile
306
306
  - gemfiles/rails-6.0.gemfile
307
307
  - gemfiles/rails-6.1.gemfile
308
- - gemfiles/rails-edge.gemfile
308
+ - gemfiles/rails-7.0.gemfile
309
309
  - lib/logtail-rails.rb
310
310
  - lib/logtail-rails/action_controller.rb
311
311
  - lib/logtail-rails/action_controller/log_subscriber.rb
@@ -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
@@ -1,10 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'rack', git: 'https://github.com/rack/rack', branch: 'master'
4
- gem 'arel', git: 'https://github.com/rails/arel', branch: 'master'
5
- gem 'rails', git: 'https://github.com/rails/rails', branch: 'main'
6
-
7
- gem 'logtail'
8
- gem 'logtail-rack'
9
-
10
- gemspec :path => '../'