logtail 0.1.12 → 0.1.14

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
  SHA256:
3
- metadata.gz: 0a6b0738bfe520cbd3e443365dff1cb77b6e2ae2849799badf8d47f785df52d4
4
- data.tar.gz: ba02074bd5ee3e2ced09e286712c2af97b6b78175e06d372c50e4bc1a158d114
3
+ metadata.gz: 6cb9ce58d42f8eaae77256309904b1e1f1d34974ffb2baf9d08b3ae8f9bc9add
4
+ data.tar.gz: cee900d3422c3d51c4b5915b54281c7b4522e1ae49c14e72820539080b013870
5
5
  SHA512:
6
- metadata.gz: 0f1f0865055d6f29eff1d251e8f4b13609ce3306ae2b2e72bd38afb44294c28d562ec7ee3aac74a4fd9ad386c302743d5a9c929741c511401afd50f8e59638ff
7
- data.tar.gz: c95ee4374d040f864130b6f5ed0fc4f732e94e6d9b17b64c6579cea8fad59f1710b422a878b6bd798cf09b9d773ef0f3a86e609ac597c87d3c3b3c7ae77e2f1f
6
+ metadata.gz: 8d7fa9ab0b8ed9b7cb23d5a940485bc523037c31134f68a6a0e9adf91190ef22284008e650b95406d1bb76834744d889569dab81943b3af0ebc69fdda73519a7
7
+ data.tar.gz: 20d6428149c7e2f0687cc0c0af867f16ff1f495c7622b49afef8e661f83900c31c46a00b322e9f15510202f877d70d17196c0163efbfd460b03a2fa8a881e4f5
data/README.md CHANGED
@@ -1,69 +1,22 @@
1
- # Logtail - Ruby Logging Made Easy
2
-
3
- [![Logtail ruby dashboard](https://user-images.githubusercontent.com/19272921/154085622-59997d5a-3f91-4bc9-a815-3b8ead16d28d.jpeg)](https://betterstack.com/logtail)
1
+ # [Better Stack](https://betterstack.com/logs) Ruby client
4
2
 
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)
7
- [![Build Status](https://github.com/logtail/logtail-ruby/workflows/build/badge.svg)](https://github.com/logtail/logtail-ruby/actions?query=workflow%3Abuild)
8
-
9
- Collect logs directly from your Ruby projects. To start logging Ruby on Rails projects explore the [Logtail Rails library](https://github.com/logtail/logtail-ruby-rails).
10
-
11
- [Logtail](https://betterstack.com/logtail) is a hosted service that centralizes all of your logs into one place. Allowing for analysis, correlation and filtering with SQL. Actionable Grafana dashboards and collaboration come built-in. Logtail works with [any language or platform and any data source](https://docs.logtail.com/).
12
-
13
- ### Features
14
- - Simple integration.
15
- - Support for structured logging and events.
16
- - Automatically captures useful context.
17
- - Performant, light weight, with a thoughtful design.
18
-
19
- ### Supported language versions
20
- - Ruby 2.7.0 or newer
21
-
22
- # Installation
23
- Install the Logtail Ruby client library, run the following command:
24
-
25
- ```bash
26
- bundle add logtail
27
- ```
28
-
29
- This will install Logtail gem and create `Gemfile` and `Gemfile.lock` that are used to track the code dependencies.
3
+ 📣 Logtail is now part of Better Stack. [Learn more ⇗](https://betterstack.com/press/introducing-better-stack/)
30
4
 
31
- Alternatively, add `gem "logtail"` to your `Gemfile` manually and then run `bundle install`.
5
+ [![Better Stack dashboard](https://github.com/logtail/logtail-python/assets/10132717/e2a1196b-7924-4abc-9b85-055e17b5d499)](https://betterstack.com/logs)
32
6
 
33
- ---
34
-
35
- # Example project
36
-
37
- To help you get started with using Logtail in your Ruby projects, we have prepared a simple program that showcases the usage of Logtail logger.
38
-
39
- ## Download and install the example project
40
-
41
- You can download the [example project](https://github.com/logtail/logtail-ruby/tree/main/example-project) from GitHub directly or you can clone it to a select directory. Make sure you are in the projects directory and run the following command:
42
-
43
- ```bash
44
- bundle install
45
- ```
46
-
47
- This will install all dependencies listed in the `Gemfile.lock` file.
7
+ [![ISC License](https://img.shields.io/badge/license-ISC-ff69b4.svg)](LICENSE.md)
8
+ [![Gem Version](https://badge.fury.io/rb/logtail.svg)](https://badge.fury.io/rb/logtail)
9
+ [![Build Status](https://github.com/logtail/logtail-ruby/workflows/build/badge.svg)](https://github.com/logtail/logtail-ruby/actions?query=workflow%3Abuild)
48
10
 
49
- ## Run the example project
50
-
51
- To run the example application, run the following command:
11
+ Experience SQL-compatible structured log management based on ClickHouse. [Learn more ⇗](https://betterstack.com/logs)
52
12
 
53
- ```bash
54
- bundle exec ruby main.rb <source-token>
55
- ```
13
+ ## Documentation
56
14
 
57
- *Don't forget to replace `<source-token>` with your actual source token which you can find by going to logtail.com -> sources -> edit.*
15
+ [Getting started ⇗](https://betterstack.com/docs/logs/ruby-and-rails/#logging-from-ruby)
58
16
 
59
- This will create a total of 5 different logs, each corresponding to a different log level. You can review these logs in Logtail.
17
+ ## Need help?
18
+ Please let us know at [hello@betterstack.com](mailto:hello@betterstack.com). We're happy to help!
60
19
 
61
- ## Explore how example project works
62
-
63
- Learn how to setup Ruby logging by exploring the workings of the [example project](https://github.com/logtail/logtail-ruby/tree/main/example-project) in detail.
64
-
65
20
  ---
66
-
67
- ## Get in touch
68
21
 
69
- Have any questions? Please explore the Logtail [documentation](https://docs.logtail.com/) or contact our [support](https://betterstack.com/help).
22
+ [ISC license](https://github.com/logtail/logtail-ruby/blob/main/LICENSE.md), [example project](https://github.com/logtail/logtail-ruby/tree/main/example-project)
data/Rakefile CHANGED
@@ -15,7 +15,7 @@ def puts_with_level(message, level = :info)
15
15
  end
16
16
 
17
17
  task :test_the_pipes, [:source_token] do |t, args|
18
- support_email = "support@logtail.com"
18
+ support_email = "hello@betterstack.com"
19
19
  # Do not modify below this line. It's important to keep the `Logtail::Logger`
20
20
  # because it provides an API for logging structured data and capturing context.
21
21
  header = <<~HEREDOC
@@ -31,7 +31,7 @@ task :test_the_pipes, [:source_token] do |t, args|
31
31
  if response.is_a?(Exception)
32
32
  message = <<~HEREDOC
33
33
  Unable to deliver logs.
34
- Here's what we received from the Logtail API:
34
+ Here's what we received from the Better Stack Telemetry API:
35
35
  #{response.inspect}
36
36
  If you continue to have trouble please contact support:
37
37
  #{support_email}
@@ -39,13 +39,13 @@ task :test_the_pipes, [:source_token] do |t, args|
39
39
  puts_with_level(message, :error)
40
40
  elsif response.is_a?(Net::HTTPResponse)
41
41
  if response.code.start_with? '2'
42
- puts_with_level("Logs successfully sent! View them at https://logtail.com",
42
+ puts_with_level("Logs successfully sent! View them at https://telemetry.betterstack.com",
43
43
  :success)
44
44
  else
45
45
  message =
46
46
  <<~HEREDOC
47
47
  Unable to deliver logs.
48
- We received a #{response.code} response from the Logtail API:
48
+ We received a #{response.code} response from the Better Stack Telemetry API:
49
49
  #{response.body.inspect}
50
50
  If you continue to have trouble please contact support:
51
51
  #{support_email}
@@ -1,2 +1,2 @@
1
1
  source 'https://rubygems.org'
2
- gem "logtail", "~> 0.1.12"
2
+ gem "logtail", "~> 0.1.14"
@@ -1,7 +1,7 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- logtail (0.1.12)
4
+ logtail (0.1.14)
5
5
  msgpack (~> 1.0)
6
6
  msgpack (1.7.2)
7
7
 
@@ -9,7 +9,7 @@ PLATFORMS
9
9
  ruby
10
10
 
11
11
  DEPENDENCIES
12
- logtail
12
+ logtail (~> 0.1.14)
13
13
 
14
14
  BUNDLED WITH
15
15
  2.1.4
@@ -15,13 +15,13 @@ This will install all dependencies listed in the `Gemfile.lock` file.
15
15
  Alternatively, add `gem "logtail"` to your `Gemfile` manually and then run `bundle install`.
16
16
 
17
17
  ## Run the example project
18
-
19
- Replace `<source-token>` with your actual source token in the `main.rb` file. You can find your source token by going to _logtail.com -> sources -> edit_.
20
-
18
+
19
+ _Don't forget to replace `<source_token>` and `<ingesting_host>` with your actual source token and ingesting host which you can find by going to **[Sources](https://telemetry.betterstack.com/team/0/sources) -> Configure** in Better Stack._
20
+
21
21
  To run the example application, run the following command adding your source token:
22
22
 
23
23
  ```bash
24
- bundle exec ruby main.rb <source-token>
24
+ bundle exec ruby main.rb <source_token> <ingesting_host>
25
25
  ```
26
26
 
27
27
  This will create a total of 5 different logs, each corresponding to a different log level. You can review these logs in Logtail.
@@ -7,12 +7,12 @@
7
7
  require "logtail"
8
8
 
9
9
  # Check for program arguments
10
- if ARGV.length != 1
11
- puts "Program needs source token to run. Run the program as followed\nbundle exec ruby main.rb <source-token>"
10
+ if ARGV.length != 2
11
+ puts "Program needs source token and ingesting host to run. Run the program as followed\nbundle exec ruby main.rb <source_token> <ingesting_host>"
12
12
  exit
13
13
  end
14
14
  # Create logger
15
- http_device = Logtail::LogDevices::HTTP.new(ARGV[0])
15
+ http_device = Logtail::LogDevices::HTTP.new(ARGV[0], ingesting_host: ARGV[1])
16
16
  logger = Logtail::Logger.new(http_device)
17
17
 
18
18
  # Filter logs that shouldn't be sent to Better Stack, see {Logtail::LogEntry} for available attributes
@@ -21,10 +21,10 @@ Logtail.config.filter_sent_to_better_stack { |log_entry| log_entry.message.inclu
21
21
  # LOGGING
22
22
 
23
23
  # Send debug logs messages using the debug() method
24
- logger.debug("Logtail is ready!")
24
+ logger.debug("Better Stack is ready!")
25
25
 
26
26
  # Send informative messages about interesting events using the info() method
27
- logger.info("I am using Logtail!")
27
+ logger.info("I am using Better Stack!")
28
28
 
29
29
  # Send messages about worrying events using the warn() method
30
30
  # You can also log additional structured data
@@ -46,7 +46,7 @@ module Logtail
46
46
  # See {Logtail::LogEntry} for available attributes of the block parameter.
47
47
  #
48
48
  # @example Rails
49
- # config.logtail.filter_sent_to_better_stack { |log_entry| log_entry.context_snapshot[:http][:path].start_with?('_') }
49
+ # config.logtail.filter_sent_to_better_stack { |log_entry| log_entry.context_snapshot[:http][:path].start_with?('/_') }
50
50
  # @example Everything else
51
51
  # Logtail.config.filter_sent_to_better_stack { |log_entry| log_entry.message.include?('IGNORE') }
52
52
  def filter_sent_to_better_stack(&block)
@@ -17,13 +17,11 @@ module Logtail
17
17
  #
18
18
  # See {#initialize} for options and more details.
19
19
  class HTTP
20
- LOGTAIL_STAGING_HOST = "in.logtail.dev".freeze
21
- LOGTAIL_PRODUCTION_HOST = "in.logtail.com".freeze
22
- LOGTAIL_HOST = ENV['LOGTAIL_STAGING'] ? LOGTAIL_STAGING_HOST : LOGTAIL_PRODUCTION_HOST
23
- LOGTAIL_PORT = 443
24
- LOGTAIL_SCHEME = "https".freeze
20
+ DEFAULT_INGESTING_HOST = "in.logs.betterstack.com".freeze
21
+ DEFAULT_INGESTING_PORT = 443
22
+ DEFAULT_INGESTING_SCHEME = "https".freeze
25
23
  CONTENT_TYPE = "application/msgpack".freeze
26
- USER_AGENT = "Logtail Ruby/#{Logtail::VERSION} (HTTP)".freeze
24
+ USER_AGENT = "Better Stack Telemetry for Ruby/#{Logtail::VERSION} (HTTP)".freeze
27
25
 
28
26
  # Instantiates a new HTTP log device that can be passed to {Logtail::Logger#initialize}.
29
27
  #
@@ -36,15 +34,15 @@ module Logtail
36
34
  # you can drop the log messages instead by passing a {DroppingSizedQueue} via the
37
35
  # `:request_queue` option.
38
36
  #
39
- # @param source_token [String] The API key provided to you after you add your application to
40
- # [Logtail](https://logtail.com).
37
+ # @param source_token [String] The API key provided to you after you add your source to
38
+ # [Better Stack](https://telemetry.betterstack.com).
41
39
  # @param [Hash] options the options to create a HTTP log device with.
42
40
  # @option attributes [Symbol] :batch_size (1000) Determines the maximum of log lines in
43
41
  # each HTTP payload. If the queue exceeds this limit an HTTP request will be issued. Bigger
44
42
  # payloads mean higher throughput, but also use more memory. Logtail will not accept
45
43
  # payloads larger than 1mb.
46
44
  # @option attributes [Symbol] :flush_continuously (true) This should only be disabled under
47
- # special circumstsances (like test suites). Setting this to `false` disables the
45
+ # special circumstances (like test suites). Setting this to `false` disables the
48
46
  # continuous flushing of log message. As a result, flushing must be handled externally
49
47
  # via the #flush method.
50
48
  # @option attributes [Symbol] :flush_interval (1) How often the client should
@@ -55,25 +53,30 @@ module Logtail
55
53
  # single persistent connection. After this number is met, the connection will be closed
56
54
  # and a new one will be opened.
57
55
  # @option attributes [Symbol] :request_queue (FlushableDroppingSizedQueue.new(25)) The request
58
- # queue object that queues Net::HTTP requests for delivery. By deafult this is a
56
+ # queue object that queues Net::HTTP requests for delivery. By default this is a
59
57
  # `FlushableDroppingSizedQueue` of size `25`. Meaning once the queue fills up to 25
60
58
  # requests new requests will be dropped. If you'd prefer to apply back pressure,
61
59
  # ensuring you do not lose log data, pass a standard {SizedQueue}. See examples for
62
60
  # an example.
63
- # @option attributes [Symbol] :logtail_host The Logtail host to delivery the log lines to.
64
- # The default is set via {LOGTAIL_HOST}.
61
+ # @option attributes [Symbol] :ingesting_host The Better Stack Telemetry ingesting host to delivery the log lines to.
62
+ # The default is set via {INGESTING_HOST}.
65
63
  #
66
64
  # @example Basic usage
67
- # Logtail::Logger.new(Logtail::LogDevices::HTTP.new("my_logtail_source_token"))
65
+ # Logtail::Logger.new(Logtail::LogDevices::HTTP.new("<source_token>", ingesting_host: "<ingesting_host>"))
68
66
  #
69
67
  # @example Apply back pressure instead of dropping messages
70
- # http_log_device = Logtail::LogDevices::HTTP.new("my_logtail_source_token", request_queue: SizedQueue.new(25))
68
+ # http_log_device = Logtail::LogDevices::HTTP.new("<source_token>", ingesting_host: "<ingesting_host>", request_queue: SizedQueue.new(25))
71
69
  # Logtail::Logger.new(http_log_device)
72
70
  def initialize(source_token, options = {})
71
+ # Handle backward-compatibility of argument names
72
+ options[:ingesting_host] ||= options[:ingesting_host] if options[:ingesting_host].present?
73
+ options[:ingesting_port] ||= options[:logtail_port] if options[:logtail_port].present?
74
+ options[:ingesting_scheme] ||= options[:logtail_scheme] if options[:logtail_scheme].present?
75
+
73
76
  @source_token = source_token || raise(ArgumentError.new("The source_token parameter cannot be blank"))
74
- @logtail_host = options[:logtail_host] || ENV['LOGTAIL_HOST'] || LOGTAIL_HOST
75
- @logtail_port = options[:logtail_port] || ENV['LOGTAIL_PORT'] || LOGTAIL_PORT
76
- @logtail_scheme = options[:logtail_scheme] || ENV['LOGTAIL_SCHEME'] || LOGTAIL_SCHEME
77
+ @ingesting_host = options[:ingesting_host] || ENV['INGESTING_HOST'] || ENV['LOGTAIL_HOST'] || DEFAULT_INGESTING_HOST
78
+ @ingesting_port = options[:ingesting_port] || ENV['INGESTING_PORT'] || ENV['LOGTAIL_PORT'] || DEFAULT_INGESTING_PORT
79
+ @ingesting_scheme = options[:ingesting_scheme] || ENV['INGESTING_SCHEME'] || ENV['LOGTAIL_SCHEME'] || DEFAULT_INGESTING_SCHEME
77
80
  @batch_size = options[:batch_size] || 1_000
78
81
  @flush_continuously = options[:flush_continuously] != false
79
82
  @flush_interval = options[:flush_interval] || 2 # 2 seconds
@@ -153,7 +156,7 @@ module Logtail
153
156
  if @last_resp.nil?
154
157
  print "."
155
158
  elsif @last_resp.code == "202"
156
- puts "Log delivery successful! View your logs at https://logtail.com"
159
+ puts "Log delivery successful! View your logs at https://telemetry.betterstack.com"
157
160
  else
158
161
  raise <<-MESSAGE
159
162
 
@@ -282,9 +285,9 @@ MESSAGE
282
285
 
283
286
  # Builds an `Net::HTTP` object to deliver requests over.
284
287
  def build_http
285
- http = Net::HTTP.new(@logtail_host, @logtail_port)
288
+ http = Net::HTTP.new(@ingesting_host, @ingesting_port)
286
289
  http.set_debug_output(Config.instance.debug_logger) if Config.instance.debug_logger
287
- if @logtail_scheme == 'https'
290
+ if @ingesting_scheme == 'https'
288
291
  http.use_ssl = true
289
292
  # Verification on Windows fails despite having a valid certificate.
290
293
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
@@ -360,7 +363,7 @@ MESSAGE
360
363
 
361
364
  Logtail::Config.instance.debug do
362
365
  if resp.code == "202"
363
- "Logs successfully sent! View your logs at https://logtail.com"
366
+ "Logs successfully sent! View your logs at https://telemetry.betterstack.com"
364
367
  else
365
368
  "Log delivery failed! status: #{resp.code}, body: #{resp.body}"
366
369
  end
@@ -16,7 +16,7 @@ module Logtail
16
16
 
17
17
  attr_reader :context_snapshot, :event, :level, :message, :progname, :tags, :time
18
18
 
19
- # Creates a log entry suitable to be sent to the Logtail API.
19
+ # Creates a log entry suitable to be sent to the Better Stack Telemetry API.
20
20
  # @param level [Integer] the log level / severity
21
21
  # @param time [Time] the exact time the log message was written
22
22
  # @param progname [String] the progname scope for the log message
@@ -134,13 +134,13 @@ module Logtail
134
134
  end
135
135
 
136
136
  def logtail_logger_frame?(frame)
137
- !frame.absolute_path.nil? && frame.absolute_path.end_with?(LOGGER_FILE)
137
+ !frame.path.nil? && frame.path.end_with?(LOGGER_FILE)
138
138
  end
139
139
 
140
140
  def path_relative_to_app_root(frame)
141
141
  Pathname.new(frame.absolute_path).relative_path_from(root_path).to_s
142
142
  rescue
143
- frame.absolute_path
143
+ frame.absolute_path || frame.path
144
144
  end
145
145
 
146
146
  def root_path
@@ -1,3 +1,3 @@
1
1
  module Logtail
2
- VERSION = "0.1.12"
2
+ VERSION = "0.1.14"
3
3
  end
@@ -125,7 +125,7 @@ describe Logtail::LogDevices::HTTP do
125
125
  let(:time) { Time.utc(2016, 9, 1, 12, 0, 0) }
126
126
 
127
127
  it "should deliver requests on an interval" do
128
- stub = stub_request(:post, "https://in.logtail.com/").
128
+ stub = stub_request(:post, "https://in.logs.betterstack.com/").
129
129
  with(
130
130
  :body => start_with("\x92\x84\xA5level\xA4INFO\xA2dt\xBB2016-09-01T12:00:00.000000Z\xA7message\xB2test log message 1".force_encoding("ASCII-8BIT")),
131
131
  :headers => {
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.12
4
+ version: 0.1.14
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-08-17 00:00:00.000000000 Z
11
+ date: 2025-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
@@ -146,7 +146,6 @@ files:
146
146
  - ".github/workflows/main.yml"
147
147
  - ".gitignore"
148
148
  - ".rspec"
149
- - CHANGELOG.md
150
149
  - Gemfile
151
150
  - LICENSE.md
152
151
  - README.md
data/CHANGELOG.md DELETED
@@ -1,28 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file.
4
-
5
- The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
6
- and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
7
-
8
- ## [Unreleased]
9
-
10
- ## [0.1.0] - 2021-02-11
11
-
12
- - The first version of the client.
13
-
14
- ## [0.1.2] - 2021-04-22
15
-
16
- - Fixed string encoding.
17
-
18
- ## [0.1.3] - 2021-06-11
19
-
20
- - Fixed detection of the frame that calls the logger.
21
-
22
- ## [0.1.7] - 2021-08-16
23
-
24
- - Fixed runtime context's frame label encoding.
25
-
26
- ## [0.1.8] - 2023-01-16
27
-
28
- - Fix issue where message is lost when logging hashes with multiple IO devices (thanks @olivier-thatch!)