timber-rack 1.0.0 → 1.0.1
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/Gemfile +0 -4
- data/README.md +0 -1
- data/lib/timber-rack/http_context.rb +3 -3
- data/lib/timber-rack/http_events.rb +1 -2
- data/lib/timber-rack/http_request.rb +14 -28
- data/lib/timber-rack/http_response.rb +11 -20
- data/lib/timber-rack/user_context.rb +3 -6
- data/lib/timber-rack/version.rb +1 -1
- data/timber-rack.gemspec +2 -2
- metadata +18 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9b77ec2fe77256fca4523cff6c8920899d470ecc6f79416a8ae0d898a53218a
|
4
|
+
data.tar.gz: 7cbc3e59167ec9bc87802519d0ae78ff27e4d1a52eb783d80b4c88ee973d6296
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ff4000fb69f6245488044fa6e021a9ee1b44ab3fbca1a6cd5d4875f977cbdeb75315500f2f44d035d02a70220ef43bfc10dd42cc140144eb1b7e46eb72e422c
|
7
|
+
data.tar.gz: 63867ce360ac7055cdc609c769a7140933b584107c03b6dffee36332fa753e02799f6a8d73a3f00dd927e60a9f4114cd44dd51ec0f18ad8e58b0a16caa499b1b
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
[](LICENSE.md)
|
4
4
|
[](http://www.rubydoc.info/github/timberio/timber-ruby-rack)
|
5
5
|
[](https://travis-ci.org/timberio/timber-ruby-rack)
|
6
|
-
[](https://codeclimate.com/github/timberio/timber-ruby-rack)
|
7
6
|
|
8
7
|
This library integrates the [`timber` Ruby library](https://github.com/timberio/timber-ruby) with the [Rack](https://github.com/rack/rack) framework,
|
9
8
|
turning your Rack logs into rich structured events.
|
@@ -141,8 +141,7 @@ module Timber
|
|
141
141
|
status, headers, body = @app.call(env)
|
142
142
|
|
143
143
|
Config.instance.logger.info do
|
144
|
-
|
145
|
-
http_context = CurrentContext.fetch(http_context_key)
|
144
|
+
http_context = CurrentContext.fetch(:http)
|
146
145
|
content_length = headers[CONTENT_LENGTH_KEY]
|
147
146
|
duration_ms = (Time.now - start) * 1000.0
|
148
147
|
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require "timber/util"
|
2
|
-
|
3
1
|
module Timber
|
4
2
|
module Integrations
|
5
3
|
module Rack
|
@@ -9,37 +7,25 @@ module Timber
|
|
9
7
|
# @note This event should be installed automatically through integrations,
|
10
8
|
# such as the {Integrations::ActionController::LogSubscriber} integration.
|
11
9
|
class HTTPRequest
|
12
|
-
BODY_MAX_BYTES = 8192.freeze
|
13
|
-
HEADERS_JSON_MAX_BYTES = 8192.freeze
|
14
|
-
HEADERS_TO_SANITIZE = ['authorization', 'x-amz-security-token'].freeze
|
15
|
-
HOST_MAX_BYTES = 256.freeze
|
16
|
-
METHOD_MAX_BYTES = 20.freeze
|
17
|
-
PATH_MAX_BYTES = 2048.freeze
|
18
|
-
QUERY_STRING_MAX_BYTES = 2048.freeze
|
19
|
-
REQUEST_ID_MAX_BYTES = 256.freeze
|
20
|
-
SCHEME_MAX_BYTES = 20.freeze
|
21
|
-
SERVICE_NAME_MAX_BYTES = 256.freeze
|
22
|
-
|
23
10
|
attr_reader :body, :content_length, :headers, :headers_json, :host, :method, :path, :port,
|
24
11
|
:query_string, :request_id, :scheme, :service_name
|
25
12
|
|
26
13
|
def initialize(attributes)
|
27
|
-
|
28
|
-
|
29
|
-
|
14
|
+
@body = attributes[:body]
|
15
|
+
@content_length = attributes[:content_length]
|
16
|
+
@headers = attributes[:headers]
|
17
|
+
@host = attributes[:host]
|
18
|
+
@method = attributes[:method]
|
19
|
+
@path = attributes[:path]
|
20
|
+
@port = attributes[:port]
|
21
|
+
@query_string = attributes[:query_string]
|
22
|
+
@scheme = attributes[:scheme]
|
23
|
+
@request_id = attributes[:request_id]
|
24
|
+
@service_name = attributes[:service_name]
|
30
25
|
|
31
|
-
@
|
32
|
-
|
33
|
-
|
34
|
-
@headers_json = @headers.to_json.byteslice(0, HEADERS_JSON_MAX_BYTES)
|
35
|
-
@host = normalizer.fetch(:host, :string, :limit => HOST_MAX_BYTES)
|
36
|
-
@method = normalizer.fetch!(:method, :string, :upcase => true, :limit => METHOD_MAX_BYTES)
|
37
|
-
@path = normalizer.fetch(:path, :string, :limit => PATH_MAX_BYTES)
|
38
|
-
@port = normalizer.fetch(:port, :integer)
|
39
|
-
@query_string = normalizer.fetch(:query_string, :string, :limit => QUERY_STRING_MAX_BYTES)
|
40
|
-
@scheme = normalizer.fetch(:scheme, :string, :limit => SCHEME_MAX_BYTES)
|
41
|
-
@request_id = normalizer.fetch(:request_id, :string, :limit => REQUEST_ID_MAX_BYTES)
|
42
|
-
@service_name = normalizer.fetch(:service_name, :string, :limit => SERVICE_NAME_MAX_BYTES)
|
26
|
+
if @headers
|
27
|
+
@headers_json = @headers.to_json
|
28
|
+
end
|
43
29
|
end
|
44
30
|
|
45
31
|
def message
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require "timber/util"
|
2
|
-
|
3
1
|
module Timber
|
4
2
|
module Integrations
|
5
3
|
module Rack
|
@@ -7,29 +5,22 @@ module Timber
|
|
7
5
|
# to clients.
|
8
6
|
|
9
7
|
class HTTPResponse
|
10
|
-
BODY_MAX_BYTES = 8192.freeze
|
11
|
-
HEADERS_JSON_MAX_BYTES = 256.freeze
|
12
|
-
HEADERS_TO_SANITIZE = ['authorization', 'x-amz-security-token'].freeze
|
13
|
-
REQUEST_ID_MAX_BYTES = 256.freeze
|
14
|
-
SERVICE_NAME_MAX_BYTES = 256.freeze
|
15
|
-
|
16
8
|
attr_reader :body, :content_length, :headers, :headers_json, :http_context, :request_id, :service_name,
|
17
9
|
:status, :duration_ms
|
18
10
|
|
19
11
|
def initialize(attributes)
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
@body = normalizer.fetch(:body, :string, :limit => body_limit)
|
25
|
-
@content_length = normalizer.fetch(:content_length, :integer)
|
26
|
-
@headers = normalizer.fetch(:headers, :hash, :sanitize => headers_to_sanitize)
|
27
|
-
@headers_json = @headers.to_json.byteslice(0, HEADERS_JSON_MAX_BYTES)
|
12
|
+
@body = attributes[:body]
|
13
|
+
@content_length = attributes[:content_length]
|
14
|
+
@headers = attributes[:headers]
|
28
15
|
@http_context = attributes[:http_context]
|
29
|
-
@request_id =
|
30
|
-
@service_name =
|
31
|
-
@status =
|
32
|
-
@duration_ms =
|
16
|
+
@request_id = attributes[:request_id]
|
17
|
+
@service_name = attributes[:service_name]
|
18
|
+
@status = attributes[:status]
|
19
|
+
@duration_ms = attributes[:duration_ms]
|
20
|
+
|
21
|
+
if @headers
|
22
|
+
@headers_json = @headers.to_json
|
23
|
+
end
|
33
24
|
end
|
34
25
|
|
35
26
|
# Returns the human readable log message for this event.
|
@@ -67,13 +67,10 @@ module Timber
|
|
67
67
|
def call(env)
|
68
68
|
user_hash = get_user_hash(env)
|
69
69
|
if user_hash
|
70
|
-
|
71
|
-
CurrentContext.with(context) do
|
72
|
-
@app.call(env)
|
73
|
-
end
|
74
|
-
else
|
75
|
-
@app.call(env)
|
70
|
+
CurrentContext.add({user: user_hash})
|
76
71
|
end
|
72
|
+
|
73
|
+
@app.call(env)
|
77
74
|
end
|
78
75
|
|
79
76
|
private
|
data/lib/timber-rack/version.rb
CHANGED
data/timber-rack.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Timber Technologies, Inc."]
|
10
10
|
spec.email = ["hi@timber.io"]
|
11
11
|
|
12
|
-
spec.summary = %q{Timber
|
12
|
+
spec.summary = %q{Timber integration for Rack}
|
13
13
|
spec.homepage = "https://docs.timber.io/languages/ruby/"
|
14
14
|
spec.license = "ISC"
|
15
15
|
|
@@ -33,7 +33,7 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
34
34
|
spec.require_paths = ["lib"]
|
35
35
|
|
36
|
-
|
36
|
+
spec.add_dependency "timber", "~> 3.0"
|
37
37
|
spec.add_runtime_dependency "rack", ">= 1.2", "< 3.0"
|
38
38
|
|
39
39
|
spec.add_development_dependency "bundler", ">= 0.0"
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: timber-rack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Timber Technologies, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03-
|
11
|
+
date: 2019-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: timber
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rack
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,10 +137,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
137
|
- !ruby/object:Gem::Version
|
124
138
|
version: '0'
|
125
139
|
requirements: []
|
126
|
-
rubygems_version: 3.0.
|
140
|
+
rubygems_version: 3.0.1
|
127
141
|
signing_key:
|
128
142
|
specification_version: 4
|
129
|
-
summary: Timber
|
130
|
-
augments your logs with rich metadata and context making them easier to search,
|
131
|
-
use, and read.
|
143
|
+
summary: Timber integration for Rack
|
132
144
|
test_files: []
|