logtail-rack 0.2.4 → 0.2.6

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: fd113ab9b17ca26fa87eff47038f60d80eb83faf8e952272fdf50d78282cdb85
4
- data.tar.gz: b10232307696b875ff0ed56fe3e2881e7d010362b2a8aa773a8cae4d40973f69
3
+ metadata.gz: 2e925613f03cc44c9e8b160ca4afefbe3c1716bb4c376d2407af771e9458c76b
4
+ data.tar.gz: f2f8f87d6daa1e6d58e1067c3ebbfa189f2261924e011e9d67906ccea9846ac0
5
5
  SHA512:
6
- metadata.gz: fda6074ed268d9674060dbd1b1356ad17872299956bcf4290b6748dc0ed247afac45a340e2e673ec5206bb81b9e55510b6a4295dae79dbb05a66b5195a79887a
7
- data.tar.gz: 23028ed6c4bfcf5168556d37e73d79a3159b0565802dd35792720282722ca1de7be645795ecfc47a5f9899ee23ec19747fb0c7bcacb523244f94a6d4b0dfce3b
6
+ metadata.gz: 9433eec385c84eb941a88ef2b8d029100562f56a1bef97a16cae4992645bcb880484820ce8f3eee81e386cbc0cba10d03657400b772a1cd225672577e33a408f
7
+ data.tar.gz: f98d540b220f588313e0746333a029aba46ed7004546370de7d33d64da08e09af9b65496e8d989280192a9c128022358876a4bda1b17d78b4445ef498b91abfc
@@ -15,47 +15,50 @@ jobs:
15
15
  fail-fast: false
16
16
  matrix:
17
17
  ruby-version:
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
27
- - jruby-9.2.14.0
28
- - truffleruby-23.0.0
29
- - truffleruby-22.1.0
18
+ - "3"
19
+ - "3.4"
20
+ - "3.3"
21
+ - "3.2"
22
+ - "3.1"
23
+ - "3.0"
24
+ - "2.7"
25
+ - "2.6"
26
+ - "2.5"
27
+ - "2.4"
28
+ - "2.3"
29
+ - "jruby-9.4.3.0"
30
+ - "jruby-9.2.14.0"
31
+ - "truffleruby-23.0.0"
32
+ - "truffleruby-22.1.0"
30
33
  rack-version:
31
- - # default Rack version
34
+ - "" # default Rack version
32
35
 
33
36
  include:
34
- - ruby-version: 2.7
35
- rack-version: ~>1.2.0
36
- - ruby-version: 2.7
37
- rack-version: ~>1.2
38
- - ruby-version: 2.7
39
- rack-version: ~>2.0.0
40
- - ruby-version: 2.7
41
- rack-version: ~>2.0
42
- - ruby-version: 2.7
43
- rack-version: ~>3.0
44
- - ruby-version: 2.7
45
- rack-version: ~>3.0.0
37
+ - ruby-version: "2.7"
38
+ rack-version: "~>1.2.0"
39
+ - ruby-version: "2.7"
40
+ rack-version: "~>1.2"
41
+ - ruby-version: "2.7"
42
+ rack-version: "~>2.0.0"
43
+ - ruby-version: "2.7"
44
+ rack-version: "~>2.0"
45
+ - ruby-version: "2.7"
46
+ rack-version: "~>3.0"
47
+ - ruby-version: "2.7"
48
+ rack-version: "~>3.0.0"
46
49
 
47
- - ruby-version: 3.2
48
- rack-version: ~>1.2.0
49
- - ruby-version: 3.2
50
- rack-version: ~>1.2
51
- - ruby-version: 3.2
52
- rack-version: ~>2.0.0
53
- - ruby-version: 3.2
54
- rack-version: ~>2.0
55
- - ruby-version: 3.2
56
- rack-version: ~>3.0
57
- - ruby-version: 3.2
58
- rack-version: ~>3.0.0
50
+ - ruby-version: "3.2"
51
+ rack-version: "~>1.2.0"
52
+ - ruby-version: "3.2"
53
+ rack-version: "~>1.2"
54
+ - ruby-version: "3.2"
55
+ rack-version: "~>2.0.0"
56
+ - ruby-version: "3.2"
57
+ rack-version: "~>2.0"
58
+ - ruby-version: "3.2"
59
+ rack-version: "~>3.0"
60
+ - ruby-version: "3.2"
61
+ rack-version: "~>3.0.0"
59
62
 
60
63
  steps:
61
64
  - uses: actions/checkout@v2
data/.gitignore CHANGED
@@ -10,6 +10,7 @@
10
10
  .ruby-version
11
11
  coverage
12
12
  Gemfile.lock
13
+ !/example-project/Gemfile.lock
13
14
  *.swp
14
15
  *.gem
15
16
 
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
1
  source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
+
5
+ gem "base64" if RUBY_VERSION >= "3.4.0"
data/README.md CHANGED
@@ -1,10 +1,22 @@
1
- # 🪵 Logtail Integration For Rack
1
+ # [Better Stack](https://betterstack.com/logs) Rack client
2
+
3
+ 📣 Logtail is now part of Better Stack. [Learn more ⇗](https://betterstack.com/press/introducing-better-stack/)
4
+
5
+ [![Better Stack dashboard](https://github.com/logtail/logtail-python/assets/10132717/e2a1196b-7924-4abc-9b85-055e17b5d499)](https://betterstack.com/logs)
2
6
 
3
7
  [![ISC License](https://img.shields.io/badge/license-ISC-ff69b4.svg)](LICENSE.md)
4
8
  [![Gem Version](https://badge.fury.io/rb/logtail-rack.svg)](https://badge.fury.io/rb/logtail-rack)
5
- [![Build Status](https://github.com/logtail/logtail-ruby-rack/workflows/build/badge.svg)](https://github.com/logtail/logtail-ruby-rack/actions?query=workflow%3Abuild)
9
+ [![Build Status](https://github.com/logtail/logtail-ruby-rack/actions/workflows/main.yml/badge.svg)](https://github.com/logtail/logtail-ruby-rack/actions/workflows/main.yml)
10
+
11
+ Experience SQL-compatible structured log management based on ClickHouse. [Learn more ⇗](https://betterstack.com/logs)
12
+
13
+ ## Documentation
14
+
15
+ [Getting started ⇗](https://betterstack.com/docs/logs/ruby-and-rails/#logging-from-rack)
16
+
17
+ ## Need help?
18
+ Please let us know at [hello@betterstack.com](mailto:hello@betterstack.com). We're happy to help!
6
19
 
7
- This library integrates the [`logtail` Ruby library](https://github.com/logtail/logtail-ruby) with the [rack](https://github.com/rack/rack) framework,
8
- turning your Rack logs into rich structured events.
20
+ ---
9
21
 
10
- * **Sign-up: [https://logtail.com](https://logtail.com)**
22
+ [ISC license](https://github.com/logtail/logtail-ruby-rack/blob/main/LICENSE.md), [example project](https://github.com/logtail/logtail-ruby-rack/tree/main/example-project)
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "rack", "~> 3.0"
4
+
5
+ gem "rackup", "~> 2.1"
6
+
7
+ gem "logtail-rack", "~> 0.2.6"
@@ -0,0 +1,23 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ logtail (0.1.15)
5
+ msgpack (~> 1.0)
6
+ logtail-rack (0.2.6)
7
+ logtail (~> 0.1)
8
+ rack (>= 1.2, < 4.0)
9
+ msgpack (1.8.0)
10
+ rack (3.1.9)
11
+ rackup (2.2.1)
12
+ rack (>= 3)
13
+
14
+ PLATFORMS
15
+ arm64-darwin-22
16
+
17
+ DEPENDENCIES
18
+ logtail-rack (~> 0.2.6)
19
+ rack (~> 3.0)
20
+ rackup (~> 2.1)
21
+
22
+ BUNDLED WITH
23
+ 2.3.14
@@ -0,0 +1,40 @@
1
+ # Example project
2
+
3
+ To help you get started with using Better Stack in your Rack projects, we have prepared a simple program that showcases the usage of Logtail logger.
4
+
5
+ ## Download and install the example project
6
+
7
+ You can download the [example project](https://github.com/logtail/logtail-ruby-rack/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:
8
+
9
+ ```bash
10
+ bundle install
11
+ ```
12
+
13
+ This will install all dependencies listed in the `Gemfile.lock` file.
14
+
15
+ Then replace `<source_token>` and `<ingesting_host>` in `config.ru` with your actual source token and ingesting host which you can find by going to [Better Stack Telemetry](https://teleemetry.betterstack.com/dashboard) -> Source -> Configure.
16
+
17
+ ```ruby
18
+ http_io_device = Logtail::LogDevices::HTTP.new("<source_token>", ingesting_host: "<ingesting_host>")
19
+ ```
20
+
21
+ ## Run the example project
22
+
23
+ To run the example application, run the following command:
24
+
25
+ ```bash
26
+ rackup
27
+ ```
28
+
29
+ This will start a local server and you visit [http://127.0.0.1:9292](http://127.0.0.1:9292) in your browser.
30
+
31
+ You should see the following output:
32
+
33
+ ```bash
34
+ All done!
35
+ Log into your Logtail account to check your logs.
36
+ ```
37
+
38
+ This will create a total of 4 different logs. You can review these logs in Better Stack.
39
+
40
+ You can visit any path on the server to see the request path being logged in context. Visit [/error](http://127.0.0.1:9292) to see an example exception being logged.
@@ -0,0 +1,23 @@
1
+ require 'logtail-rack'
2
+ require './logging_app'
3
+
4
+ # Initialization of logging middlewares
5
+ use Logtail::Integrations::Rack::HTTPContext
6
+ use Logtail::Integrations::Rack::HTTPEvents
7
+ use Logtail::Integrations::Rack::ErrorEvent
8
+
9
+ # HTTP IO device sends logs to Better Stack, replace <source_token> and <ingesting_host> with your real source token and ingesting host
10
+ http_io_device = Logtail::LogDevices::HTTP.new("<source_token>", ingesting_host: "<ingesting_host>")
11
+
12
+ # STDOUT IO device sends logs to console output
13
+ stdout_io_device = STDOUT
14
+
15
+ # Logger initialization, you can use any number of IO devices
16
+ logger = Logtail::Logger.new(http_io_device, stdout_io_device)
17
+ Logtail::Config.instance.logger = logger
18
+
19
+ # App initialization
20
+ logging_app = LoggingApp.new(logger)
21
+ run do |env|
22
+ logging_app.run(env)
23
+ end
@@ -0,0 +1,24 @@
1
+ require 'logtail-rack'
2
+
3
+ class LoggingApp
4
+ def initialize(logger)
5
+ @logger = logger
6
+ end
7
+
8
+ def run(env)
9
+ @logger.info("I am using Better Stack! 🚀")
10
+
11
+ # You can also provide additional information when logging
12
+ @logger.debug("Logging structured data...",
13
+ name: {
14
+ first: "John",
15
+ last: "Smith"
16
+ },
17
+ id: 123456
18
+ )
19
+
20
+ raise RuntimeError.new("Visiting /error raises an error. You should see it in Better Stack.") if env["REQUEST_PATH"].start_with?("/error")
21
+
22
+ [200, {}, ["All done!\nLog into your Logtail account to check your logs."]]
23
+ end
24
+ end
@@ -269,10 +269,11 @@ module Logtail
269
269
  end
270
270
 
271
271
  def filter_http_headers(headers)
272
- headers.each do |name, _|
273
- normalized_header_name = self.class.normalize_header_name(name)
274
- headers[name] = "[FILTERED]" if self.class.http_header_filters&.include?(normalized_header_name)
275
- end
272
+ headers.map do |name, value|
273
+ normalized_name = self.class.normalize_header_name(name)
274
+ is_filtered = self.class.http_header_filters&.include?(normalized_name)
275
+ [name, is_filtered ? "[FILTERED]" : value]
276
+ end.to_h
276
277
  end
277
278
 
278
279
  def safe_to_i(val)
@@ -1,7 +1,7 @@
1
1
  module Logtail
2
2
  module Integrations
3
3
  module Rack
4
- VERSION = "0.2.4"
4
+ VERSION = "0.2.6"
5
5
  end
6
6
  end
7
7
  end
@@ -5,8 +5,8 @@ require "logtail-rack/version"
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "logtail-rack"
7
7
  spec.version = Logtail::Integrations::Rack::VERSION
8
- spec.authors = ["Logtail"]
9
- spec.email = ["hi@logtail.com"]
8
+ spec.authors = ["Better Stack"]
9
+ spec.email = ["hello@betterstack.com"]
10
10
 
11
11
  spec.summary = %q{Logtail integration for Rack}
12
12
  spec.homepage = "https://github.com/logtail/logtail-ruby-rack"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logtail-rack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
- - Logtail
7
+ - Better Stack
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-09-06 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: logtail
@@ -88,7 +88,7 @@ dependencies:
88
88
  version: '3.0'
89
89
  description:
90
90
  email:
91
- - hi@logtail.com
91
+ - hello@betterstack.com
92
92
  executables: []
93
93
  extensions: []
94
94
  extra_rdoc_files: []
@@ -100,6 +100,11 @@ files:
100
100
  - LICENSE.md
101
101
  - README.md
102
102
  - Rakefile
103
+ - example-project/Gemfile
104
+ - example-project/Gemfile.lock
105
+ - example-project/README.md
106
+ - example-project/config.ru
107
+ - example-project/logging_app.rb
103
108
  - lib/logtail-rack.rb
104
109
  - lib/logtail-rack/config.rb
105
110
  - lib/logtail-rack/error_event.rb