logtail 0.1.13 → 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: 10c467039aa517fd668eb0b4f25a3bc0405331b9c422984b01e7effa7bfd1ceb
4
- data.tar.gz: 2890f2588f6beb9671037e0521a3eb361e80937e0c475b4be2f2895e48422540
3
+ metadata.gz: 6cb9ce58d42f8eaae77256309904b1e1f1d34974ffb2baf9d08b3ae8f9bc9add
4
+ data.tar.gz: cee900d3422c3d51c4b5915b54281c7b4522e1ae49c14e72820539080b013870
5
5
  SHA512:
6
- metadata.gz: 81d0c6479082f302ff146cb321f9483c6b46a8d2fbf9133e1c661bc9694f5d8134447a2ec6d8ab7bfbc6ee36abc66fabe0777e113b199dc31642810fbfee7322
7
- data.tar.gz: 161f16cd44e8522fe9c6e47b31773a2d422372ac082409d3afaec74ba249807af1a51512fcb1c151eb5541ad45cbbfc82d62eccde03231b25129abe0dfda232e
6
+ metadata.gz: 8d7fa9ab0b8ed9b7cb23d5a940485bc523037c31134f68a6a0e9adf91190ef22284008e650b95406d1bb76834744d889569dab81943b3af0ebc69fdda73519a7
7
+ data.tar.gz: 20d6428149c7e2f0687cc0c0af867f16ff1f495c7622b49afef8e661f83900c31c46a00b322e9f15510202f877d70d17196c0163efbfd460b03a2fa8a881e4f5
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Logtail
2
- VERSION = "0.1.13"
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.13
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-11-14 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