logtail 0.1.10 → 0.1.12

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: b7ad98029314cd53d6824adf57c97eeb24b44aa4bc432ff1622e0dd9b2e07b9f
4
- data.tar.gz: 6143a7a066580bc22e4960686919cc0a58ec934a1c3b8bcf193139944723ad55
3
+ metadata.gz: 0a6b0738bfe520cbd3e443365dff1cb77b6e2ae2849799badf8d47f785df52d4
4
+ data.tar.gz: ba02074bd5ee3e2ced09e286712c2af97b6b78175e06d372c50e4bc1a158d114
5
5
  SHA512:
6
- metadata.gz: 19b97528678d45d109a50289666003fda062598f17606cc1093fc20b880e7567c8de91631ae4b12850b430999293e45d1d129783066af892e6699024ddc24090
7
- data.tar.gz: d2dcc91d791fe9d325e1abae949f0b5430114790fea7ee5e602b0ee4241f66fc5a8b4904baaa26b3abb4c1bb04e435749e03e324f0b6a23496abbc01d87d0d8a
6
+ metadata.gz: 0f1f0865055d6f29eff1d251e8f4b13609ce3306ae2b2e72bd38afb44294c28d562ec7ee3aac74a4fd9ad386c302743d5a9c929741c511401afd50f8e59638ff
7
+ data.tar.gz: c95ee4374d040f864130b6f5ed0fc4f732e94e6d9b17b64c6579cea8fad59f1710b422a878b6bd798cf09b9d773ef0f3a86e609ac597c87d3c3b3c7ae77e2f1f
@@ -1,26 +1,32 @@
1
1
  name: build
2
2
 
3
- on: [push, pull_request]
3
+ on:
4
+ push:
5
+ schedule:
6
+ - cron: '20 5 * * 1'
7
+ workflow_dispatch:
4
8
 
5
9
  jobs:
6
10
  test:
7
-
8
11
  runs-on: ubuntu-20.04
9
12
 
10
13
  strategy:
14
+ fail-fast: false
15
+
11
16
  matrix:
12
17
  ruby-version:
13
- - 3.2.1
14
- - 3.1.2
15
- - 3.0.0
16
- - 2.7.2
17
- - 2.6.6
18
- - 2.5.8
19
- - 2.4.10
20
- - 2.3.8
21
- - 2.2.10
18
+ - 3.2
19
+ - 3.1
20
+ - 3.0
21
+ - 2.7
22
+ - 2.6
23
+ - 2.5
24
+ - 2.4
25
+ - 2.3
26
+ - jruby-9.4.3.0
22
27
  - jruby-9.2.14.0
23
- - truffleruby-21.0.0
28
+ - truffleruby-23.0.0
29
+ - truffleruby-22.1.0
24
30
 
25
31
  steps:
26
32
  - uses: actions/checkout@v2
@@ -1,2 +1,2 @@
1
1
  source 'https://rubygems.org'
2
- gem "logtail"
2
+ gem "logtail", "~> 0.1.12"
@@ -1,9 +1,9 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- logtail (0.1.9)
4
+ logtail (0.1.12)
5
5
  msgpack (~> 1.0)
6
- msgpack (1.7.1)
6
+ msgpack (1.7.2)
7
7
 
8
8
  PLATFORMS
9
9
  ruby
@@ -15,6 +15,9 @@ end
15
15
  http_device = Logtail::LogDevices::HTTP.new(ARGV[0])
16
16
  logger = Logtail::Logger.new(http_device)
17
17
 
18
+ # Filter logs that shouldn't be sent to Better Stack, see {Logtail::LogEntry} for available attributes
19
+ Logtail.config.filter_sent_to_better_stack { |log_entry| log_entry.message.include?("DO_NOT_SEND") }
20
+
18
21
  # LOGGING
19
22
 
20
23
  # Send debug logs messages using the debug() method
@@ -33,6 +36,9 @@ logger.warn(
33
36
  }
34
37
  )
35
38
 
39
+ # Some messages can be filtered, see {Logtail::Config#filter_sent_to_better_stack} call above
40
+ logger.info("This message will not be sent to Better Stack because it contains 'DO_NOT_SEND'")
41
+
36
42
  # Send error messages using the error() method
37
43
  logger.error("Oops! An error occurred!")
38
44
 
@@ -32,6 +32,28 @@ module Logtail
32
32
 
33
33
  attr_writer :http_body_limit
34
34
 
35
+ # Whether a particular {Logtail::LogEntry} should be sent to Better Stack
36
+ def send_to_better_stack?(log_entry)
37
+ !@better_stack_filters&.any? { |blocker| blocker.call(log_entry) }
38
+ rescue => e
39
+ debug { "Could not determine whether to send LogEntry to Better Stack (assumed yes): #{e}" }
40
+ true
41
+ end
42
+
43
+ # This allows filtering logs that are sent to Better Stack. Can be called multiple times, all filters will
44
+ # be applied. If the passed block RETURNS TRUE for a particular LogEntry, it WILL NOT BE SENT to Better Stack.
45
+ #
46
+ # See {Logtail::LogEntry} for available attributes of the block parameter.
47
+ #
48
+ # @example Rails
49
+ # config.logtail.filter_sent_to_better_stack { |log_entry| log_entry.context_snapshot[:http][:path].start_with?('_') }
50
+ # @example Everything else
51
+ # Logtail.config.filter_sent_to_better_stack { |log_entry| log_entry.message.include?('IGNORE') }
52
+ def filter_sent_to_better_stack(&block)
53
+ @better_stack_filters ||= []
54
+ @better_stack_filters << -> (log_entry) { yield(log_entry) }
55
+ end
56
+
35
57
  # Convenience method for logging debug statements to the debug logger
36
58
  # set in this class.
37
59
  # @private
@@ -89,6 +89,8 @@ module Logtail
89
89
  # size is constricted by the Logtail API. The actual application limit is a multiple
90
90
  # of this. Hence the `@request_queue`.
91
91
  def write(msg)
92
+ return unless Logtail.config.send_to_better_stack?(msg)
93
+
92
94
  @msg_queue.enq(msg)
93
95
 
94
96
  # Lazily start flush threads to ensure threads are alive after forking processes.
@@ -57,11 +57,11 @@ module Logtail
57
57
 
58
58
  # Because of all the crazy ways Rails has attempted tags, we need this crazy method.
59
59
  def extract_active_support_tagged_logging_tags
60
- if defined?(ActiveSupport::IsolatedExecutionState)
61
- @current_tags ||= ActiveSupport::IsolatedExecutionState[tagged_logging_object_key_name]
60
+ if defined?(current_tags)
61
+ return current_tags
62
62
  end
63
63
 
64
- @current_tags ||
64
+ defined?(ActiveSupport::IsolatedExecutionState) && ActiveSupport::IsolatedExecutionState[tagged_logging_object_key_name] ||
65
65
  Thread.current[:activesupport_tagged_logging_tags] ||
66
66
  Thread.current[tagged_logging_object_key_name] ||
67
67
  EMPTY_ARRAY
@@ -1,3 +1,3 @@
1
1
  module Logtail
2
- VERSION = "0.1.10"
2
+ VERSION = "0.1.12"
3
3
  end
data/logtail.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.metadata["homepage_uri"] = spec.homepage
19
19
  spec.metadata["source_code_uri"] = spec.homepage
20
20
 
21
- spec.required_ruby_version = Gem::Requirement.new(">= 2.2.0")
21
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3")
22
22
 
23
23
  spec.files = `git ls-files`.split("\n")
24
24
  spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logtail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Better Stack
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-12 00:00:00.000000000 Z
11
+ date: 2023-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
@@ -216,7 +216,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
216
216
  requirements:
217
217
  - - ">="
218
218
  - !ruby/object:Gem::Version
219
- version: 2.2.0
219
+ version: '2.3'
220
220
  required_rubygems_version: !ruby/object:Gem::Requirement
221
221
  requirements:
222
222
  - - ">="