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 +4 -4
- data/.github/workflows/main.yml +40 -37
- data/.gitignore +1 -0
- data/Gemfile +2 -0
- data/README.md +17 -5
- data/example-project/Gemfile +7 -0
- data/example-project/Gemfile.lock +23 -0
- data/example-project/README.md +40 -0
- data/example-project/config.ru +23 -0
- data/example-project/logging_app.rb +24 -0
- data/lib/logtail-rack/http_events.rb +5 -4
- data/lib/logtail-rack/version.rb +1 -1
- data/logtail-ruby-rack.gemspec +2 -2
- metadata +9 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e925613f03cc44c9e8b160ca4afefbe3c1716bb4c376d2407af771e9458c76b
|
4
|
+
data.tar.gz: f2f8f87d6daa1e6d58e1067c3ebbfa189f2261924e011e9d67906ccea9846ac0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9433eec385c84eb941a88ef2b8d029100562f56a1bef97a16cae4992645bcb880484820ce8f3eee81e386cbc0cba10d03657400b772a1cd225672577e33a408f
|
7
|
+
data.tar.gz: f98d540b220f588313e0746333a029aba46ed7004546370de7d33d64da08e09af9b65496e8d989280192a9c128022358876a4bda1b17d78b4445ef498b91abfc
|
data/.github/workflows/main.yml
CHANGED
@@ -15,47 +15,50 @@ jobs:
|
|
15
15
|
fail-fast: false
|
16
16
|
matrix:
|
17
17
|
ruby-version:
|
18
|
-
- 3
|
19
|
-
- 3.
|
20
|
-
- 3.
|
21
|
-
- 2
|
22
|
-
-
|
23
|
-
-
|
24
|
-
- 2.
|
25
|
-
- 2.
|
26
|
-
-
|
27
|
-
-
|
28
|
-
-
|
29
|
-
-
|
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
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,10 +1,22 @@
|
|
1
|
-
#
|
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
|
+
[](https://betterstack.com/logs)
|
2
6
|
|
3
7
|
[](LICENSE.md)
|
4
8
|
[](https://badge.fury.io/rb/logtail-rack)
|
5
|
-
[](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
|
-
|
8
|
-
turning your Rack logs into rich structured events.
|
20
|
+
---
|
9
21
|
|
10
|
-
|
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,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.
|
273
|
-
|
274
|
-
|
275
|
-
|
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)
|
data/lib/logtail-rack/version.rb
CHANGED
data/logtail-ruby-rack.gemspec
CHANGED
@@ -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 = ["
|
9
|
-
spec.email = ["
|
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
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Better Stack
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
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
|
-
-
|
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
|