@@ -17,13 +17,11 @@ module LogDevices
1717 #
1818 # See {#initialize} for options and more details.
1919 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
2523 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
2725
2826 # Instantiates a new HTTP log device that can be passed to {Logtail::Logger#initialize}.
2927 #
@@ -36,15 +34,15 @@ class HTTP
3634 # you can drop the log messages instead by passing a {DroppingSizedQueue} via the
3735 # `:request_queue` option.
3836 #
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).
4139 # @param [Hash] options the options to create a HTTP log device with.
4240 # @option attributes [Symbol] :batch_size (1000) Determines the maximum of log lines in
4341 # each HTTP payload. If the queue exceeds this limit an HTTP request will be issued. Bigger
4442 # payloads mean higher throughput, but also use more memory. Logtail will not accept
4543 # payloads larger than 1mb.
4644 # @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
4846 # continuous flushing of log message. As a result, flushing must be handled externally
4947 # via the #flush method.
5048 # @option attributes [Symbol] :flush_interval (1) How often the client should
@@ -55,25 +53,30 @@ class HTTP
5553 # single persistent connection. After this number is met, the connection will be closed
5654 # and a new one will be opened.
5755 # @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
5957 # `FlushableDroppingSizedQueue` of size `25`. Meaning once the queue fills up to 25
6058 # requests new requests will be dropped. If you'd prefer to apply back pressure,
6159 # ensuring you do not lose log data, pass a standard {SizedQueue}. See examples for
6260 # 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 }.
6563 #
6664 # @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> "))
6866 #
6967 # @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))
7169 # Logtail::Logger.new(http_log_device)
7270 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+
7376 @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
7780 @batch_size = options [ :batch_size ] || 1_000
7881 @flush_continuously = options [ :flush_continuously ] != false
7982 @flush_interval = options [ :flush_interval ] || 2 # 2 seconds
@@ -153,7 +156,7 @@ def verify_delivery!
153156 if @last_resp . nil?
154157 print "."
155158 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"
157160 else
158161 raise <<-MESSAGE
159162
@@ -282,9 +285,9 @@ def intervaled_flush_ready?
282285
283286 # Builds an `Net::HTTP` object to deliver requests over.
284287 def build_http
285- http = Net ::HTTP . new ( @logtail_host , @logtail_port )
288+ http = Net ::HTTP . new ( @ingesting_host , @ingesting_port )
286289 http . set_debug_output ( Config . instance . debug_logger ) if Config . instance . debug_logger
287- if @logtail_scheme == 'https'
290+ if @ingesting_scheme == 'https'
288291 http . use_ssl = true
289292 # Verification on Windows fails despite having a valid certificate.
290293 http . verify_mode = OpenSSL ::SSL ::VERIFY_NONE
@@ -360,7 +363,7 @@ def deliver_requests(conn)
360363
361364 Logtail ::Config . instance . debug do
362365 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"
364367 else
365368 "Log delivery failed! status: #{ resp . code } , body: #{ resp . body } "
366369 end
0 commit comments